6.22. Bzip2-1.0.3

The Bzip2 package contains programs for compressing and decompressing files. Compressing text files with bzip2 yields a much better compression percentage than with the traditional gzip.

6.22.1. Installation of Bzip2

Apply a patch to install the documentation for this package:

patch -Np1 -i ../bzip2-1.0.3-install_docs-1.patch

The bzgrep command does not escape '|' and '&' in filenames passed to it. This allows arbitrary commands to be executed with the privileges of the user running bzgrep. Apply the following patch to address this:

patch -Np1 -i ../bzip2-1.0.3-bzgrep_security-1.patch

The bzdiff script depends on tempfile. We remove that dependency with this patch:

patch -Np1 -i ../bzip2-1.0.3-remove_tempfile-1.patch

Bzip2's default Makefile target automatically runs the testsuite as well. Disable the tests since you can not run the cross-compiled binaries causing all of the tests to fail:

cp Makefile{,.orig}
sed -e "/^all:/s/ test//" Makefile.orig > Makefile

The Bzip2 package does not contain a configure script. Compile it with:

make -f Makefile-libbz2_so CC="${CC}" AR="${AR}" RANLIB="${RANLIB}"
make clean

The -f flag will cause Bzip2 to be built using a different Makefile file, in this case the Makefile-libbz2_so file, which creates a dynamic libbz2.so library and links the Bzip2 utilities against it.

Recompile the package using a non-shared library.

make CC="${CC}" AR="${AR}" RANLIB="${RANLIB}"


If reinstalling Bzip2, perform rm -vf ${CLFS}/usr/bin/bz* first, otherwise the following make PREFIX=${CLFS}/usr install will fail.

Install the programs:

make PREFIX=${CLFS}/usr install

Install the shared bzip2 binary into the ${CLFS}/bin directory, make some necessary symbolic links, and clean up:

cp -v bzip2-shared ${CLFS}/bin/bzip2
cp -av libbz2.so* ${CLFS}/lib
ln -sv ../../lib/libbz2.so.1.0 ${CLFS}/usr/lib/libbz2.so
rm -v ${CLFS}/usr/bin/{bunzip2,bzcat,bzip2}
ln -sv bzip2 ${CLFS}/bin/bunzip2
ln -sv bzip2 ${CLFS}/bin/bzcat

6.22.2. Contents of Bzip2

Installed programs: bunzip2 (link to bzip2), bzcat (link to bzip2), bzcmp, bzdiff, bzegrep, bzfgrep, bzgrep, bzip2, bzip2recover, bzless, and bzmore
Installed libraries: libbz2.a, libbz2.so (link to libbz2.so.1.0), libbz2.so.1.0 (link to libbz2.so.1.0.3), and libbz2.so.1.0.3

Short Descriptions


Decompresses bzipped files


Decompresses to standard output


Runs cmp on bzipped files


Runs diff on bzipped files


Runs grep on bzipped files


Runs egrep on bzipped files


Runs fgrep on bzipped files


Compresses files using the Burrows-Wheeler block sorting text compression algorithm with Huffman coding; the compression rate is better than that achieved by more conventional compressors using “Lempel-Ziv” algorithms, like gzip


Tries to recover data from damaged bzipped files


Runs less on bzipped files


Runs more on bzipped files


The library implementing lossless, block-sorting data compression, using the Burrows-Wheeler algorithm