XZ Utils for iPhone

XZ Utils is free general-purpose data compression software with a high compression ratio. The easiest way to install XZ Utils is through my Cydia repository. If you want to know how to build it from source, though, read on.

You will need the on-iPhone development environment to build XZ Utils. As always, please contact me if you need help.

The Easy Way

First, you need to download a copy of the XZ Utils source and the patch:

iphone:~ mobile$ wget http://tukaani.org/xz/xz-4.999.9beta.tar.bz2
iphone:~ mobile$ wget http://gammalevel.com/forever/xz-4.999.9beta-iPad.patch

Now, we will unpack the source and apply the patch:

iphone:~ mobile$ tar xjvf xz-4.999.9beta.tar.bz2
iphone:~ mobile$ cd xz-4.999.9beta
iphone:~/xz-4.999.9beta mobile$ patch -p1 < ../xz-4.999.9beta-iPad.patch

Now we can configure, build, and install as always:

iphone:~/xz-4.999.9beta mobile$ ./configure
iphone:~/xz-4.999.9beta mobile$ make
iphone:~/xz-4.999.9beta mobile$ sudo make install

XZ Utils is now installed.

The Hard Way

In this section, we build XZ Utils the same way, except I’ll actually walk through editing files manually, and explain why the changes are made. You should really use the patch method, though, if it works.

The only file we need to change in XZ Utils is src/common/cpucores.h, and this file is patched this way for just about every BSD system there is. It seems the XZ Utils developers didn’t know how to use the sysctl call correctly. Find the line where they call the sysctl function, and change it to this:

if (!sysctl(name, 2, &cpus, &cpus_size, NULL, NULL)
                  && cpus_size == sizeof(cpus) && cpus > 0)

Note that the only difference is the 2 added after name.