Subject: 24.1.50; install-etc target installs emacs.png outside of $DESTDIR

From: Ulrich Mueller <[email-masked]>
Date: Sat, 19 May 2012 10:08:28 +0200

Forwarding downstream bug <https://bugs.gentoo.org/show_bug.cgi?id=416515>.

When installing Emacs from BZR trunk as of today, the "install-etc"
target in the top-level Makefile tries to install files outside of
$DESTDIR. In Gentoo's sandboxed environment this leads to an access
violation.

Here is the relevant part of the build log:

umask 022; /bin/mkdir -p /var/tmp/portage/app-editors/emacs-vcs-24.1.9999/image//usr/share/applications
/usr/bin/install -c -m 644 /var/tmp/portage/app-editors/emacs-vcs-24.1.9999/work/emacs-vcs-24.1.9999/etc/emacs.desktop \
  /var/tmp/portage/app-editors/emacs-vcs-24.1.9999/image//usr/share/applications/emacs.desktop
thisdir=`/bin/pwd`; \
cd /var/tmp/portage/app-editors/emacs-vcs-24.1.9999/work/emacs-vcs-24.1.9999/etc/images/icons || exit 1; umask 022 ; \
for dir in */*/apps */*/mimetypes; do \
  [ -d ${dir} ] || continue ; \
  ( cd ${thisdir}; /bin/mkdir -p /usr/share/icons/${dir} ) ; \
  for icon in ${dir}/*.*; do \
    [ -r ${icon} ] || continue ; \
    ( cd ${thisdir}; \
      /usr/bin/install -c -m 644 /var/tmp/portage/app-editors/emacs-vcs-24.1.9999/work/emacs-vcs-24.1.9999/etc/images/icons/${icon} /usr/share/icons/${icon} ) \
    || exit 1; \
  done ; \
done
ACCESS DENIED  unlink:       /usr/share/icons/hicolor/128x128/apps/emacs.png
/usr/bin/install: cannot remove ‘/usr/share/icons/hicolor/128x128/apps/emacs.png’: Permission denied
make: *** [install-etc] Error 1
 * ERROR: app-editors/emacs-vcs-24.1.9999 failed (install phase):
 * emake failed

The breakage was introduced by this commit:
------------------------------------------------------------
revno: 108266
committer: Glenn Morris <[email-masked]>
branch nick: trunk
timestamp: Thu 2012-05-17 15:13:02 -0400
message:
  Simplify install-etc rule
  
  * Makefile.in (install-etc, mkdir):
  Make relevant directories in install-etc rather than mkdir.
------------------------------------------------------------

The following patch should fix it:

2012-05-19  Ulrich Müller  <[email-masked]>

	* Makefile.in (install-etc): Install icons inside of DESTDIR.

--- emacs-orig/Makefile.in
+++ emacs/Makefile.in
@@ -626,11 +626,11 @@
 	cd ${iconsrcdir} || exit 1; umask 022 ; \
 	for dir in */*/apps */*/mimetypes; do \
 	  [ -d $${dir} ] || continue ; \
-	  ( cd $${thisdir}; ${MKDIR_P} ${icondir}/$${dir} ) ; \
+	  ( cd $${thisdir}; ${MKDIR_P} $(DESTDIR)${icondir}/$${dir} ) ; \
 	  for icon in $${dir}/*.*; do \
 	    [ -r $${icon} ] || continue ; \
 	    ( cd $${thisdir}; \
-	      ${INSTALL_DATA} ${iconsrcdir}/$${icon} ${icondir}/$${icon} ) \
+	      ${INSTALL_DATA} ${iconsrcdir}/$${icon} $(DESTDIR)${icondir}/$${icon} ) \
 	    || exit 1; \
 	  done ; \
 	done