XAR/PKG Format
Purpose
This guide covers working with XAR archives and macOS installer packages (PKG) using Excavate.
Concepts
XAR (eXtensible ARchive) is an archive format used primarily for macOS installer packages (.pkg). PKG files contain XAR archives with CPIO payloads.
Basic Usage
PKG Structure
macOS installer packages contain:
Installer.pkg
├── Distribution # Installer configuration XML
├── Resources/ # Images, licenses, etc.
└── Packages/
└── Package.pkg/
├── Bom # Bill of Materials
├── Info.plist
└── Payload # CPIO.GZ archive with filesWhen to Use Recursive
Use recursive_packages: true to extract file contents:
# Without recursive - you get Payload file
Excavate::Archive.new('Installer.pkg').extract
# Result: Installer/Distribution, Installer/Packages/Package.pkg/Payload
# With recursive - Payload is extracted
Excavate::Archive.new('Installer.pkg').extract(recursive_packages: true)
# Result: Installer/Applications/..., Installer/Library/..., etc.XAR Characteristics
| Characteristic | Description |
|---|---|
File extension |
|
Compression | GZIP, BZIP2, LZMA, None |
Platform | macOS (primary) |
Common Use Cases
Extract macOS Application
Excavate::Archive.new('App.pkg').extract(
recursive_packages: true,
filter: '**/Applications/**/*'
)CLI Usage
# Extract PKG recursively
excavate -r Installer.pkg
# Extract with filter
excavate -r --filter "**/*.app" Installer.pkgTechnical Details
Excavate uses the Omnizip gem’s XAR support:
-
Extracts XAR archive structure
-
Renames Payload to Payload.cpio.gz for recognition
-
Passes to CPIO/GZIP extractors recursively
Payload Handling
The PKG Payload is a CPIO archive, often GZIP compressed:
# Excavate handles this chain automatically:
# PKG (XAR) → Payload (CPIO.GZ) → Files
Excavate::Archive.new('Installer.pkg').extract(recursive_packages: true)Related Topics
-
TAR Format - Similar Unix archive format