From 4180ba3570c746291d9db119998bd5a0b1d91832 Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Wed, 18 Dec 2019 10:25:26 -0600 Subject: [PATCH] snapcraft.yaml: unset LD_FLAGS and LD_LIBRARY_PATH to allow iterative builds Leaving these set leads to the debian build system including files from $SNAPCRAFT_STAGE in the build and using those libraries, etc. which it should not be doing. Without this, after building successfully once, re-building the snap without cleaning would fail like this: dpkg-shlibdeps: error: no dependency information found for /root/stage/lib/x86_64-linux-gnu/libc.so.6 (used by debian/snapd/usr/lib/snapd/snap-seccomp) Hint: check if the library actually comes from a package. dh_shlibdeps: dpkg-shlibdeps -Tdebian/snapd.substvars debian/snapd/usr/bin/snapfuse debian/snapd/usr/bin/snap debian/snapd/usr/lib/snapd/snap-confine debian/snapd/usr/lib/snapd/snap-seccomp debian/snapd/usr/lib/snapd/snap-bootstrap debian/snapd/usr/lib/snapd/snap-gdb-shim debian/snapd/usr/lib/snapd/snap-repair debian/snapd/usr/lib/snapd/snapd debian/snapd/usr/lib/snapd/snap-failure debian/snapd/usr/lib/snapd/snap-discard-ns debian/snapd/usr/lib/systemd/system-environment-generators/snapd-env-generator debian/snapd/lib/systemd/system-generators/snapd-generator returned exit code 2 debian/rules:102: recipe for target 'binary' failed make: *** [binary] Error 2 dpkg-buildpackage: error: debian/rules binary gave error exit status 2 Failed to run 'override-build': Exit code was 2. because libc.so.6 was included in the linker search path during compiling when it should just be using the one from the build environment instead. Signed-off-by: Ian Johnson --- build-aux/snap/snapcraft.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build-aux/snap/snapcraft.yaml b/build-aux/snap/snapcraft.yaml index 044d98bb75fd..dfde0863547e 100644 --- a/build-aux/snap/snapcraft.yaml +++ b/build-aux/snap/snapcraft.yaml @@ -41,6 +41,13 @@ parts: # set version after installing dependencies so we have all the tools here snapcraftctl set-version $(./mkversion.sh --output-only) override-build: | + # unset the LD_FLAGS and LD_LIBRARY_PATH vars that snapcraft sets for us + # as those will point to the $SNAPCRAFT_STAGE which on re-builds will + # contain things like libc and friends that confuse the debian package + # build system + # TODO: should we unset $PATH to not include $SNAPCRAFT_STAGE too? + unset LD_FLAGS + unset LD_LIBRARY_PATH # if we are root, disable tests if [ "$(id -u)" = "0" ]; then DEB_BUILD_OPTIONS=nocheck