]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
build-sys: Order pylibmount after usrlib on install
authorFilipe Brandenburger <filbranden@google.com>
Thu, 31 Dec 2015 06:36:15 +0000 (22:36 -0800)
committerFilipe Brandenburger <filbranden@google.com>
Tue, 26 Jan 2016 21:24:25 +0000 (13:24 -0800)
This fixes a failure of `make install DESTDIR=...` when trying to relink
pylibmount against libmount.la.

libtool will look for libmount.so under ${DESTDIR}/${libdir}, but if it
is not yet present, it will assume it is a system installed library and
use -lmount instead.

This makes the install order significant.

Automake lists the install entries in alphabetical order, and as
install-pylibmountexecLTLIBRARIES < install-usrlib_execLTLIBRARIES,
make will try to install pylibmount.so before libmount.so is present
in the DESTDIR, which will then cause libtool to fallback to -lmount
when relinking. This causes the error below:

  libtool: install: warning: relinking `pylibmount.la'
  libtool: install: (... libtool --mode=relink gcc -o pylibmount.la \
        -rpath /usr/lib/python2.7/dist-packages/libmount \
        libmount/python/*.lo libmount.la ... -lpython2.7 \
        -inst-prefix-dir /path/to/destdir)
  /usr/bin/ld: cannot find -lmount
  collect2: error: ld returned 1 exit status
  libtool: install: error: relink `pylibmount.la' ...
  make[3]: *** [install-pylibmountexecLTLIBRARIES] Error 1

Work around this issue by using a zz_ prefix for the pylibmount exec
dir, in order to install it last.

This does not work if parallel make is used for the install step, but
that should be a minor issue (parallel install is probably not that
useful for util-linux, which is not that large a package to actually
benefit from it.) The proper fix should be to introduce a make
dependency of target install-pylibmountexecLTLIBRARIES on target
install-usrlib_execLTLIBRARIES, but unfortunately there is no good way
to accomplish that in automake without overriding it completely.

This issue seems to be previously encountered in automake context, since
automake includes a hack to insert such a dependency rule to install all
libLTLIBRARIES before attempting to install binPROGRAMS, initially
introduced in the commit below:
http://git.savannah.gnu.org/cgit/automake.git/commit/?id=bd4a1d5ad1a72fa780a8b7fd6c365a5dad2e6220

Also, a related bug from Ubuntu tracker:
https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/1442076

Tested that `make install` starts working again after this commit, even
when libmount-dev is not installed on the system. Also confirmed that
`make distcheck` is now functional.

Confirmed that both __init__.py and the .so library are still installed
in the Python directory.

Tested that it still works without python-devel installed, also
inspected Makefile.in which looks correct.

Tested that `make install pylibmountexecdir=...` still works to override
destination directory at `make install` time.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
libmount/python/Makemodule.am

index 367d324729f4d0ca6c82d7a18ca7829fe852f954..89f756f6c971341b6e377d2bc3c50bb5bf233b78 100644 (file)
@@ -2,11 +2,21 @@ if BUILD_PYLIBMOUNT
 
 pylibmountexecdir = $(pyexecdir)/libmount
 
+# Use a zz_ prefix to ensure this is last on `make install` (automake orders
+# the entries in alphabetical order) since we need to ensure that the
+# install-zz_pylibmountexecLTLIBRARIES step is only executed after the
+# install-usrlib_execLTLIBRARIES step, otherwise libtool fails to find
+# libmount under DESTDIR when it tries to relink pylibmount.so.
+#
+# Keep the pylibmountexecdir variable, in order to be backwards compatible with
+# invocation of `make install` that override that variable in the command line.
+zz_pylibmountexecdir = $(pylibmountexecdir)
+
 # Please, don't use $pythondir for the scripts. We have to use the same
 # directory for binary stuff as well as for the scripts otherwise it's
 # not possible to install 32-bit and 64-bit version on the same system.
-pylibmountexec_LTLIBRARIES = pylibmount.la
-pylibmountexec_PYTHON = libmount/python/__init__.py
+zz_pylibmountexec_LTLIBRARIES = pylibmount.la
+zz_pylibmountexec_PYTHON = libmount/python/__init__.py
 
 pylibmount_la_SOURCES = \
        libmount/python/pylibmount.c \