Crossdirect redirects archivers (gz, bzip2, ...) to their native
versions when cross compiling. This works e.g. when extracting sources or
packing the .apks at the end of the build. But it currently fails when
such an archiver gets called during package().
For example with bootchart2:
>>> bootchart2: Entering fakeroot...
...
gzip -c bootchart2.1 > /home/pmos/build/pkg/bootchart2/usr/share/man/man1/bootchart2.1.gz
Error relocating /native/usr/lib/libfakeroot.so: unsupported relocation type 6
Error relocating /native/usr/lib/libfakeroot.so: unsupported relocation type 6
Error relocating /native/usr/lib/libfakeroot.so: unsupported relocation type 1
Error relocating /native/usr/lib/libfakeroot.so: unsupported relocation type 6
Fix this by running the foreign arch version when it gets called in a
fakeroot.
Fixes: 8a7c9ce7 ("cross/crossdirect: run archivers natively too")
Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/7120>
27 lines
1 KiB
Bash
27 lines
1 KiB
Bash
#!/bin/sh -e
|
|
# Execute the binary from the native chroot if it is installed there. This is
|
|
# done for archiver tools such as unxz, so they don't need to go through QEMU.
|
|
BASENAME="$(basename "$0")"
|
|
|
|
if [ -n "$LD_PRELOAD" ]; then
|
|
# The archiver tool gets called during package(), which abuild runs
|
|
# with libfakeroot.so. Some packages do this, like bootchart2, which
|
|
# compresses man pages in its "make install". We can't run the native
|
|
# binary here due to the LD_PRELOAD, so run the foreign arch one.
|
|
export PATH="/usr/bin:/usr/sbin:/sbin:/bin"
|
|
exec "$BASENAME" "$@"
|
|
fi
|
|
|
|
# Try /native first, then the foreign arch paths. Never try
|
|
# /native/usr/lib/crossdirect as this would result in a loop.
|
|
UNWRAPPED_PATH="/native/usr/bin:/native/usr/sbin:/native/sbin:/native/bin:/usr/bin:/usr/sbin:/sbin:/bin"
|
|
UNWRAPPED_BIN="$(PATH="$UNWRAPPED_PATH" command -v "$BASENAME")"
|
|
|
|
case "$UNWRAPPED_BIN" in
|
|
/native/*)
|
|
export LD_LIBRARY_PATH="/native/usr/lib:/native/lib"
|
|
export PATH="$UNWRAPPED_PATH"
|
|
;;
|
|
esac
|
|
|
|
exec "$UNWRAPPED_BIN" "$@"
|