diff --git a/main/abuild/0001-abuild-parse-ORIGIN-in-rpaths-correctly.patch b/main/abuild/0001-abuild-parse-ORIGIN-in-rpaths-correctly.patch new file mode 100644 index 00000000000..e68a96776fa --- /dev/null +++ b/main/abuild/0001-abuild-parse-ORIGIN-in-rpaths-correctly.patch @@ -0,0 +1,112 @@ +From ed79001072ac39da6dd24fe934a7cc51a27fd599 Mon Sep 17 00:00:00 2001 +From: Sertonix +Date: Thu, 24 Oct 2024 20:00:29 +0200 +Subject: [PATCH] abuild: parse $ORIGIN in rpaths correctly + +--- + abuild.in | 18 ++++++++++++++---- + tests/abuild_test | 47 +++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 61 insertions(+), 4 deletions(-) + +diff --git a/abuild.in b/abuild.in +index b834e73..1202a95 100644 +--- a/abuild.in ++++ b/abuild.in +@@ -1244,15 +1244,25 @@ prepare_metafiles() { + } + + prepare_trace_rpaths() { +- local dir=${subpkgdir:-$pkgdir} + local etype= soname= file= sover= + [ "${subpkgarch:-$pkgarch}" = "noarch" ] && return 0 + options_has "!tracedeps" && return 0 + # lets tell all the places we should look for .so files - all rpaths +- scanelf --quiet --recursive --rpath "$dir" \ +- | sed -e 's/[[:space:]].*//' -e 's/:/\n/' | sort -u \ +- >"$controldir"/.rpaths ++ ( ++ cd "${subpkgdir:-$pkgdir}" ++ scanelf --quiet --recursive --rpath . ++ ) | awk -F '[:[:space:]]+' '{ ++ sub(/^\./, "", $NF); ++ sub("/[^/]*$", "", $NF); ++ for (i = 1; i < NF; i++) { ++ # $ORIGIN means relative to the binary ++ gsub("\\$ORIGIN", $NF, $i); ++ gsub("\\${ORIGIN}", $NF, $i); ++ printf("%s\n", $i); ++ } ++ }' | sort -u >"$controldir"/.rpaths + if grep -q -x '/usr/lib' "$controldir"/.rpaths; then ++ # FIXME silence warning when $ORIGIN was used + warning "Redundant /usr/lib in rpath found" + fi + if grep '^/home/' "$controldir"/.rpaths; then +diff --git a/tests/abuild_test b/tests/abuild_test +index e87c65a..6c315b3 100755 +--- a/tests/abuild_test ++++ b/tests/abuild_test +@@ -18,6 +18,7 @@ init_tests \ + abuild_py_providers_creation \ + abuild_py_dependency_scan \ + abuild_py_dependency_scan_conflict \ ++ abuild_rpaths \ + abuild_reject_init_with_improper_shebang \ + abuild_valid_pkgnames \ + abuild_invalid_pkgnames \ +@@ -394,6 +395,52 @@ abuild_py_dependency_scan_conflict_body() { + abuild rootpkg + } + ++abuild_rpaths_body() { ++ init_keys ++ ++ mkdir -p bin ++ cat > bin/scanelf <<-EOF ++ #!/bin/sh ++ for i; do ++ [ "\$i" = --rpath ] || continue ++ echo "\$ABUILD_RPATH" /usr/lib/pkg/base.so ++ break ++ done ++ EOF ++ chmod +x bin/scanelf ++ PATH="$PWD/bin:$PATH" ++ ++ mkdir -p testrepo/pkg ++ cd testrepo/pkg ++ cat > APKBUILD <<-EOF ++ maintainer="Natanael Copa " ++ pkgname="pkg" ++ pkgver=1.0 ++ pkgrel=0 ++ pkgdesc="Dummy test package" ++ url="https://gitlab.alpinelinux.org/alpine/aports" ++ arch="all" ++ license="MIT" ++ options="!check !strip !textrels !archcheck" ++ ++ package() { ++ mkdir -p "\$pkgdir"/usr/lib ++ touch "\$pkgdir"/usr/lib/libfoo.so.1 ++ } ++ EOF ++ ABUILD_RPATH='/usr/lib/foo' abuild rootpkg || atf_fail "abuild failed" ++ atf_check -s exit:0 \ ++ -o match:"/usr/lib/foo" \ ++ cat pkg/.control.pkg/.rpaths ++ ABUILD_RPATH='$ORIGIN/bar:${ORIGIN}/../baf' pkgbasedir=$PWD/pkg abuild rootpkg || atf_fail "abuild failed" ++ atf_check -s exit:0 \ ++ -o match:"/usr/lib/pkg/bar" \ ++ -o match:"/usr/lib/pkg/../baf" \ ++ cat pkg/.control.pkg/.rpaths ++ ABUILD_RPATH='/home/builder' atf_check -s exit:1 -o ignore \ ++ -e match:"ERROR:.*: Has /home/... in rpath" abuild rootpkg ++} ++ + abuild_reject_init_with_improper_shebang_body() { + mkdir invalid-initd + cd invalid-initd +-- +2.47.0 + diff --git a/main/abuild/APKBUILD b/main/abuild/APKBUILD index 671d7d70610..e32fb7076b7 100644 --- a/main/abuild/APKBUILD +++ b/main/abuild/APKBUILD @@ -2,7 +2,7 @@ pkgname=abuild pkgver=3.14.1 _ver=${pkgver%_git*} -pkgrel=5 +pkgrel=6 pkgdesc="Script to build Alpine Packages" url="https://gitlab.alpinelinux.org/alpine/abuild/" arch="all" @@ -35,6 +35,7 @@ subpackages=" options="suid" pkggroups="abuild" source="https://gitlab.alpinelinux.org/alpine/abuild/-/archive/$pkgver/abuild-$pkgver.tar.gz + 0001-abuild-parse-ORIGIN-in-rpaths-correctly.patch tar-arguments.patch 0001-abuild-add-option-C-DIR-to-allow-change-directory.patch usr-share-cmake.patch @@ -123,6 +124,7 @@ _sudo() { sha512sums=" 49e243114933f3013884f0014fc8e5f142ff146de3d9ddb62e5ad98689cb1bf2bc8172da0331943f44b106dca4fd6fcdd917f5439e82facbb97eccc0f3459f37 abuild-3.14.1.tar.gz +9db4fa9986ffda62257298d4eefa82bc49a3c88195928729adebfefa22090dbbee60c8c1f4105e762bad55bd67fe3ceda1b8ec6385a1a83ce0741a3acf88c9a2 0001-abuild-parse-ORIGIN-in-rpaths-correctly.patch 824e936eed3699e8b18ad0c9a2462ea2ec0995111edbb595188b29a2e728b7ec9a4c445fba706d36c9954a6d349bb92b4eff0f20715758051f14065208a9778f tar-arguments.patch 4b43ed25d97593996b4154ef6f2e4253ddfb1b8cc85fba18c5dd15e01c9ee8fbb8b3db80203455a1120f779615d834e79c600d40e26ee97f64ff56fe28c44d46 0001-abuild-add-option-C-DIR-to-allow-change-directory.patch 8e5a384c181100df1656c4db2ec429c3861ee6e3a9e0e12951f4e04160e8358ea4332bdfeb5c70f57f578b684e489fdeccbbff067f799430ec422fdc594c0f97 usr-share-cmake.patch