# Take apart InstallAssistant.pkg on Linux: # installer-app.tar "Install macOS .app" skeleton (Payload, pbzx+cpio) # installer.json byte offsets of SharedSupport.dmg inside the pkg # app-name e.g. "Install macOS Tahoe.app" # The 18 GB SharedSupport.dmg is never copied on the host; makeImage exposes that # byte range of the pkg as a raw disk and the recovery script copies it into the app. { pkgs, lib, ... }: { name, pkg }: pkgs.runCommand "${name}-installer-payload" { nativeBuildInputs = with pkgs; [ xar pbzx cpio python3 gnutar ]; } '' mkdir -p $out xar --dump-toc=toc.xml -f ${pkg} python3 ${./xar-toc.py} toc.xml ${pkg} > $out/installer.json grep -q '"SharedSupport.dmg"' $out/installer.json || { echo "no SharedSupport.dmg in pkg"; exit 1; } grep -A4 '"SharedSupport.dmg"' $out/installer.json | grep -q '"encoding": "application/octet-stream"' \ || { echo "SharedSupport.dmg is compressed inside the xar, cannot map it as a disk"; exit 1; } echo "=== vmix: extracting installer app skeleton ===" xar -x -f ${pkg} Payload mkdir root (cd root && pbzx -n ../Payload | cpio -idm --quiet) APP=$(ls root/Applications | grep -E '^Install macOS.*\.app$' | head -1) [ -n "$APP" ] || { echo "installer app not found in Payload"; ls -R root | head; exit 1; } echo "$APP" > $out/app-name tar -C root/Applications -cf $out/installer-app.tar "$APP" ls -la $out ''