Before you can actually start doing something with a package, you need to unpack it first. Often the package files are tar'ed and gzip'ed or bzip2'ed. I'm not going to write down every time how to unpack an archive. I will explain how to do that once, in this section.
To start with, change to the $LFS/usr/src directory by running:
cd $LFS/usr/src
If a file is tar'ed and gzip'ed, it is unpacked by running either one of the following two commands, depending on the filename:
tar xvzf filename.tar.gz
tar xvzf filename.tgz
If a file is tar'ed and bzip2'ed, it is unpacked by running:
bzcat filename.tar.bz2 | tar xv
Some tar programs (most of them nowadays but not all of them) are slightly modified to be able to use bzip2 files directly using either the I or the y tar parameter, which works the same as the z tar parameter to handle gzip archives. The above construction works no matter how your host system decided to patch bzip2.
If a file is just tar'ed, it is unpacked by running:
tar xvf filename.tar
When an archive is unpacked, a new directory will be created under the current directory (and this book assumes that the archives are unpacked under the $LFS/usr/src directory). Please enter that new directory before continuing with the installation instructions. Again, every time this book is going to install a package, it's up to you to unpack the source archive and cd into the newly created directory.
From time to time you will be dealing with single files such as patch files. These files are generally gzip'ed or bzip2'ed. Before such files can be used they need to be uncompressed first.
If a file is gzip'ed, it is unpacked by running:
gunzip filename.gz
If a file is bzip2'ed, it is unpacked by running:
bunzip2 filename.bz2
After a package has been installed, two things can be done with it: either the directory that contains the sources can be deleted, or it can be kept. If it is kept, that's fine with me, but if the same package is needed again in a later chapter, the directory needs to be deleted first before using it again. If this is not done, you might end up in trouble because old settings will be used (settings that apply to the host system but which don't always apply to the LFS system). Doing a simple make clean or make distclean does not always guarantee a totally clean source tree.
So, save yourself a lot of hassle and just remove the source directory immediately after you have installed it.
There is one exception to that rule: don't remove the Linux kernel source tree. A lot of programs need the kernel headers, so that's the only directory that should not be removed, unless no package is to be compiled anymore.