Subject: packages and DESTDIR
To: None <tech-pkg@netbsd.org>
From: Brook Milligan <brook@trillium.NMSU.Edu>
List: tech-pkg
Date: 09/23/1998 11:58:36
I am trying to use DESTDIR to prevent newly compiled packages from
overwriting my live system.  So far most seem to work fine, with
devel/gmake and devel/readline being notable exceptions.

The problem in both cases is that DESTDIR is used twice for the
install targets; it is included in the PREFIX and then things are
installed, for example, in $(DESDIR)/$(PREFIX).  Thus, things end up,
for example, in $(DESTDIR)/$(DESTDIR)/usr/pkg/... .  

The attached patch fixes gmake by removing DESTDIR from the install
actions.

The fix for readline is a bit more complex because its Makefile is
patched to use bsd.lib.mk which is where the additional DESTDIR comes
in.  As a result, I'm not sure what to do with the readline Makefile.
Suggestions welcome.

Cheers,
Brook

========   patch for pkgsrc/devel/gmake/patches   =========================

--- Makefile.in.orig	Wed Sep 23 11:10:23 1998
+++ Makefile.in	Wed Sep 23 11:11:28 1998
@@ -217,18 +217,18 @@
 
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
-	$(mkinstalldirs) $(DESTDIR)$(bindir)
+	$(mkinstalldirs) $(bindir)
 	@list='$(bin_PROGRAMS)'; for p in $$list; do \
 	  if test -f $$p; then \
-	    echo "  $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \
-	     $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
+	    echo "  $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed '$(transform)'`"; \
+	     $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed '$(transform)'`; \
 	  else :; fi; \
 	done
 
 uninstall-binPROGRAMS:
 	@$(NORMAL_UNINSTALL)
 	list='$(bin_PROGRAMS)'; for p in $$list; do \
-	  rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \
+	  rm -f $(bindir)/`echo $$p|sed '$(transform)'`; \
 	done
 
 .c.o:
@@ -306,21 +306,21 @@
 
 install-info-am: $(INFO_DEPS)
 	@$(NORMAL_INSTALL)
-	$(mkinstalldirs) $(DESTDIR)$(infodir)
+	$(mkinstalldirs) $(infodir)
 	@for file in $(INFO_DEPS); do \
 	  d=$(srcdir); \
 	  for ifile in `cd $$d && echo $$file $$file-[0-9] $$file-[0-9][0-9]`; do \
 	    if test -f $$d/$$ifile; then \
-	      echo " $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile"; \
-	      $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile; \
+	      echo " $(INSTALL_DATA) $$d/$$ifile $(infodir)/$$ifile"; \
+	      $(INSTALL_DATA) $$d/$$ifile $(infodir)/$$ifile; \
 	    else : ; fi; \
 	  done; \
 	done
 	@$(POST_INSTALL)
 	@if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
 	  for file in $(INFO_DEPS); do \
-	    echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";\
-	    install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :;\
+	    echo " install-info --info-dir=$(infodir) $(infodir)/$$file";\
+	    install-info --info-dir=$(infodir) $(infodir)/$$file || :;\
 	  done; \
 	else : ; fi
 
@@ -331,11 +331,11 @@
 	else ii=; fi; \
 	for file in $(INFO_DEPS); do \
 	  test -z "$ii" \
-	    || install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \
+	    || install-info --info-dir=$(infodir) --remove $$file; \
 	done
 	@$(NORMAL_UNINSTALL)
 	for file in $(INFO_DEPS); do \
-	  (cd $(DESTDIR)$(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \
+	  (cd $(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \
 	done
 
 dist-info: $(INFO_DEPS)
@@ -366,7 +366,7 @@
 	done
 
 install-man1:
-	$(mkinstalldirs) $(DESTDIR)$(man1dir)
+	$(mkinstalldirs) $(man1dir)
 	@list='$(man1_MANS)'; \
 	l2='$(man_MANS)'; for i in $$l2; do \
 	  case "$$i" in \
@@ -379,8 +379,8 @@
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-	  echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \
-	  $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \
+	  echo " $(INSTALL_DATA) $$file $(man1dir)/$$inst"; \
+	  $(INSTALL_DATA) $$file $(man1dir)/$$inst; \
 	done
 
 uninstall-man1:
@@ -394,8 +394,8 @@
 	  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
 	  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
 	  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-	  echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \
-	  rm -f $(DESTDIR)$(man1dir)/$$inst; \
+	  echo " rm -f $(man1dir)/$$inst"; \
+	  rm -f $(man1dir)/$$inst; \
 	done
 install-man: $(MANS)
 	@$(NORMAL_INSTALL)
@@ -588,8 +588,8 @@
 install-strip:
 	$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
 installdirs: installdirs-recursive
-	$(mkinstalldirs)  $(DATADIR)$(bindir) $(DESTDIR)$(infodir) \
-		$(DESTDIR)$(mandir)/man1
+	$(mkinstalldirs)  $(DATADIR)$(bindir) $(infodir) \
+		$(mandir)/man1
 
 
 mostlyclean-generic:
@@ -657,7 +657,7 @@
 
 install-exec-local:
 	@if $(inst_setgid); then \
-	   app=$(DESTDIR)$(bindir)/`echo $(bin_PROGRAMS)|sed '$(transform)'`; \
+	   app=$(bindir)/`echo $(bin_PROGRAMS)|sed '$(transform)'`; \
 	   if chgrp $(inst_group) $$app && chmod g+s $$app; then \
 	     echo "chgrp $(inst_group) $$app && chmod g+s $$app"; \
 	   else \