-
-
Save itsHanibee/fac63ea2fc0eca7b8d7dcbb7eb678c3b to your computer and use it in GitHub Desktop.
A script for patching toolchains to resolve glibc requirement issues on distros with old glibc packages. The script must be placed in the toolchain directory and then executed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
WORK_DIR=$(pwd) | |
cd "$HOME" || exit | |
echo "Downloading patchelf binary from ArchLinux repos" | |
mkdir -p patchelf-temp | |
#curl -L https://github.com/Jebaitedneko/docker/raw/ubuntu/patchelf | |
curl -L https://archlinux.org/packages/extra/x86_64/patchelf/download | bsdtar -C patchelf-temp -xf - | |
mv "$HOME"/patchelf-temp/usr/bin/patchelf "$HOME"/ | |
rm -rf "$HOME"/patchelf-temp | |
echo "Downloading latest glibc from ArchLinux repos" | |
mkdir -p glibc | |
curl -L https://archlinux.org/packages/core/x86_64/glibc/download | bsdtar -C glibc -xf - | |
curl -L https://archlinux.org/packages/core/x86_64/lib32-glibc/download | bsdtar -C glibc -xf - | |
ln -svf "$HOME"/glibc/usr/lib "$HOME"/glibc/usr/lib64 | |
echo "Patching glibc" | |
for bin in $(find "$HOME"/glibc -type f -exec file {} \; | grep 'ELF .* interpreter' | awk '{print $1}'); do | |
bin="${bin::-1}" | |
echo "Patching: $bin" | |
"$HOME"/patchelf --set-rpath "$HOME"/glibc/usr/lib --force-rpath --set-interpreter "$HOME"/glibc/usr/lib/ld-linux-x86-64.so.2 "$bin" | |
done | |
echo "Patching Toolchain" | |
for bin in $(find "$WORK_DIR" -type f -exec file {} \; | grep 'ELF .* interpreter' | awk '{print $1}'); do | |
bin="${bin::-1}" | |
echo "Patching: $bin" | |
"$HOME"/patchelf --add-rpath "$HOME"/glibc/usr/lib --force-rpath --set-interpreter "$HOME"/glibc/usr/lib/ld-linux-x86-64.so.2 "$bin" | |
done | |
echo "Cleaning" | |
rm -rf "$HOME"/patchelf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment