Extract .pkg and .mpkg files with xar on Linux

macOS installer packages have the .pkg extension which are xar archives, to extract them on Linux we need to download and compile xar from https://code.google.com/archive/p/xar/downloads.

Operating system:  Linux Debian 9 / kernel 4.9.0-3-amd64

1. Install dependencies

apt-get install build-essential libxml2-dev libssl1.0-dev zlib1g-dev

2. Download and extract xar-1.5.2.tar.gz

wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/xar/xar-1.5.2.tar.gz
tar -zxvf xar-1.5.2.tar.gz

3. Build and install

cd xar-1.5.2
./configure
make
make install

4. Extract files with xar

xar -xvf package_installer.pkg

6 Replies to “Extract .pkg and .mpkg files with xar on Linux”

  1. it does not work:

    apt-get install build-essential libxml2-dev libssl1.0-dev zlib1g-dev

    E: Unable to locate package libssl1.0-dev

  2. Linux Mint 19.3

    my error is ;
    “make: *** No targets specified and no makefile found. Stop.”

    I couldn’t find any specific solution.

  3. Hi Bruno and vokhirion,

    Make sure that the ./configure is finishing successfully.
    In case of an error, you must install the dependencies and retry the ./configure.
    You have to use make and make install only after the ./configure was successfully.

  4. My configure did not work. Here is the error:
    ============================================
    checking for openssl/evp.h… yes
    checking for OpenSSL_add_all_ciphers in -lcrypto… no
    configure: error: Cannot build without libcrypto (OpenSSL)
    ================================================
    I added the OpenSSL package (a higher version than the one recommended because the one recommended could not be found.
    I reran the ./configure but got the same error, however, I found the libcrypto file:
    ===============================================
    ~/xar-1.5.2$ sudo find / -name libcrypto.so
    /usr/lib/x86_64-linux-gnu/libcrypto.so

    I added the path to the LD_LIBRARY_PATH variable, but it still would not pick it up. Can you say what I might do to get the configure script to pick up the libcrypto file?

  5. The missing libcrypo stuff is because debian has moved on and/or reorganised the openssl libraries. I found it simplest to go build the old debian packages. You can download them ready-built straight from debian packages repositories too.
    libssl1.0.2_1.0.2u-1~deb9u1_i386.deb
    libssl1.0-dev_1.0.2u-1~deb9u1_i386.deb
    You probably need to uninstall libssl-dev if you have a 1.1-based version (Debian unstable does). Then you get a minor fight with apt that you should win easily.

Leave a Reply

Your email address will not be published. Required fields are marked *