**DMG/PKG Linux notes** ----------------------- Mounting DMGs w/ HFS partitions: ### Tools needed: `apt-get install hfsplus hfsutils hfsprogs dmg2img` #### Convert DMG to raw IMG (pkgdmgs don't need this) `dmg2img image.dmg image.img` An HFS+/HFSX partition starts with 1024 reserved bytes (for boot code), followed by the volume header. The first 4 bytes of the volume header are a signature and a version number: - "H+" followed by version 4 = HFS - "HX" followed by version 5 = HFSX Search raw img for either HFS+ or HFSX header - `"48 2b 00 04"` = HFS+ - `"48 58 00 05"` = HFSX - `hexdump -C image.img | grep "48 2b 00 04"` Subtract 1024 bytes to find the beginning of the partition - `expr $(printf "%d" 0x
) - 1024` Get the offset in a one-liner using first found match for HFS+ volume header in SOURCE.img: - `expr $(printf "%d" 0x$(hexdump -C SOURCE.img | grep -m 1 "48 2b 00 04" | awk '{print $1}')) - 1024` Setup .img as a block device: - `losetup -o  /dev/loop0 image.img` Mount the block device: - `mount -t hfsplus /dev/loop0 /mnt` ### Install XAR from source: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ apt-get install -y build-essentials git autoconf libxml2-dev libcurl4-openssl-dev python2.7 libbz2-dev liblzma-dev git clone https://github.com/mackyle/xar.git cd xar ./autogen.sh ./configure --with-bzip2 --with-lzma=/usr make make install ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### Convert and extract PBZX-wrapped Payload (as of OS X 10.10) needs extra processing if: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file path/to/Payload > path/to/Payload: data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Use Michael Lynn's Python script to remove PBZX wrapper: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ xar -x -f /mnt/SOME.pkg path/to/Payload file path/to/Payload > path/to/Payload: data parsepbzx.py path/to/Payload file /Payload.cpio.xz > Payload.cpio.xz: XZ compressed data xz -d /Payload.cpio.xz file /Payload.cpio > Payload.cpio: ASCII cpio archive (pre-SVR4 or odc) cpio -i --list -I /Payload.cpio >. >./System >./System/Library >./System/Library/Input Methods >./usr >./Library ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ### Install bomutils from source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ git clone https://github.com/hogliux/bomutils.git make make install ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~