From 81f009d7e40a3efbede295bd5c272e8b786582f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 21 Apr 2025 20:16:42 +0200 Subject: [PATCH 01/10] conditioning: Use core-provided libraries instead of dangling symlinks libraries .so files provided by -dev packages normally point to the versioned so file, but if these files are provided by the core snap or another base snap then we should instead use them, if they're not provided by the SDK itself. So, ensure that all the symlinks in the lib directory are actually pointing to a library file, trying to resolve them with the core-provided libraries as first try. --- snapcraft.yaml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 1328ef42..a2e59d3e 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1637,10 +1637,27 @@ parts: ln -s gettext-0.19.8 usr/share/gettext-current ln -s gdk-pixbuf-2.0/2.10.0 usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/gdk-pixbuf-current - # Fix dangling symlink by overwriting it - ln -sf lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libc_malloc_debug.so.0 usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libc_malloc_debug.so - # CHECK THIS When changing the core base, this line must be update - cp /snap/$CRAFT_EXT_CORE_LEVEL/current/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libc_malloc_debug.so.0 lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/ + # Check dangling libraries symlinks + invalid_links=() + core_root_prefix=/snap/$CRAFT_EXT_CORE_LEVEL/current + for i in $(find "$CRAFT_PRIME"/{usr/,}lib -xtype l -name '*.so'); do + # Try fix dangling symlink by overwriting it with core library if any. + rel_lib_path=$(realpath --relative-to="$CRAFT_PRIME" "$i") + core_lib=$core_root_prefix/$(dirname "$rel_lib_path")/$(readlink "$i") + + if realpath --canonicalize-existing "$core_lib"; then + ln -svf "${core_lib#"$core_root_prefix"}" "$i" + continue + fi + + echo "$i: dangling symlink!" + invalid_links+=($i) + done + if [ ${#invalid_links[@]} -gt 0 ]; then + echo "Invalid symlinks found:" + echo "${invalid_links[@]}" + exit 1; + fi # Necessary for armhf builds, triggers review warning if [ "$CRAFT_ARCH_TRIPLET_BUILD_FOR" = "arm-linux-gnueabihf" ]; then From cc890bfeba465a1d1d8c331cbde26293e2668210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 16 May 2025 14:15:04 +0200 Subject: [PATCH 02/10] snapcraft: Do not remove *.so files outside the find target While this is fine for all the *.so.* files, we should not remove the *.so files by mistake, since these are dev-only files --- snapcraft.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index a2e59d3e..4644ce49 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1552,15 +1552,18 @@ parts: override-build: | set -eux craftctl default + + # Drop all the duplicates *.so.* library files that have been pulled from + # deb files and that we're already shipping as part of source-compiled parts cd $CRAFT_STAGE/usr - find . -type f,l -exec rm -f $CRAFT_PART_INSTALL/usr/{} \; - find . -type f,l -name "*.so*" -exec bash -c "rm -f $CRAFT_PART_INSTALL/usr/{}*" \; + find . -type f,l -exec rm -fv $CRAFT_PART_INSTALL/usr/{} \; + find . -type f,l -name "*.so.*" -exec sh -c "rm -fv $CRAFT_PART_INSTALL/usr/{}*" \; cd $CRAFT_STAGE/usr/lib - find . -type f,l -exec rm -f $CRAFT_PART_INSTALL/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/{} \; - find . -type f,l -name "*.so*" -exec bash -c "rm -f $CRAFT_PART_INSTALL/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/{}*" \; + find . -type f,l -exec rm -fv $CRAFT_PART_INSTALL/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/{} \; + find . -type f,l -name "*.so.*" -exec sh -c "rm -fv $CRAFT_PART_INSTALL/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/{}*" \; cd $CRAFT_STAGE/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR - find . -type f,l -exec rm -f $CRAFT_PART_INSTALL/usr/lib/{} \; - find . -type f,l -name "*.so*" -exec bash -c "rm -f $CRAFT_PART_INSTALL/usr/lib/{}*" \; + find . -type f,l -exec rm -fv $CRAFT_PART_INSTALL/usr/lib/{} \; + find . -type f,l -name "*.so.*" -exec sh -c "rm -fv $CRAFT_PART_INSTALL/usr/lib/{}*" \; # FIXME, need to figure out why libayatana-appindicator install those rm -f $CRAFT_PART_INSTALL/usr/lib/*/libatk-1.0.so* rm -f $CRAFT_PART_INSTALL/usr/lib/*/libatk-bridge-2.0.so* From 69c0d259ada0603e493d9ecc2e538d1fc3d51f73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 19 May 2025 04:03:48 +0200 Subject: [PATCH 03/10] Revert "Do not stage libc and libm in Libtool part." This reverts commit 385bffb48a4093500bc8bfabdaac7f8d70f53632 since it's not the right fix: .so files should be included if they are dependencies of dev libraries we stage, but we should instead also stage their dependencies instead --- snapcraft.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 4644ce49..88cf4199 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -89,8 +89,6 @@ parts: override-stage: | set -eux craftctl default - rm $CRAFT_STAGE/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/lib[mc].a || : - rm $CRAFT_STAGE/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/lib[mc].so || : LIBTOOLIZE=usr/bin/libtoolize sed -i 's#pkgauxdir="#pkgauxdir="$CRAFT_STAGE#' $LIBTOOLIZE sed -i 's#pkgltdldir="#pkgltdldir="$CRAFT_STAGE#' $LIBTOOLIZE From d5e74c41d4cacf7749647c0f8fa5d94cb888aae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 8 Aug 2025 19:13:38 +0200 Subject: [PATCH 04/10] Revert "Purge lib[mc].{a,so} for good." This reverts commit df438973963f53879a2eb1b61051387fc8626b4f. --- snapcraft.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 88cf4199..c224916f 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1702,11 +1702,6 @@ parts: rm -rf usr/share/locale-langpack/kab rm -f usr/share/unity/client-scopes.json - # Libm is a dangling symlink in armhf and riscv64, breaking builds. - # We don't need them anyway, the base image has them. - rm -f usr/lib/*/lib[mc].so || : - rm -f usr/lib/*/lib[mc].a || : - find . -type d -empty -delete PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin From 73f8150c27264737139db5add07a4aec027d6588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 19 May 2025 04:09:15 +0200 Subject: [PATCH 05/10] debs: Install all the build dependencies in the SDK The GNOME SDK should contain all the required dev-dependencies of the libraries we ship, including the core files dependencies. Now, even though core includes already some of the runtime libraries it does not include their *.so counterparts, and then that's now our duty to provide them all and in a working state. Since we can't really symlink to external paths in a snap, we should provide all the libraries here, since there's no way to fix the *.so files that are used at link time. Dropping them would be wrong though, since there may be libraries in the SDK that requires them at link time only, and it's not up to final applications to manage that. --- snapcraft.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snapcraft.yaml b/snapcraft.yaml index c224916f..93ab061e 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1403,6 +1403,8 @@ parts: - libbrotli-dev - libbz2-1.0 - libbz2-dev + - libc6 + - libc6-dev - libcairo2-dev - libcanberra-gtk3-dev - libcrypt-dev @@ -1466,6 +1468,8 @@ parts: - libnsl-dev - libnss3-dev - libopenjp2-7-dev + - libpciaccess0 + - libpciaccess-dev - libpcre2-8-0 - libpcre2-dev - libpcre3 From e310331ec3b5d87a7e8adf7569c67a961f9371cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 19 May 2025 04:14:17 +0200 Subject: [PATCH 06/10] conditioning: Fail if dangling libraries *.so files are found If a dangling *.so file is found, it means that a package it links has not been staged, so fail in such case --- snapcraft.yaml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 93ab061e..4b86da84 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1646,21 +1646,13 @@ parts: invalid_links=() core_root_prefix=/snap/$CRAFT_EXT_CORE_LEVEL/current for i in $(find "$CRAFT_PRIME"/{usr/,}lib -xtype l -name '*.so'); do - # Try fix dangling symlink by overwriting it with core library if any. - rel_lib_path=$(realpath --relative-to="$CRAFT_PRIME" "$i") - core_lib=$core_root_prefix/$(dirname "$rel_lib_path")/$(readlink "$i") - - if realpath --canonicalize-existing "$core_lib"; then - ln -svf "${core_lib#"$core_root_prefix"}" "$i" - continue - fi - echo "$i: dangling symlink!" invalid_links+=($i) done if [ ${#invalid_links[@]} -gt 0 ]; then echo "Invalid symlinks found:" echo "${invalid_links[@]}" + echo "Ensure full package set is staged!" exit 1; fi From c39eb7bb5587b61b1f3252698018fd479229e941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 26 May 2025 18:44:50 +0200 Subject: [PATCH 07/10] debs: Remove custom code to drop atk and atspi libraries We already have code to remove duplicates and these libraries are already dropped as part of the previous lines --- snapcraft.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 4b86da84..cbf33f25 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1566,10 +1566,6 @@ parts: cd $CRAFT_STAGE/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR find . -type f,l -exec rm -fv $CRAFT_PART_INSTALL/usr/lib/{} \; find . -type f,l -name "*.so.*" -exec sh -c "rm -fv $CRAFT_PART_INSTALL/usr/lib/{}*" \; - # FIXME, need to figure out why libayatana-appindicator install those - rm -f $CRAFT_PART_INSTALL/usr/lib/*/libatk-1.0.so* - rm -f $CRAFT_PART_INSTALL/usr/lib/*/libatk-bridge-2.0.so* - rm -f $CRAFT_PART_INSTALL/usr/lib/*/libatspi.so* conditioning: after: [ debs ] From 75c8986f9751c0030b62ab46549287ee0b7ff3b7 Mon Sep 17 00:00:00 2001 From: Nathan Pratta Teodosio Date: Fri, 29 Aug 2025 11:24:46 +0200 Subject: [PATCH 08/10] debs: Add libgssapi-krb5-2, libffi8, libelf1t64, libk5crypto3 and libkrb5support0. They provide the targets of the -dev's symlinks. --- snapcraft.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/snapcraft.yaml b/snapcraft.yaml index cbf33f25..e375f112 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1415,10 +1415,12 @@ parts: - libdrm2 - libdrm-dev - libegl1-mesa-dev + - libelf1t64 - libevdev2 - libevdev-dev - libexpat1 - libexpat1-dev + - libffi8 - libfontconfig1-dev - libfreetype6 - libfreetype-dev @@ -1440,6 +1442,7 @@ parts: - libgraphene-1.0-dev - libgraphviz-dev - libgspell-1-dev + - libgssapi-krb5-2 - libgstreamer-plugins-bad1.0-dev - libgstreamer-plugins-base1.0-dev - libgstreamer-plugins-good1.0-dev @@ -1450,6 +1453,8 @@ parts: - libidn2-0 - libidn2-dev - libjpeg-dev + - libk5crypto3 + - libkrb5support0 - libkrb5-3 - libkrb5-dev - liblcms2-dev From e1d2f25eaaf8b5806a8b70d47e3fba9c6260bb49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 1 Sep 2025 04:37:45 +0200 Subject: [PATCH 09/10] snapcraft: Add last(?) round of runtime dependencies --- snapcraft.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snapcraft.yaml b/snapcraft.yaml index e375f112..7539b250 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1407,7 +1407,9 @@ parts: - libc6-dev - libcairo2-dev - libcanberra-gtk3-dev + - libcrypt1 - libcrypt-dev + - libcom-err2 - libcurl4-openssl-dev - libdbus-1-3 - libdbus-1-dev @@ -1506,6 +1508,7 @@ parts: - libtasn1-6-dev - libtdb-dev - libthai-dev + - libtirpc3t64 - libudev1 - libudev-dev - libunity-dev From 79959237dd5ff5403c8d8a0fdc44ee342e05e3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 1 Sep 2025 04:39:43 +0200 Subject: [PATCH 10/10] snapcraft: Clarify error message on what we mean by package set --- snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 7539b250..6fccffa4 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1656,7 +1656,7 @@ parts: if [ ${#invalid_links[@]} -gt 0 ]; then echo "Invalid symlinks found:" echo "${invalid_links[@]}" - echo "Ensure full package set is staged!" + echo "Ensure full package set (runtime and dev files) is staged!" exit 1; fi