Subject: bug#9578: closed (Re: bug#9578: make uninstall fails after make install-data in empty prefix.)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 26 Sep 2011 19:57:03 +0000

Your bug report

#9578: make uninstall fails after make install-data in empty prefix.

which was filed against the automake package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
9578: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9578
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#9578: make uninstall fails after make install-data in empty prefix.
From: Stefano Lattarini <[email-masked]>
To: [email-masked]
Cc: Nick Bowler <[email-masked]>, [email-masked], [email-masked]
Date: Mon, 26 Sep 2011 21:55:30 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

On Saturday 24 September 2011, Stefano Lattarini wrote:
> On Thursday 22 September 2011, Nick Bowler wrote:
> > Hello,
> >
> Hi Nick, thanks for the report.
> 
> > I noticed a problem testing the uninstall target of my
> > automake-generated Makefiles.  If the install prefix does not exist
> > before installation, automake will create the necessary directories.
> > But if you run a plain "make install-data" (without make install-exec),
> > the directories for executables are (unsurprisingly) not created.  The
> > problem is that "make uninstall" fails in this case:
> >
> I'm not yet sure whether this should be considered a bug or a feature...
> I'm inclined to agree with you that it's more of a bug though, so I'll
> push the attached patch to maint in a few days if nobody objects.  This
> change is not completely obvious, so any review would be appreciated.
> 
> Notice that the test coverage added by the patch is far from perfect, but
> I'd rather improve it in the `testsuite-work' branch only, so that I'll
> be able to use TAP and won't be forced to write 10 or so new "sister
> tests" instead.
>
> Thanks,
>    Stefano
> 

I've squashed in the following, and pushed.  I'm thus closing the bug
report.

Regards,
  Stefano

-*-*-*-

diff --git a/tests/uninstall-fail.test b/tests/uninstall-fail.test
index 6ba0eba..a3e7a7a 100755
--- a/tests/uninstall-fail.test
+++ b/tests/uninstall-fail.test
@@ -16,7 +16,7 @@
 
 # "make uninstall" complains and errors out on failures.
 
-# FIXME: this test only dealt with DATA primary; maybe we need sister
+# FIXME: this test only deal with DATA primary; maybe we need sister
 # tests for other primaries too?  E.g., SCRIPTS, PROGRAMS, LISP, PYTHON,
 # etc...
 
diff --git a/tests/uninstall-pr9578.test b/tests/uninstall-pr9578.test
index 3f67203..9aea52d 100755
--- a/tests/uninstall-pr9578.test
+++ b/tests/uninstall-pr9578.test
@@ -17,6 +17,10 @@
 # Check against automake bug#9578: "make uninstall" issued before
 # "make install" or after a mere "make install-data" or a mere
 # "make install-exec" failed spuriously.
+#
+# FIXME: this test only deal with DATA and script primaries; maybe we
+# need sister tests for other primaries too?  E.g., PROGRAMS, LISP,
+# PYTHON, etc...
 
 . ./defs || Exit 1

Subject: make uninstall fails after make install-data in empty prefix.
From: Nick Bowler <[email-masked]>
To: [email-masked]
Date: Thu, 22 Sep 2011 14:42:59 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

I noticed a problem testing the uninstall target of my
automake-generated Makefiles.  If the install prefix does not exist
before installation, automake will create the necessary directories.
But if you run a plain "make install-data" (without make install-exec),
the directories for executables are (unsurprisingly) not created.  The
problem is that "make uninstall" fails in this case:

  % ./configure --prefix=/tmp/does_not_exist
  % make install-data
  % make uninstall
   ( cd '/tmp/does_not_exist/bin' && rm -f foo )
  /bin/sh: line 6: cd: /tmp/does_not_exist/bin: No such file or directory
  make: *** [uninstall-binPROGRAMS] Error 1

and the installed data files are not deleted.  For reference, here's the
generated uninstall-binPROGRAMS target:

  uninstall-binPROGRAMS:
  	@$(NORMAL_UNINSTALL)
  	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
  	files=`for p in $$list; do echo "$$p"; done | \
  	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
  	      -e 's/$$/$(EXEEXT)/' `; \
  	test -n "$$list" || exit 0; \
  	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
  	cd "$(DESTDIR)$(bindir)" && rm -f $$files

Manually adding a - before the second command corrects the issue and the
data is successfully uninstalled.

A similar problem occurs with "make install-exec" followed by "make
uninstall", although this is somewhat less severe because GNU make will
successfully uninstall the executables before failing when it gets to
the data.  I'm using autoconf-2.68 and automake-1.11.1; the problem also
occurs with latest git automake at the time of writing.  The above was
reproduced with the following:

% cat >Makefile.am <<'EOF'
bin_PROGRAMS = foo
data_DATA = bar
EOF

% cat >configure.ac <<'EOF'
AC_INIT([test], [1.0])

AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
EOF

% cat >foo.c <<'EOF'
int main(void) { return 0; }
EOF

% cat >bar <<'EOF'
baz
EOF

Cheers,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)