diff options
author | Tuomas Tynkkynen <tuomas@tuxera.com> | 2016-06-03 21:25:02 (GMT) |
---|---|---|
committer | Tuomas Tynkkynen <tuomas@tuxera.com> | 2016-06-03 21:25:02 (GMT) |
commit | 48143414941d91016efca2b0ef6f32475d6eaa75 (patch) | |
tree | b1348f8591c5f723404811adfdceba8df12c3616 /tests/shrink-rpath-with-allowed-prefixes.sh | |
parent | 2e3fdc2030c75c19df6fc2924083cfad53856562 (diff) | |
download | patchelf-48143414941d91016efca2b0ef6f32475d6eaa75.zip patchelf-48143414941d91016efca2b0ef6f32475d6eaa75.tar.gz patchelf-48143414941d91016efca2b0ef6f32475d6eaa75.tar.bz2 |
Add '--allowed-rpath-prefixes' option to '--shrink-rpath'
Fixes #97. In essence, the problem is that some packages in Nixpkgs have
RPATHs pointing to both $NIX_BUILD_TOP and $out, e.g.:
/tmp/nix-build-openldap-2.4.44.drv-0/openldap-2.4.44/libraries/libldap_r/.libs
/tmp/nix-build-openldap-2.4.44.drv-0/openldap-2.4.44/libraries/liblber/.libs
/nix/store/bfkmdxmv3a3f0g3d2q8jkdz2wam93c5z-openldap-2.4.44/lib
/nix/store/bfkmdxmv3a3f0g3d2q8jkdz2wam93c5z-openldap-2.4.44/lib64
Currently, running `patchelf --shrink-rpath` does the wrong thing by
keeping the /tmp/ paths and deleting the /nix/store ones. Now we can fix
the problem by using
patchelf --shrink-rpath --allowed-rpath-prefixes $NIX_STORE_DIR
in the Nixpkgs fixupPhase instead.
Diffstat (limited to 'tests/shrink-rpath-with-allowed-prefixes.sh')
-rwxr-xr-x | tests/shrink-rpath-with-allowed-prefixes.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/shrink-rpath-with-allowed-prefixes.sh b/tests/shrink-rpath-with-allowed-prefixes.sh new file mode 100755 index 0000000..db24da2 --- /dev/null +++ b/tests/shrink-rpath-with-allowed-prefixes.sh @@ -0,0 +1,47 @@ +#! /bin/sh -e +SCRATCH=scratch/$(basename $0 .sh) + +rm -rf ${SCRATCH} +mkdir -p ${SCRATCH} +mkdir -p ${SCRATCH}/libsA +mkdir -p ${SCRATCH}/libsB + +cp main ${SCRATCH}/ +cp libfoo.so libbar.so ${SCRATCH}/libsA/ +cp libfoo.so libbar.so ${SCRATCH}/libsB/ + +oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/main) +if test -z "$oldRPath"; then oldRPath="/oops"; fi +pathA="$(pwd)/${SCRATCH}/libsA" +pathB="$(pwd)/${SCRATCH}/libsB" +../src/patchelf --force-rpath --set-rpath $oldRPath:$pathA:$pathB ${SCRATCH}/main + +cp ${SCRATCH}/main ${SCRATCH}/mainA +cp ${SCRATCH}/main ${SCRATCH}/mainB + +../src/patchelf --shrink-rpath ${SCRATCH}/main +../src/patchelf --shrink-rpath --allowed-rpath-prefixes $oldRPath:$pathA ${SCRATCH}/mainA +../src/patchelf --shrink-rpath --allowed-rpath-prefixes $oldRPath:$pathB ${SCRATCH}/mainB + +check() { + exe=$1 + mustContain=$2 + mustNotContain=$3 + + rpath=$(../src/patchelf --print-rpath $exe) + echo "RPATH of $exe after: $rpath" + + if ! echo "$rpath" | grep -q $mustContain; then + echo "RPATH didn't contain '$mustContain' when it should have" + exit 1 + fi + + if echo "$rpath" | grep -q $mustNotContain; then + echo "RPATH contained '$mustNotContain' when it shouldn't have" + exit 1 + fi +} + +check ${SCRATCH}/main $pathA $pathB +check ${SCRATCH}/mainA $pathA $pathB +check ${SCRATCH}/mainB $pathB $pathA |