pbzx -n Payload | cpio -i For a macOS installer ISO, copy the extracted contents into a folder that mimics a bootable installer (e.g., copy Install macOS.app contents). For a simple data ISO, skip this.
Example structure:
echo "Creating ISO ..." hdiutil makehybrid -iso -joliet -o "$OUT" .
genisoimage -R -J -V "MyVolume" -o output.iso iso_contents/ #!/bin/bash PKG="$1" OUT="$2:-output.iso" TMPDIR=$(mktemp -d) echo "Extracting $PKG ..." xar -xf "$PKG" -C "$TMPDIR" cd "$TMPDIR"
iso_contents/ Applications/ (if macOS installer) Library/ System/ usr/ .IABootFiles (for bootability) On macOS:
cd pkg_extracted cat Payload | gunzip -dc | cpio -i