Package: libcap-dev
Version: 2.25-1
Severity: important
Tags: patch
Usertags: rebootstrap

libcap.pc has a bad assignment for libdir. On most architectures it
turns out to be /lib. On amd64, mips64el and sparc64 it becomes /lib64
and on x32 it becomes /libx32. Yet the .so symlink for linking it
resides in /usr/lib/$(DEB_HOST_MULTIARCH). The issue becomes worse once
one notices that the libdir is dependent on the build architecture (due
to the ldd check in Make.Rules). Thus cross building libcap2 for mipsel
on amd64 results in a libdir=/lib64 and that makes systemd FTCBFS. So
essentially, libdir is always wrong. It is even more wrong when cross
compiling and for mipsel, stuff breaks loudly.

The cause is twofold. For one thing the build (make) and install (make
install) use different assignments for lib. And then debian/rules moves
the .so symlink from /lib/$(DEB_HOST_MULTIARCH) to
/usr/lib/$(DEB_HOST_MULTIARCH). If one were copying the lib= assignment
to the build, libdir would end up being just /lib/$(DEB_HOST_MULTIARCH),
which would still be wrong but harmless.

So the attached patch goes the simple route of fixing up libcap.pc after
installation. Please consider applying it.

diff --minimal -Nru libcap2-2.25/debian/rules libcap2-2.25/debian/rules
--- libcap2-2.25/debian/rules   2016-04-30 14:30:26.000000000 +0200
+++ libcap2-2.25/debian/rules   2017-07-24 17:49:34.000000000 +0200
@@ -46,6 +46,8 @@
        cd debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) && \
                mv    ../../../lib/$(DEB_HOST_MULTIARCH)/*.a . && \
                ln -s ../../../lib/$(DEB_HOST_MULTIARCH)/*.*
+       sed -i -e 's#^libdir=.*#libdir=/usr/lib/$(DEB_HOST_MULTIARCH)#' \
+               debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/libcap.pc
        # Remove unwanted/unused files (because of --fail-missing)
        rm -f debian/tmp/lib/$(DEB_HOST_MULTIARCH)/*.so

Reply via email to