A .pkg file is an archive (often an xar archive or a flat file) containing:
if head -n 1 "$INPUT_BIN" | grep -q "#!/bin/sh"; then echo "Detected self-extracting script. Extracting..." extract_dir="/tmp/bin_extract_$$" mkdir -p "$extract_dir" (cd "$extract_dir" && sh "$INPUT_BIN" --noexec --target .) pkgbuild --root "$extract_dir" --identifier "com.bin2pkg.extractor" --version 1.0 "$OUTPUT_PKG" rm -rf "$extract_dir" exit 0 fi bin to pkg
: This is essential for MDM (Mobile Device Management) systems like Hexnode or Jamf , which require .pkg files to push software to managed Macs remotely. 3. Firmware and Networking (Cisco & Sony) bin to pkg