File checkinstall-destdir.patch of Package checkinstall

Index: Makefile
===================================================================
--- Makefile.orig	2009-06-06 22:41:12.000000000 +0200
+++ Makefile	2009-12-07 15:00:06.998174340 +0100
@@ -1,6 +1,7 @@
 # $Id: Makefile,v 1.6.2.1 2008/11/09 07:48:18 izto Exp $
 
 # Where to install.
+DESTDIR=
 PREFIX=/usr/local
 BINDIR=$(PREFIX)/sbin
 LCDIR=$(PREFIX)/lib/checkinstall/locale
@@ -25,20 +26,20 @@ install: all
 	export
 	$(MAKE) -C installwatch install
 	
-	mkdir -p $(BINDIR)
-	install checkinstall makepak $(BINDIR)
+	mkdir -p $(DESTDIR)$(BINDIR)
+	install checkinstall makepak $(DESTDIR)$(BINDIR)
 	for file in locale/*.mo ; do \
 		LANG=`echo $$file | sed -e 's|locale/checkinstall-||' \
 			-e 's|\.mo||'` && \
-		mkdir -p $(LCDIR)/$${LANG}/LC_MESSAGES && \
-		cp $$file $(LCDIR)/$${LANG}/LC_MESSAGES/checkinstall.mo || \
+		mkdir -p $(DESTDIR)$(LCDIR)/$${LANG}/LC_MESSAGES && \
+		install $$file $(DESTDIR)$(LCDIR)/$${LANG}/LC_MESSAGES/checkinstall.mo || \
 		exit 1 ; \
 	done
 	
-	mkdir -p $(CONFDIR)
-	install -m644  checkinstallrc-dist $(CONFDIR)
-	if ! [ -f $(CONFDIR)/checkinstallrc ]; then \
-		cp $(CONFDIR)/checkinstallrc-dist $(CONFDIR)/checkinstallrc; \
+	mkdir -p $(DESTDIR)$(CONFDIR)
+	install -m644  checkinstallrc-dist $(DESTDIR)$(CONFDIR)
+	if ! [ -f $(DESTDIR)$(CONFDIR)/checkinstallrc ]; then \
+		install $(DESTDIR)$(CONFDIR)/checkinstallrc-dist $(DESTDIR)$(CONFDIR)/checkinstallrc; \
 	else \
 		echo; \
 		echo; \
@@ -47,7 +48,7 @@ install: all
 		echo An existing checkinstallrc file has been found. ;\
 		echo The one from this distribution can be found at: ; \
 		echo; \
-		echo -e \\t$(CONFDIR)/checkinstallrc-dist ; \
+		echo -e \\t$(DESTDIR)$(CONFDIR)/checkinstallrc-dist ; \
 		echo; \
 		echo; \
 		echo ======================================================== ;\
Index: installwatch/Makefile
===================================================================
--- installwatch/Makefile.orig	2009-06-06 22:41:12.000000000 +0200
+++ installwatch/Makefile	2009-12-07 15:02:49.622561338 +0100
@@ -5,6 +5,7 @@
 # Make sure the directory you specify exists.
 
 PREFIX=/usr/local
+DESTDIR=
 
 # End of configurable part
 
@@ -25,19 +26,19 @@ localdecls.h: create-localdecls
 	./create-localdecls
 
 install: all
-	mkdir -p $(LIBDIR)
-	mkdir -p $(BINDIR)
-	if [ -r $(LIBDIR)/installwatch.so ]; then \
-		rm -f  $(LIBDIR)/installwatch.so; \
+	mkdir -p $(DESTDIR)$(LIBDIR)
+	mkdir -p $(DESTDIR)$(BINDIR)
+	if [ -r $(DESTDIR)$(LIBDIR)/installwatch.so ]; then \
+		rm -f  $(DESTDIR)$(LIBDIR)/installwatch.so; \
 	fi
-	install installwatch.so $(LIBDIR)
+	install -s installwatch.so $(DESTDIR)$(LIBDIR)
 	
-	sed -e "s|#PREFIX#|$(PREFIX)|" < installwatch > $(BINDIR)/installwatch
-	chmod 755 $(BINDIR)/installwatch
+	sed -e "s|#PREFIX#|$(PREFIX)|" < installwatch > $(DESTDIR)$(BINDIR)/installwatch
+	chmod 755 $(DESTDIR)$(BINDIR)/installwatch
 
 uninstall:
-	rm -f $(LIBDIR)/installwatch.so
-	rm -f $(BINDIR)/installwatch
+	rm -f $(DESTDIR)$(LIBDIR)/installwatch.so
+	rm -f $(DESTDIR)$(BINDIR)/installwatch
 	
 clean:
 	rm -f *~ *.bak *.o installwatch.so core localdecls.h libctest test-installwatch
@@ -47,6 +48,6 @@ tarball: clean
 
 test: install
 	gcc -Wall -DVERSION=\"$(VERSION)\" -o test-installwatch test-installwatch.c -ldl
-	$(PREFIX)/bin/installwatch ./test-installwatch
+	$(DESTDIR)$(PREFIX)/bin/installwatch ./test-installwatch