Files
QEMU-S5L8950X/scripts/build-macos-recovery-tools.sh
Yaya48 5d9a60a926 hw/arm: add authenticated A6 IMG3 boot lab
Model the A6 crypto, interrupt, USB, and platform blocks needed to boot SecureROM through iBSS into iBEC Recovery.

Add local lab identity, IMG3, and APTicket tooling, patched macOS recovery utilities, UART and GDB access, and English end-user documentation.
2026-09-01 09:51:49 -07:00

137 lines
4.2 KiB
Bash
Executable File

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
source_dir=$(CDPATH= cd -- "$script_dir/.." && pwd)
build_root=${A6_RECOVERY_BUILD_DIR:-"$source_dir/build/macos-recovery"}
prefix=${A6_RECOVERY_PREFIX:-"$source_dir/build/limd-prefix"}
downloads="$build_root/downloads"
libirecovery_commit=95dec3aa25b1e30654ca107eb971971f6a216520
libirecovery_sha256=fcd91f2d5c6c3d70bba5b6f790ae37e
libirecovery_sha256=${libirecovery_sha256}dcc2ff9419ac56de67770bb5f1cc2eca9
idevicerestore_commit=540c352c4c44896f7415abef87a166e8bbaea9b0
idevicerestore_sha256=d971449c0838fe6733e6cd18268ffa2e5
idevicerestore_sha256=${idevicerestore_sha256}499b8d9034e10cf2984c2c5835913b3
libirecovery_archive="$downloads/libirecovery-$libirecovery_commit.tar.gz"
idevicerestore_archive="$downloads/idevicerestore-$idevicerestore_commit.tar.gz"
github_base=https://github.com/libimobiledevice
libirecovery_url="$github_base/libirecovery/archive/$libirecovery_commit.tar.gz"
idevicerestore_path="idevicerestore/archive/$idevicerestore_commit.tar.gz"
idevicerestore_url="$github_base/$idevicerestore_path"
fail()
{
echo "error: $*" >&2
exit 1
}
for command_name in curl shasum tar patch autoreconf pkg-config make; do
command -v "$command_name" >/dev/null 2>&1 ||
fail "required command not found: $command_name"
done
if command -v brew >/dev/null 2>&1; then
brew_prefix=$(brew --prefix)
else
brew_prefix=/usr/local
fi
pkg_config_path="$prefix/lib/pkgconfig:$brew_prefix/lib/pkgconfig"
pkg_config_path="$pkg_config_path:$brew_prefix/opt/libusb/lib/pkgconfig"
if [ -n "${PKG_CONFIG_PATH:-}" ]; then
pkg_config_path="$pkg_config_path:$PKG_CONFIG_PATH"
fi
export PKG_CONFIG_PATH=$pkg_config_path
for package in \
libimobiledevice-glue-1.0 \
libimobiledevice-1.0 \
libusbmuxd-2.0 \
libplist-2.0 \
libtatsu-1.0 \
libzip \
libcurl \
zlib; do
pkg-config --exists "$package" || fail \
"missing $package dependency; run: brew install libimobiledevice libusb libzip"
done
mkdir -p "$downloads" "$prefix"
fetch_verified()
{
archive=$1
url=$2
expected=$3
temporary="$archive.tmp"
if [ -f "$archive" ]; then
actual=$(shasum -a 256 "$archive" | awk '{print $1}')
if [ "$actual" = "$expected" ]; then
return
fi
fi
echo "Downloading: $url"
curl -fsSL "$url" -o "$temporary"
actual=$(shasum -a 256 "$temporary" | awk '{print $1}')
[ "$actual" = "$expected" ] ||
fail "unexpected SHA-256 for $url: $actual"
mv "$temporary" "$archive"
}
fetch_verified "$libirecovery_archive" "$libirecovery_url" \
"$libirecovery_sha256"
fetch_verified "$idevicerestore_archive" "$idevicerestore_url" \
"$idevicerestore_sha256"
work_dir=$(mktemp -d "$build_root/source.XXXXXX")
case $work_dir in
"$build_root"/source.*) ;;
*) fail "unexpected temporary directory: $work_dir" ;;
esac
trap 'rm -rf "$work_dir"' EXIT HUP INT TERM
tar -xzf "$libirecovery_archive" -C "$work_dir"
tar -xzf "$idevicerestore_archive" -C "$work_dir"
libirecovery_source="$work_dir/libirecovery-$libirecovery_commit"
idevicerestore_source="$work_dir/idevicerestore-$idevicerestore_commit"
echo "Applying the QEMU backend to libirecovery"
patch -d "$libirecovery_source" -p1 \
-i "$script_dir/patches/libirecovery-qemu.patch"
printf '%s\n' '1.3.1-qemu-a6' > "$libirecovery_source/.tarball-version"
(
cd "$libirecovery_source"
autoreconf -fiv
./configure --prefix="$prefix"
make -j4
make install
)
printf '%s\n' '1.0.0-qemu-a6' > "$idevicerestore_source/.tarball-version"
echo "Applying boot-only mode without filesystem extraction"
patch -d "$idevicerestore_source" -p1 \
-i "$script_dir/patches/idevicerestore-no-restore-fs.patch"
echo "Applying QEMU boot support for a local lab identity"
patch -d "$idevicerestore_source" -p1 \
-i "$script_dir/patches/idevicerestore-qemu-lab-boot.patch"
(
cd "$idevicerestore_source"
autoreconf -fiv
./configure --prefix="$prefix"
make -j4
make install
)
echo
echo "Tools installed in $prefix/bin"
echo "Start QEMU with ./Run-iPhone5-macOS.sh, then run:"
echo " scripts/irecovery-qemu -q"
echo " scripts/idevicerestore-qemu -d -y /path/to/Restore.ipsw"