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
make install

4. Extract files with xar

xar -xvf package_installer.pkg

9 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

    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.
    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.

  6. Could you please write down the linux commands that we should be using now that the dependencies are no longer available to use this method?
    I am very new at linux and couldn’t follow it after the dependencies were no longer found.
    Any help would be appreciated.

  7. I could build xar without problems on a Raspberry Pi.

    But when I try to unpack an mpkg file, it refuses:
    qic-warm:~/src> xar -xv -f 1528098253_uart_1_wire_clic_mikroc_arm.mpkg
    Usage: xar -[ctx][v] -f …
    -c Creates an archive
    -x Extracts an archive
    -t Lists an archive

Leave a Reply

Your email address will not be published.