This topic has a total weight of 7 points and contains the following objectives:
Candidates should be able to build and install an executable program from source. This objective includes being able to unpack a file of sources.
The candidate should be able to create an off-site backup storage plan.
This section used to be an objective for LPI. It no longer is. This section serves as a reference. It explains how to configure the logging daemon to act as a central network log server. It also includes configuring the logging daemon to send log output to a central log server, logging remote connections and using grep and other text utilities to automate log analysis.
This section used to be an objective for LPI. It no longer is. This section serves as a reference. It explains how to build a package. It describes building (or rebuilding) both RPM and DEB packaged software.
TODO: review and complete this section
Candidates should be able to build and install an executable program from source. This objective includes being able to unpack a file of sources.
Key files, terms and utilities include:
/usr/src/ |
| gunzip |
| gzip |
| bzip2 |
| tar |
| configure |
| make |
| uname |
| install |
Resources: the man pages of tar(1), gzip(1), bzip2(1), make(1), uname(1) and install(1).
Most Open Source software is distributed as compressed tarballs containing source code and build scripts to compile and install the software.
These tarballs are generally compressed using either gzip or bzip2. GNU tar supports these compression formats, and makes it easy to decompress such files. For example, to unpack a gzip compressed tarball:
$ tar zxvf /path/to/tarball.tar.gz
The z option tells tar to use the gzip alghorithm, and the x option tells tar to extract the file. To extract a bzip2 compressed file use GNU tar's j option:
$ tar jxvf /path/to/tarball.tar.bz2
Although GNU tar supports these compression alghorithms, several other tar implementations don't. To extract compressed tarballs on machines with such tar implementations, you first need to decompress the file, and then extract the contents.
For a gzip compressed tarball:
$ gunzip /path/to/tarball.tar.gz
For a bzip2 compressed tarball:
$ bunzip2 /path/to/tarball.tar.bz2
As an alternative, you can also use the '-d' (decompress) argument to the gzip and bzip2 commands.
After decompression, you can extract the contents by calling tar without giving a compression argument:
$ tar xvf /path/to/tarball.tar
Usually the build scripts are generated using GNU autoconf and automake. automake is used to generate GNU Coding standard compliant Makefile.in files. autoconf produces self-contained configure scripts which can then be used to adapt, build and install the software on the target system.
The usual way of building and installing software from source looks something like this:
$ tar zxvf snow-2.0.3.tar.gz
$ cd snow-2.0.3
$ ./configure
$ make
$ su
# make install
The ./configure command will check for both optional and mandatory dependencies. It will also adapt the source code to the target system (think system architecture, installed libraries, compiler flags, install directories, ...). If an optional dependency is missing, it will disable compilation to that dependency. In the case of missing required dependencies, it will print the error and exit.
According to GNU standards, the commands above would install the
'snow' application under /usr/local. If you
want to install the application under some other directory
structure, for example /opt, the configure
command would look like:
$ ./configure --prefix=/opt
Try ./configure --help to see all possible configure arguments.
The configure command also generates Makefiles
which make uses to compile and install the
software. The Makefile usually contains
several 'build targets' which you can call by giving them as an
argument to make. Often used targets include 'all' which is
usually the default action, 'clean' to clean up (remove) built
object files from the source tree, and 'install' to install the
software after the build stage.
It's possible to install the built software under a different directory than it was configured for. This is for useful if you want to build the software on one machine, and install it on another:
$ tar zxvf snow-2.0.3.tar.gz $ cd snow-2.0.3 $ ./configure --prefix=/opt/snow $ make DESTDIR=/tmp/snow_tmp install
This technique is often used to build software on one machine,
and install it onto multiple others. In the above case,
the /tmp/snow_tmp directory would only
contain files installed by snow-2.0.3.
$ cd /tmp/snow_tmp
$ tar zcf snow_2.0.3_built.tgz opt/
The c option (as opposed to the previously mentioned x option) to tar tells it to create a new archive.
If you copy the resulting tarball to the target machines in,
let's say, the /tmp directory, you can
execute the following commands to install the snow software
into /opt/snow:
# cd /
# tar zxvf /tmp/snow_2.0.3_built.tgz