Skip to content

Instantly share code, notes, and snippets.

@satmandu
Last active February 23, 2022 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satmandu/37ce878ba5c3e002b7cb6c3a47aa598a to your computer and use it in GitHub Desktop.
Save satmandu/37ce878ba5c3e002b7cb6c3a47aa598a to your computer and use it in GitHub Desktop.
Extract macos dmg with pkg inside from Linux (ubuntu 22.04)
# Install build prereqs:
sudo apt-get install build-essential libxml2-dev libssl-dev zlib1g-dev
# You can extract a dmg using 7z thus: 7z x File.dmg
# This installs tools like lsbom to see what is inside bom files
git clone https://github.com/hogliux/bomutils && cd bomutils && make && sudo make install
# Now install xar so you can extract the pkg file
curl -OLf https://opensource.apple.com/tarballs/xar/xar-425.2.tar.gz
tar fxv xar-425.2.tar.gz
cd xar-425.2/xar/
curl -OLf https://raw.githubusercontent.com/macports/macports-ports/master/archivers/xar/files/xar-1.8-openssl-1.1.patch
patch -Np0 -i xar-1.8-openssl-1.1.patch
curl -OLf https://github.com/macports/macports-ports/raw/master/archivers/xar/files/xar-1.8-Add-OpenSSL-To-Configuration.patch
patch -Np0 -i xar-1.8-Add-OpenSSL-To-Configuration.patch
curl -OLf https://github.com/macports/macports-ports/raw/master/archivers/xar/files/xar-1.8-safe_dirname.patch
patch -Np0 -i xar-1.8-safe_dirname.patch
sed -i 's,filetree.h,../lib/filetree.h,g' src/xar.c
sed -i 's,util.h,../lib/util.h,g' src/xar.c
autoreconf -fvi
./configure
make
sudo make install
# Once you have extracted a File.pkg thus: xar -xvf File.pkg
# You can check the contents with lsbom Bom
# You can extract the Payload thus: cat Payload | gzip -d | cpio -id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment