Created
May 13, 2023 15:11
-
-
Save Lessica/97c3ee0172bf8e24820b71dfe44d53b3 to your computer and use it in GitHub Desktop.
Fetch libraries and executables for macOS from libimobiledevice artifacts. This script will make executables runnable without install them to specific paths.
This file contains 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
#!/bin/sh | |
set -e | |
if ! test -x "`which ldid`"; then | |
echo "Cannot find ldid, you may install it via Homebrew." | |
exit 1 | |
fi | |
if [ ! -d "$(xcode-select -p)" ]; then | |
echo "You need to install Xcode to use this script." | |
exit 1 | |
fi | |
EFFECTIVE_URL=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/NyaMisty/libimobiledevice-nightly-pkg/releases/latest/) | |
EFFECTIVE_TAG=$(basename $EFFECTIVE_URL) | |
if [ ! -f macOS.tar ]; then | |
curl -Lo macOS.tar "https://github.com/NyaMisty/libimobiledevice-nightly-pkg/releases/download/$EFFECTIVE_TAG/macOS.tar" | |
fi | |
tar xvf macOS.tar -C . | |
mv ./usr/local/lib/*.dylib ./usr/local/bin || true | |
for FILENAME in ./usr/local/bin/*; do | |
if [ ! -L $FILENAME ] | |
then | |
LIBLIST=$(otool -arch arm64 -L $FILENAME | cut -d' ' -f1-1 | xargs | cut -d' ' -f2-) | |
for LIBNAME in $LIBLIST; do | |
LIBBASENAME=$(basename $LIBNAME) | |
if [ -e "./usr/local/bin/$LIBBASENAME" ]; then | |
install_name_tool -change $LIBNAME @executable_path/$LIBBASENAME $FILENAME | |
ldid -S $FILENAME | |
fi | |
done | |
fi | |
done | |
open ./usr/local/bin | |
exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment