Section 2.5. Packaging


2.5. Packaging

For some applications, you might need to use a package manager to uniformly distribute and install the application on any Linux platform. As an alternative to distributing the application on a tarball image, using a package manager to distribute and install the application on Linux has its advantages. One advantage to using a packaging manager is it allows versions of the application to be managed properly.

The Red Hat Package Manager (RPM) is the most popular package manager available in Linux. It is a command-line utility used to install, uninstall, verify, query, and update software packages in Linux. Before RPM became available, there was no easy and elegant way to manage software application installations on a Linux server. Installation was done through compressed and tar'ed files, and the only way to find out whether an application was dependent on another package was by reading the documentation that came with it or by running the application and hoping it produced a message describing the missing component. The availability of RPM changed all this!

Applications packaged in RPM format made maintaining and managing software applications on a Linux machine easier. Red Hat, the originator of RPM, also became the most popular Linux distribution as a result of the release of RPM. Today, most if not all Linux distributions support RPM as the de facto package manager. It is for this reason that we recommend applications ported to Linux be packaged in an RPM format. More detailed documentations for RPM can be found at www.rpm.org/.

2.5.1. Packaging the Application with RPM

At the heart of RPM is the RPM engine. The engine requires several files as input and builds the packaged application as the output. One of the input files that RPM requires is the spec file. The spec file contains informational and instructional verbiage that will be displayed or acted on by RPM, respectively, during the package build or user installation. The spec file has the following sections:

  • Preamble. Contains information that displays when information about the package is requested

  • Prep. Contains a script used by RPM to prepare for the actual build of the package

  • Build. Contains scripts to actually build the package from source files

  • Install. Contains commands to install the software application when the build step completes

  • Install and uninstall. Contains the install and uninstall scripts that are run on the user's system when he or she installs the software application through the RPM command utility

  • Verify. Contains a script to verify the installation of a package in the user system

  • Clean. Contains a script to clean up after a package build

  • File list. Contains the list of files to be packaged, file permissions when files are installed on the user system, documentation, and configuration information

The sections of the spec file used during the build of the package are the prep, build, install, clean, and file list sections. The sections used by RPM when installing the package on the user system are the install and uninstall, verify, and file list sections.

When building a package, a package with RPM follows these steps:

1.

Create a build environment that includes the source. This is the environment where the sources will be patched if patches are available and compiled to create the binary distribution.

2.

Run the installation script in the install section after the build is complete to install the binaries into the correct directory locations.

3.

After the binaries have been installed, create the package using the file list section. Note that RPM does not create the file list automatically. This list needs to be created manually.

4.

The final output of the build is the RPM distribution package.

For a complete reference on how to build an RPM package, refer to the Maximum RPM documentation available at www.rpm.org/max-rpm-snapshot/.

2.5.2. Basic RPM Usage

After the software application has been packaged as an RPM file, it can be tested with the command syntax described in the following sections.

2.5.2.1. rpm -i

The command rpm i tells RPM to install a software package. This command also performs dependency checks and pre-installation tasks, unpacks installation files from the package and places them in the proper directories, performs post-installation tasks, and creates a log of what was done.

2.5.2.2. rpm e

The command rpm e removes or erases one or more packages from the system. This command checks the RPM database for package dependencies, performs pre-uninstall tasks, saves modified configuration files, removes files belonging to this package, and executes post-uninstall tasks.

2.5.2.3. rpm -U

The command rpm U upgrades an old version of the application software. This command removes the previous version of the software and installs a new version. It is basically a combination of the rpm i and rpm e command.

2.5.2.4. rpm q

The command rpm q provides information about a specific software application. The information may include but is not limited to the version of a package, identifying what file belongs to what package and version of the installed package.

2.5.2.5. rpm -V

The command rpm V verifies an installed package. This command can verify the file attributes of files included in a package. This can give a sense of what may have changed for a particular software installation. Information verified by the rpm V command includes but is not limited to the owner, group, MD5 checksum, and size of the file. These attributes are compared to the RPM database to make sure that they match the original installation results.

2.5.3. Baseline Packaging Format as Recommended by the LSB

The Linux Standard Base 1.2 specification offers a baseline RPM recommendation for Linux packages so that these packages can be installed and used in all Linux distributions. It recommends that applications packaged in the RPM format follow the specifications in the appendix section of the 1997 edition of Maximum RPM (www.rpm.org/max-rpm/) with some restrictions. You can find these restrictions on the LSB website (www.linuxbase.org/spec/refspecs/LSB_1.2.0/gLSB/swinstall.html#FTN.PKG-1).

As a side note, another package manager available for Linux is called DEB.[18],[19] DEB is similar to RPM in almost all respects when it comes to packaging features. The main difference between DEB and RPM is the package format. Although RPM packages are most commonly used to package Linux applications for installation on almost all Linux platforms, DEB packages are used to package products for installation on the Debian distribution of Linux.[20] RPM packages can still be installed on Debian Linux, but only after they are converted from an RPM format to a DEB format. A tool that can convert RPM packages to DEB packages and vice versa is alien.[21]

[18] "How to make Debian packages": http://linuxdevices.com/articles/AT8047723203.html

[19] "Debian packages": www.tldp.org/HOWTO/Debian-Binary-Package-Building-HOWTO/

[20] And other Debian variants, such as Lindows

[21] See Linux man pages alien(1).




UNIX to Linux Porting. A Comprehensive Reference
UNIX to Linux Porting: A Comprehensive Reference
ISBN: 0131871099
EAN: 2147483647
Year: 2004
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net