Notes on building software

Those people who have built an LFS system will be aware of the general principles of downloading and unpacking software. We will however repeat some of that information here for those new to building their own software.

Each set of installation instructions contains a URL from which you can download the package. We do however keep a selection of patches available via http. These are referenced as needed in the installation instructions.

While you can keep the source files anywhere you like, we assume that you have unpacked them and unzipped any required patches into /usr/src.

We can not emphasize strongly enough that you should start from a clean source tree each time. This means that if you have had an error, it's usually best to delete the source tree and re-unpack it before trying again. This obviously doesn't apply if you're an advanced user used to hacking Makefiles and C code, but if in doubt, start from a clean tree.

Unpacking the software

If a file is tar'ed and gzip'ed, it is unpacked by running one of the following commands, depending on the filename:

tar -xvzf filename.tar.gz
tar -xvzf filename.tgz
tar -xvzf filename.tar.Z

If a file is tar'ed and bzip2'ed, it can usually be unpacked by running:

tar -jxvf filename.tar.bz2

You can also use a slightly different method:

bzcat filename.tar.bz2 | tar -xv

Finally, you sometimes need to be able to unpack patches which are generally not tar'ed. The best way to do this is to copy the patch file to /usr/src and then to run one of the following commands depending on whether the file is .gz or .bz2:

gunzip patchname.gz
bunzip2 patchname.bz2

Verifying file integrity using md5sum

Generally, to verify that the downloaded file is genuine and complete, most package maintainers also distribute md5sums of the files. To verify the md5sum of the downloaded files, download both the file and the corresponding md5sum file to the same directory (preferably from different on-line locations), and (assuming file.md5sum is the md5sum file downloaded) run the following command:

md5sum -c file.md5sum

If there are any errors, they will be reported.

Creating Log files during installation

For larger packages, it is convenient to create log files instead of staring at the screen hoping to catch a particular error or warning. Log files are also useful for debugging and keeping records. The following command allows you to create an installation log. Replace <command> with the command you intend to execute.

( <command> 2>&1 | tee compile.log && exit $PIPESTATUS )

2>&1 redirects error messages to the same location as standard output. The tee command allows viewing of the output while logging the results to a file. The parentheses around the command run the entire command in a subshell and finally the exit $PIPESTATUS ensures the result of the <command> is returned as the result and not the result of the tee command.

Last updated on 2005-02-04 00:30:54 -0700