2.5. PackagingFor 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 RPMAt 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:
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:
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 UsageAfter 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 -iThe 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 eThe 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 -UThe 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 qThe 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 -VThe 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 LSBThe 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]
|