Package: coreutils
Version: 8.26-3
Severity: normal
Tags: upstream patch

If you crossbuild coreutils (after fixing the manpages issue covered in #721358)
it fails with:

 Recursive variable 'INSTALL' references itself (eventually).$

in context:
----------------
make[4]: Leaving directory '/tmp/buildd/coreutils/coreutils-8.26/po'
Making install in .
make[4]: Entering directory '/tmp/buildd/coreutils/coreutils-8.26'
make[5]: Entering directory '/tmp/buildd/coreutils/coreutils-8.26'
Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually).$
make[5]: Leaving directory '/tmp/buildd/coreutils/coreutils-8.26'
Makefile:12005: recipe for target 'install-am' failed
make[4]: *** [install-am] Error 2
make[4]: Leaving directory '/tmp/buildd/coreutils/coreutils-8.26'
Makefile:11513: recipe for target 'install-recursive' failed
make[3]: *** [install-recursive] Error 1
make[3]: Leaving directory '/tmp/buildd/coreutils/coreutils-8.26'
Makefile:11999: recipe for target 'install' failed
make[2]: *** [install] Error 2
make[2]: Leaving directory '/tmp/buildd/coreutils/coreutils-8.26'
dh_auto_install: make -j1 install DESTDIR=/tmp/buildd/coreutils/coreutils-8.26/$
debian/rules:34: recipe for target 'override_dh_auto_install' failed
make[1]: *** [override_dh_auto_install] Error 2
make[1]: Leaving directory '/tmp/buildd/coreutils/coreutils-8.26'
debian/rules:25: recipe for target 'binary-arch' failed
make: *** [binary-arch] Error 2
dpkg-buildpackage: error: debian/rules binary-arch gave error exit status 2
------------------


Now clearly someone did something to fix this in the past:
# Use the just-built 'ginstall', when not cross-compiling.
if CROSS_COMPILING
cu_install_program = @INSTALL_PROGRAM@
else
cu_install_program = src/ginstall
endif
INSTALL = $(cu_install_program) -c

however if you resolve this @INSTALL_PROGRAM@ resolves to
$INSTALL_PROGRAM and that defaults to $INSTALL if nothing is
explicitly specified. As you can see, this results in a recursive
definition.

See 
https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Programs.html
 definition of AC_PROG_INSTALL: (which is used so far as I can tell)
 "Also set the variables INSTALL_PROGRAM and INSTALL_SCRIPT to ‘${INSTALL}’ "

I guess when the above fix was put in $INSTALL_PROGRAM was somehow set
somewhere so that it worked? This could be done in debian/rules but
this should really be fixed upstream.

It's not clear to me exactly what the right way to fix this is, but
this really stupid patch does actually work and illustrates that this is indeed 
the problem:

Index: coreutils-8.26/src/local.mk
===================================================================
--- coreutils-8.26.orig/src/local.mk
+++ coreutils-8.26/src/local.mk
@@ -645,7 +645,7 @@ check-duplicate-no-install: src/tr

 # Use the just-built 'ginstall', when not cross-compiling.
 if CROSS_COMPILING
-cu_install_program = @INSTALL_PROGRAM@
+cu_install_program = install
 else
 cu_install_program = src/ginstall
 endif

It seems likely that there is a better way :-)

I did try just setting $INSTALL_PROGRAM=install in debian/rules but
that didn't propogate the way I was hoping it would, and as I say that
isn't an upstream fix anyway.

To reproduce this issue, cross-build coreutils with:

dpkg --add-architecture arm64
apt --no-install-recommends install crossbuild-essential-arm64
apt build-dep -aarm64 coreutils
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -aarm64 -B
 

Reply via email to