Run a virtual iPhone on an Apple Silicon Mac.
Swift
fix: prefer project venv Python for patchers (#187)
matteo zappiae8c29f3a8275
diff --git a/scripts/cfw_install_jb.sh b/scripts/cfw_install_jb.shindex 13ebd5c5..59841d8b 100755--- a/scripts/cfw_install_jb.sh+++ b/scripts/cfw_install_jb.sh@@ -15,6 +15,19 @@ set -euo pipefailVM_DIR="${1:-.}"SCRIPT_DIR="${0:a:h}"+# ── Python resolver — prefer project venv over whatever is in PATH ─+# Resolves to .venv/bin/python3 relative to the project root (parent of+# scripts/), falling back to the system python3 when the venv is absent.+_resolve_python3() {+ local venv_py="${SCRIPT_DIR:h}/.venv/bin/python3"+ if [[ -x "$venv_py" ]]; then+ echo "$venv_py"+ else+ command -v python3 || true+ fi+}+PYTHON3="$(_resolve_python3)"+# ════════════════════════════════════════════════════════════════# Step 1: Run base CFW install (skip halt — we continue with JB phases)# ════════════════════════════════════════════════════════════════@@ -225,10 +238,10 @@ fi# LC_LOAD_DYLIB command after stripping LC_CODE_SIGNATURE.if [[ -d "$JB_INPUT_DIR/basebin" ]]; thenecho " Injecting LC_LOAD_DYLIB for /b (short launchdhook alias)..."- python3 "$SCRIPT_DIR/patchers/cfw.py" inject-dylib "$TEMP_DIR/launchd" "/b"+ "$PYTHON3" "$SCRIPT_DIR/patchers/cfw.py" inject-dylib "$TEMP_DIR/launchd" "/b"fi-python3 "$SCRIPT_DIR/patchers/cfw.py" patch-launchd-jetsam "$TEMP_DIR/launchd"+"$PYTHON3" "$SCRIPT_DIR/patchers/cfw.py" patch-launchd-jetsam "$TEMP_DIR/launchd"# Re-sign with original entitlements to avoid "operation not permitted" on spawnif [[ -s "$TEMP_DIR/launchd.entitlements" ]]; then@@ -375,7 +388,7 @@ if [[ -f "$SETUP_PLIST" ]]; then# Inject into launchd.plist so launchd starts it at bootecho " Injecting com.vphone.jb-setup into launchd.plist..."scp_from "/mnt1/System/Library/xpc/launchd.plist" "$TEMP_DIR/launchd.plist"- python3 -c "+ "$PYTHON3" -c "import plistlib, syswith open(sys.argv[1], 'rb') as f:target = plistlib.load(f)diff --git a/scripts/setup_machine.sh b/scripts/setup_machine.shindex cba0ba7f..bd100139 100755--- a/scripts/setup_machine.sh+++ b/scripts/setup_machine.sh@@ -414,6 +414,30 @@ stop_process_tree() {wait "$pid" 2>/dev/null || true}+kill_stale_vphone_procs() {+ local vphone_bin="${PROJECT_ROOT}/.build/release/vphone-cli"+ local -a stale_pids+ stale_pids=(${(@f)$(pgrep -f "$vphone_bin" 2>/dev/null || true)})+ (( ${#stale_pids[@]} == 0 )) && return++ echo "[*] Found stale vphone-cli process(es) (pids: ${stale_pids[*]}); terminating..."+ for pid in "${stale_pids[@]}"; do+ [[ "$pid" == "$$" ]] && continue+ stop_process_tree "$pid"+ done++ # Wait up to 8s for VZ file locks to clear (flock/fcntl locks may lag behind process exit)+ local waited=0+ while (( waited < 8 )); do+ local -a remaining+ remaining=(${(@f)$(collect_vm_lock_pids)})+ (( ${#remaining[@]} == 0 )) && break+ sleep 1+ (( waited++ ))+ done+ echo "[+] Stale vphone-cli processes cleared"+}+force_release_vm_locks() {local -a lock_pidslocal pid@@ -706,6 +730,7 @@ start_boot_dfu() {returnfi+ kill_stale_vphone_procscheck_vm_storage_locks: > "$DFU_LOG"@@ -972,6 +997,10 @@ main() {run_make "Project setup" buildfi+ # Activate venv so all child scripts (cfw_install, patchers, etc.) use the+ # project Python with capstone/keystone/pyimg4 installed, not the bare system python3.+ export PATH="$PROJECT_ROOT/.venv/bin:$PATH"+run_make "Firmware prep" vm_newrun_make "Firmware prep" fw_preparerun_make "Firmware patch" "$fw_patch_target"diff --git a/scripts/vm_manifest.py b/scripts/vm_manifest.pyindex a15aa5a4..8acb39bd 100755--- a/scripts/vm_manifest.py+++ b/scripts/vm_manifest.py@@ -4,6 +4,7 @@ vm_manifest.py — Generate VM manifest plist for vphone-cli.Compatible with security-pcc's VMBundle.Config format."""+import argparseimport plistlibimport sys@@ -58,7 +59,7 @@ def create_manifest(},"sepStorage": "SEPStorage",}-+if platform_fusing is not None:manifest["platformFusing"] = platform_fusing