Recursive Extraction
Concepts
Recursive extraction automatically detects and extracts archives within archives. This is essential for formats like MSI (which contain CAB files) and PKG (which contain CPIO payloads).
Basic Usage
Enable recursive extraction with the recursive_packages option:
Excavate::Archive.new('installer.msi').extract(recursive_packages: true)How It Works
The recursive extraction process:
-
Extract the top-level archive
-
Scan extracted files for nested archives
-
Extract each nested archive
-
Replace the archive file with its contents
-
Repeat until no more nested archives found
installer.msi
│
├── Extract MSI
│
▼
data1.cab data2.cab
│ │
├── Extract ├── Extract
│ │
▼ ▼
file1.dll file3.dll
file2.exe file4.sysFormats That Benefit
MSI Files
MSI files contain embedded CAB archives:
# Extract MSI and all embedded CABs
Excavate::Archive.new('setup.msi').extract(recursive_packages: true)Combining with Other Options
Recursive + Filter
# Extract DLL files from MSI and nested CABs
Excavate::Archive.new('installer.msi').extract(
recursive_packages: true,
filter: '**/*.dll'
)Depth Handling
Excavate handles arbitrary nesting depth:
# Handles: archive.zip → inner.tar.gz → data.cab → files
Excavate::Archive.new('complex.zip').extract(recursive_packages: true)Performance Considerations
Recursive extraction is more I/O intensive:
-
Each nested archive requires additional extraction pass
-
Disk space temporarily doubles during extraction
-
Consider filtering to reduce work
# Faster: Filter early
Excavate::Archive.new('large.msi').extract(
recursive_packages: true,
filter: '**/*.dll'
)
# Slower: Extract everything
Excavate::Archive.new('large.msi').extract(recursive_packages: true)CLI Usage
# Recursive extraction
excavate -r installer.msi
# Short form
excavate --recursive package.pkg
# Combined with filter
excavate -r --filter "**/*.ttf" fonts.msiCommon Patterns
Extract All from Installer
# Extract everything from Windows installer
Excavate::Archive.new('setup.msi').extract(recursive_packages: true)