Skip to content

Instantly share code, notes, and snippets.

@phracker
Created August 5, 2018 20:40
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save phracker/1944ce190e01963c550566b749bd2b54 to your computer and use it in GitHub Desktop.
Save phracker/1944ce190e01963c550566b749bd2b54 to your computer and use it in GitHub Desktop.
Unpack XIP on Linux

Unpacking XIP files on Linux:

  1. Install xar from https://mackyle.github.io/xar/
  2. Install pbzx from https://github.com/NiklasRosenstein/pbzx (use gcc -llzma -lxar -I /usr/local/include pbzx.c -o pbzx and copy the binary into your PATH)
  3. use xar -xf XIP_FILE -C /path/to/extract/to
  4. Change to the directory where you extracted the file.
  5. Use pbzx -n Content | cpio -i to extract the contents.
@lucacordisco
Copy link

Thank you :)

@esnosy
Copy link

esnosy commented May 30, 2021

many thanks!

@partho222
Copy link

pbzx compilation should be

gcc -I /usr/local/include pbzx.c -o pbzx -llzma -lxar

because on OS X the linker allows the -l command line options to precede the source files. On Linux it does not.

@trygvis
Copy link

trygvis commented Dec 21, 2021

On modern Linux you need to fix configure.ac: https://askubuntu.com/a/1195797

Also note that you have to install libbz2-dev (and liblzma-dev) on Debian/Ubuntu to extract at least the Xcode xip archive.

@kasaiee
Copy link

kasaiee commented Mar 7, 2022

@partho222
so many thanks. I had exactly the issue

@richbai90
Copy link

richbai90 commented Aug 11, 2022

On modern Linux you need to fix configure.ac: https://askubuntu.com/a/1195797

Also note that you have to install libbz2-dev (and liblzma-dev) on Debian/Ubuntu to extract at least the Xcode xip archive.

In addition to this, you also need to make the changes mentioned in this issue mackyle/xar#10

@PiRK
Copy link

PiRK commented Apr 26, 2023

Alternatively, with less patching & compiling required: use the tool developed by bitcoin

https://github.com/bitcoin-core/apple-sdk-tools

python extract_xcode.py -f Xcode_11.3.1.xip | cpio -d -i

@Abyss-W4tcher
Copy link

Abyss-W4tcher commented Oct 4, 2023

Hi, the following worked for me (inverted lib order while linking) :

sudo ldconfig # after installing xar
gcc pbzx.c -o pbzx -llzma -lxar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment