mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2025-03-07 04:37:28 +00:00
abuild: parse $ORIGIN in rpaths correctly
This commit is contained in:
parent
b274749838
commit
5ad0236004
18
abuild.in
18
abuild.in
@ -1244,15 +1244,25 @@ prepare_metafiles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prepare_trace_rpaths() {
|
prepare_trace_rpaths() {
|
||||||
local dir=${subpkgdir:-$pkgdir}
|
|
||||||
local etype= soname= file= sover=
|
local etype= soname= file= sover=
|
||||||
[ "${subpkgarch:-$pkgarch}" = "noarch" ] && return 0
|
[ "${subpkgarch:-$pkgarch}" = "noarch" ] && return 0
|
||||||
options_has "!tracedeps" && return 0
|
options_has "!tracedeps" && return 0
|
||||||
# lets tell all the places we should look for .so files - all rpaths
|
# 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 \
|
cd "${subpkgdir:-$pkgdir}"
|
||||||
>"$controldir"/.rpaths
|
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
|
if grep -q -x '/usr/lib' "$controldir"/.rpaths; then
|
||||||
|
# FIXME silence warning when $ORIGIN was used
|
||||||
warning "Redundant /usr/lib in rpath found"
|
warning "Redundant /usr/lib in rpath found"
|
||||||
fi
|
fi
|
||||||
if grep '^/home/' "$controldir"/.rpaths; then
|
if grep '^/home/' "$controldir"/.rpaths; then
|
||||||
|
@ -18,6 +18,7 @@ init_tests \
|
|||||||
abuild_py_providers_creation \
|
abuild_py_providers_creation \
|
||||||
abuild_py_dependency_scan \
|
abuild_py_dependency_scan \
|
||||||
abuild_py_dependency_scan_conflict \
|
abuild_py_dependency_scan_conflict \
|
||||||
|
abuild_rpaths \
|
||||||
abuild_reject_init_with_improper_shebang \
|
abuild_reject_init_with_improper_shebang \
|
||||||
abuild_valid_pkgnames \
|
abuild_valid_pkgnames \
|
||||||
abuild_invalid_pkgnames \
|
abuild_invalid_pkgnames \
|
||||||
@ -394,6 +395,52 @@ abuild_py_dependency_scan_conflict_body() {
|
|||||||
abuild rootpkg
|
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 <ncopa@alpinelinux.org>"
|
||||||
|
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() {
|
abuild_reject_init_with_improper_shebang_body() {
|
||||||
mkdir invalid-initd
|
mkdir invalid-initd
|
||||||
cd invalid-initd
|
cd invalid-initd
|
||||||
|
Loading…
Reference in New Issue
Block a user