Introduction
Xar, the eXtensible ARchive format, was started in the OpenDarwin project in the
mid-2000s and taken up by Apple. Its table of contents is an XML document, so new kinds
of information can be added without changing the format, and it can hold checksums and
digital signatures. It is rarely seen under its own name: macOS installer packages
(.pkg files in the flat package format) are xar archives, and so were
older Safari extensions and Xcode’s .xip downloads.
Structure
Numbers in the header are big-endian.
0Magicxar!4 bytes4Header size usually 282 bytes6Version 12 bytes8Table of contents compressed and uncompressed lengths16 bytes24Checksum algorithm none, SHA-1, MD5, or another named in the table of contents4 bytes28Table of contents XML compressed with zlibvaries…Heap the table of contents checksum, then each file’s datathe rest
The table of contents lists every file with its name, type, owner, permissions and times, and for each file’s data its offset in the heap, its length, its encoding (such as gzip or bzip2) and checksums of the stored and extracted data.
Links
Software
xarandpkgutil, built into macOS- 7-Zip, extract only (Windows)
- The Unarchiver (macOS)
Developers
- libarchive, C library that reads and writes xar