Skip to content

Commit

Permalink
chore(spread): patchelf core24 cleanup
Browse files Browse the repository at this point in the history
- Use --destructive-mode in the CLI
- Remove dangling set-base logic
- Remove unbound references to base

These tests still fail, but now they fail due to the lack of the classic
feature.

Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
  • Loading branch information
sergiusens committed Mar 6, 2024
1 parent 4fa25a4 commit e39b10d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ parts:
- libcurl4-openssl-dev
- patchelf
override-build: |
snapcraftctl build
craftctl default
mv $CRAFT_PART_INSTALL/bin/hello-classic $CRAFT_PART_INSTALL/bin/hello-classic-existing-rpath
patchelf --force-rpath --set-rpath "\$ORIGIN/../fake-lib" $CRAFT_PART_INSTALL/bin/hello-classic-existing-rpath
hello-no-patchelf:
Expand All @@ -39,5 +39,5 @@ parts:
- gcc
- libcurl4-openssl-dev
override-build: |
snapcraftctl build
craftctl default
mv $CRAFT_PART_INSTALL/bin/hello-classic $CRAFT_PART_INSTALL/bin/hello-classic-no-patchelf
20 changes: 6 additions & 14 deletions tests/spread/core24-suites/patchelf/classic-patchelf/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,24 @@ prepare: |
apt-mark auto patchelf dpkg-dev
restore: |
snapcraft clean
snapcraft clean --destructive-mode
rm -f ./*.snap
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
. "$TOOLS_DIR/snapcraft-yaml.sh"
restore_yaml "snap/snapcraft.yaml"
execute: |
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
. "$TOOLS_DIR/snapcraft-yaml.sh"
base="$(get_base)"
snapcraft prime
snapcraft prime --destructive-mode
arch_triplet="$(dpkg-architecture -q DEB_HOST_MULTIARCH)"
# Account for /usr merge.
RPATH_MATCH="^/snap/$base/current/lib/$arch_triplet"
RPATH_ORIGIN_MATCH="^\\\$ORIGIN/../fake-lib:/snap/$base/current/lib/$arch_triplet"
RPATH_MATCH="^/snap/core24/current/lib/$arch_triplet"
RPATH_ORIGIN_MATCH="^\\\$ORIGIN/../fake-lib:/snap/core24/current/lib/$arch_triplet"
# Verify typical binary.
patchelf --print-interpreter prime/bin/hello-classic | MATCH "^/snap/$base/current/lib.*ld.*.so.*"
patchelf --print-interpreter prime/bin/hello-classic | MATCH "^/snap/core24/current/lib.*ld.*.so.*"
patchelf --print-rpath prime/bin/hello-classic | MATCH "${RPATH_MATCH}"
# Verify binary w/ existing rpath.
patchelf --print-interpreter prime/bin/hello-classic-existing-rpath | MATCH "^/snap/$base/current/lib.*ld.*.so.*"
patchelf --print-interpreter prime/bin/hello-classic-existing-rpath | MATCH "^/snap/core24/current/lib.*ld.*.so.*"
patchelf --print-rpath prime/bin/hello-classic-existing-rpath | MATCH "${RPATH_ORIGIN_MATCH}"
# Verify untouched no-patchelf.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ parts:
build-attributes:
- enable-patchelf
override-build: |
snapcraftctl build
craftctl default
mv $CRAFT_PART_INSTALL/bin/hello-strict $CRAFT_PART_INSTALL/bin/hello-strict-existing-rpath
patchelf --force-rpath --set-rpath "\$ORIGIN/../fake-lib" $CRAFT_PART_INSTALL/bin/hello-strict-existing-rpath
hello-enable-patchelf:
Expand All @@ -38,5 +38,5 @@ parts:
build-attributes:
- enable-patchelf
override-build: |
snapcraftctl build
craftctl default
mv $CRAFT_PART_INSTALL/bin/hello-strict $CRAFT_PART_INSTALL/bin/hello-strict-enable-patchelf
12 changes: 6 additions & 6 deletions tests/spread/core24-suites/patchelf/strict-patchelf/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ prepare: |
apt-mark auto patchelf dpkg-dev
restore: |
snapcraft clean
snapcraft clean --destructive-mode
rm -f ./*.snap
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
. "$TOOLS_DIR/snapcraft-yaml.sh"
restore_yaml "snap/snapcraft.yaml"
execute: |
snapcraft prime
snapcraft prime --destructive-mode
arch_triplet="$(dpkg-architecture -q DEB_HOST_MULTIARCH)"
Expand All @@ -26,14 +26,14 @@ execute: |
fi
# Account for /usr merge.
RPATH_MATCH="^/snap/$base/current/lib/$arch_triplet"
RPATH_ORIGIN_MATCH="^\\\$ORIGIN/../fake-lib:/snap/$base/current/lib/$arch_triplet"
RPATH_MATCH="^/snap/core24/current/lib/$arch_triplet"
RPATH_ORIGIN_MATCH="^\\\$ORIGIN/../fake-lib:/snap/core24/current/lib/$arch_triplet"
# Verify binary rpath patching with existing rpath
patchelf --print-interpreter prime/bin/hello-strict-existing-rpath | MATCH "^/snap/$base/current/lib.*ld.*.so.*"
patchelf --print-interpreter prime/bin/hello-strict-existing-rpath | MATCH "^/snap/core24/current/lib.*ld.*.so.*"
patchelf --print-rpath prime/bin/hello-strict-existing-rpath | MATCH "${RPATH_ORIGIN_MATCH}"
# Verify binary rpath patching without existing rpath
patchelf --print-interpreter prime/bin/hello-strict-enable-patchelf | MATCH "^/snap/$base/current/lib.*ld.*.so.*"
patchelf --print-interpreter prime/bin/hello-strict-enable-patchelf | MATCH "^/snap/core24/current/lib.*ld.*.so.*"
patchelf --print-rpath prime/bin/hello-strict-enable-patchelf | MATCH "${RPATH_MATCH}"

0 comments on commit e39b10d

Please sign in to comment.