Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt

Related items

Made to Measure : Apache Web Server Customization

Apache at your Web Service

Jump Start your Intranet Web Sites - Setting up Virtual Hosts on Apache

Linux #6 Stairway to Heaven? - Setting up your Linux Server as an Internet Gateway!

Linux #5 What's in a name? - Domain Name Server on Linux

Linux #4 "Setting up DHCP is not P2C2E"

Linux #3 "You teach best...."

Linux#2 Net Connection

Linux#1 A Red Hat to cover your a-- (oops!) head.

Linux with RPM

You are here: irt.org | Articles | Linux & Apache | Linux with RPM [ previous next ]

Published on: Saturday 23rd January 1999 By: Pankaj Kamthan

What Is Linux?

Linux is a full-featured POSIX-compliant UNIX-like operating system. It has gained popularity in recent years owing to many reasons, two major ones being: its support for Intel-based PCs since its inception and a myriad of free software that is available for it. It has been observed that Linux has proved to be a viable alternative to Microsoft Windows NT in many respects. Linux's widespread use has even lead Sun Microsystems (makers of the widely-used SunOS and Solaris family of UNIX-derivatives) to support its implementation for their UltraSPARC-based platforms.

Linux is a large system. Installing it on your computer, and getting it up and running can be an arduous task. This process is simplified by the presence of many vendors who provide Linux distributions at a modest price. These distributions, particularly that from Red Hat Software, provide a menu where the user can pick-and-choose the features and applications he/she wishes to install, with recommendations for default settings.

Manage Your Packages, Or They Will Manage You

Installing the operating system and relevant applications, and getting them to work is just the beginning. One of the most challenging tasks thereafter is the further maintenance of both system and application software. However, not all computer users are (and/or intend to be) systems administrators. Also, unlike commercial UNIX flavours, there is a lack of support for personal users. This is where the requirement for a robust, efficient and easy-to-use software management system becomes important.

A package, roughly speaking, is an entity which keeps related objects together in the same place. Viewing a software as a package makes the system manageable, portable and, most importantly, it contains knowledge about what it takes to install (and uninstall) itself on your computer. A package management system takes all the files containing programs, data, documentation and configuration information and places them in one formatted file - package file. For example, in RPM package management system, the file is called a ".rpm file" or just RPM. In addition to putting together certain components to form a package, a package management system also keeps track of which packages are installed, and their dependencies on other packages which may be necessary for installation or operation, etc.

One tool that has met the expectations of package management to a large extent is the RPM from Red Hat Software. (It is one of the primary reasons that has made the company standout among its competitors and for its major success as a Linux distributor).

What Is The RPM?

RPM is an open packaging system that is available for anyone to use. It works on all Linux as well as currently on various other UNIX flavours: IRIX, Solaris, SunOS, AIX, HP/UX, AmigaOS, and FreeBSD. (There is a frequently updated listing of platforms on which RPM is known to run.) It is distributable under the terms of the GNU Public License (GPL). RPM provides the base for a very extensive system and is quickly becoming the de-facto packaging standard for free software on the Internet. For a historical tour of RPM, see Section 1.2.1 of the book Maximum RPM.

Advantages Of The RPM

For the end-users, RPM provides many features that make maintaining a system far easier than it has ever been previously. In the UNIX world, it has been (and still is) customary to use .tar.gz files for installing software; a method in which it is easy to lose customizations of configuration files. From a developer's viewpoint, it allows you to take source code for new software and package it into source and binary form for end users. This process is simple, and involves a single file and optional patches that you create.

The various advantages that RPM offers stem directly from its design goals:

Pristine Sources

RPM is designed to allow the use of "pristine" software sources, as distributed by the original authors of the software. With RPM, you have the pristine sources along with any patches that were used to compile from. This is a big advantage for several reasons. For one, if a new version of a software is released, you don't necessarily have to start from scratch to get it to compile; you can look at the patch to see what you might need to do. All the compile-in defaults and all of the changes that were made to get the software to build, are easily visible this way.

Querying

RPM is designed to have powerful querying options. You can search through your entire database for packages or just certain files. You can also easily find out what package a file belongs to and where it came from. The RPM files themselves are compressed archives, with a custom binary header added to the package (in uncompressed form) containing useful information about the package and its contents. This allows you to query individual packages easily and quickly.

Upgradability

Software development is an evolutionary process and new releases of operating systems are announced from time to time. When you obtain a new release of an operating system based on RPM, you don't need to reinstall it on your computer. With RPM, you can upgrade individual components of your system without completely reinstalling it. Configuration files that you had in packages are preserved during the process of upgrade, so you won't lose your customizations.

Verification

Another powerful feature of RPM is the ability to verify packages. For example, if you deleted an important file for some package, all you need to do is just verify it. You will be notified of any anomalies. At that point, you can reinstall the package, if necessary. Any configuration files that you had are preserved during the process of reinstallation so you won't lose your customizations.

Obtaining And Installing RPM

RPM Requirements

The main requirement to run RPM is cpio 2.4.2 or greater. As mentioned above, RPM is intended for use with Linux, as well as various other Unix systems. However, the binary packages generated on a different type of UNIX system will not be compatible.

To build RPMs from source, you also need everything normally required to build a package, like gcc, make, etc.

Obtaining RPM

One way to get RPM is to install the Red Hat Linux. If you don't want to do that, you can still get and use RPM. It can be obtained from any of the RPM mirrors on the WWW or from RPM FTP site.

RPM Scenarios

RPM has five basic modes of operation (excluding package building): installing, uninstalling, upgrading, querying and verifying. Most applications of RPM are a consequence of these operations.

Installing Packages

RPM packages typically have file names like rpm -i foobar-1.0-1.i386.rpm which includes :

Installing is as simple as executing the following command:

rpm -ivh foobar-1.0-1.i386.rpm

You can also install packages via FTP. If you are connected to the Internet and want to install a new package, all you need to do is specify the file with the appropriate URL:

rpm -i ftp://ftp.somedomain.com/pub/linux/RPMS/foobar-1.0-1.i386.rpm

This uses anonymous FTP. For a username/password FTP you can do:

rpm -i ftp://username@ftp://ftp.somedomain.com/pub/linux/RPMS/foobar-1.0-1.i386.rpm

You will then be prompted for a password. After entering the password, RPM installs the package.

If the package is already installed, or if you try installing a package that contains a file that has already been installed by another package, or if you try to install a package for which there is an unresolved dependency (dependence on another package which is a prerequisite and is not installed), you get errors that can easily be resolved/overridden by using appropriate options. This makes the process of installation quite failsafe.

rpm2html And rpmfind

rpm2html is a script that automatically generates HTML pages describing a set of RPM packages.  It identifies the dependencies between various packages and finds the package(s) providing the resources needed to install a given package. Every package is analyzed to retrieve its dependencies and the resources it offers. These relationships are then indexed and expressed using hyperlinks in the generated pages. Most of the pages listing a set of RPMs also provide a colormap in the header to help localize the packages pertaining to a given distribution/architecture.

The official WWW site for rpm2html generated RPM repository is rufus. There are various mirror sites which make it convenient for users in different locations around the world.

rpmfind goes a step further, and is a program that will find RPM files on rufus for you. For example, rpmfind emacs will tell you what packages are needed to install Emacs on your platform, where to find them, and how much space it will take on your hard drive (so that you can also estimate the download time), and can fetch the required files for you. rpmfind can also be used to query the RPM database for existing packages using a keyword or a regular expression.

Uninstalling Packages

To uninstall a package you execute a simple command:

rpm -e foobar

Upgrading Packages

Upgrading is similar to installing:

rpm -Uvh foobar-2.0-1.i386.rpm

which includes uninstallation of any previous versions of the foo package. If your changes to the configuration file are not "forward" compatible with the new configuration file in the package, RPM saves your original file and installs the new one. The error diagnostics in this case are similar to that of installing/uninstalling a package though it also warns you if you try to upgrade to a package with an older version number.

Querying Packages

You can query a database of installed packages by the command rpm -q. For example,

rpm -q foo

prints out the package name, version, and the release number of the package foo. There are many other options which can:

Verifying Packages

By verifying we mean comparing the information about the files installed from a package to the original package. Verification entails comparing the MD5 checksum, device, size, modification time, symbolic link, permissions, file type, owner, and group of each file.

You can verify a package by the command rpm -V. For example,

rpm -V foo

verifies that all the files in the foo package are as they were when they were originally installed. There are certain Package Selection Options (similar to Package Specification Options) which can specify the packages you wish to verify: verify all currently installed packages, verify a package against an RPM package, and verify a package owning a file.

A simple application of verification is file recovery. Suppose you deleted some files by accident, but you aren't sure of what you deleted. You can verify your entire file system and see what might be missing by executing:

rpm -Va

In general, RPM can be used in a variety of ways as seen from the Usage message:

RPM version 2.3.9
Copyright (C) 1997 - Red Hat Software
This may be freely redistributed under the terms of the GNU Public License

usage: rpm {--help}
       rpm {--version}
       rpm {--initdb}   [--dbpath <dir>]
       rpm {--install -i} [-v] [--hash -h] [--percent] [--force] [--test]
                        [--replacepkgs] [--replacefiles] [--root <dir>]
                        [--excludedocs] [--includedocs] [--noscripts]
                        [--rcfile <file>] [--ignorearch] [--dbpath <dir>]
                        [--prefix <dir>] [--ignoreos] [--nodeps]
                        [--ftpproxy <host>] [--ftpport <port>]
                        file1.rpm ... fileN.rpm
       rpm {--upgrade -U} [-v] [--hash -h] [--percent] [--force] [--test]
                        [--oldpackage] [--root <dir>] [--noscripts]
                        [--excludedocs] [--includedocs] [--rcfile <file>]
                        [--ignorearch]  [--dbpath <dir>] [--prefix <dir>] 
                        [--ftpproxy <host>] [--ftpport <port>]
                        [--ignoreos] [--nodeps] file1.rpm ... fileN.rpm
       rpm {--query -q} [-afpg] [-i] [-l] [-s] [-d] [-c] [-v] [-R]
                        [--scripts] [--root <dir>] [--rcfile <file>]
                        [--whatprovides] [--whatrequires] [--requires]
                        [--ftpuseport] [--ftpproxy <host>] [--ftpport <port>]
                        [--provides] [--dump] [--dbpath <dir>] [targets]
       rpm {--verify -V -y} [-afpg] [--root <dir>] [--rcfile <file>]
                        [--dbpath <dir>] [--nodeps] [--nofiles] [--noscripts]
                        [--nomd5] [targets]
       rpm {--setperms} [-afpg] [target]
       rpm {--setugids} [-afpg] [target]
       rpm {--erase -e} [--root <dir>] [--noscripts] [--rcfile <file>]
                        [--dbpath <dir>] [--nodeps] [--allmatches]
                        package1 ... packageN
       rpm {-b|t}[plciba] [-v] [--short-circuit] [--clean] [--rcfile  <file>]
                        [--sign] [--test] [--timecheck <s>] specfile
       rpm {--rebuild} [--rcfile <file>] [-v] source1.rpm ... sourceN.rpm
       rpm {--recompile} [--rcfile <file>] [-v] source1.rpm ... sourceN.rpm
       rpm {--resign} [--rcfile <file>] package1 package2 ... packageN
       rpm {--addsign} [--rcfile <file>] package1 package2 ... packageN
       rpm {--checksig -K} [--nopgp] [--nomd5] [--rcfile <file>]
                           package1 ... packageN
       rpm {--rebuilddb} [--rcfile <file>] [--dbpath <dir>]
       rpm {--querytags}

As you can see, RPM has several options. You can find more details on what those options do in the RPM man page.

Building Your Own RPM

Building RPMs is fairly straightforward, especially if you can get the software you are trying to package to build on its own. Under normal operation, RPM builds both binary and source packages. We will not discuss in detail how to build packages with RPM; interested users can refer to Part II of the book Maximum RPM. Some programming experience and basic familiarity with the UNIX file system is required to understand the building process.

RPM can also be used to build packages for multiple architectures/operating systems: Intel i386, the Digital Alpha running Linux, Sparc, SGI's and HPs. There are several features that make building packages on all platforms easy. Using RPM to make multi-architectural packages is usually easier to do than getting the package itself to build in both places. The best help when you get stuck building an RPM is to look a similar source package.

Once you have made your own RPM of some software (that is freely distributable), you can contribute your work to others (after you have well-tested it and checked that it has not already been RPM'ed) by uploading it to ftp.redhat.com.

Conclusion

The task of managing systems or application software, whether it's a beginning user or an experienced systems administrator, is always painstaking. Many routine jobs in this endeavour can be greatly simplified with enormous efficiency by using a software management system such as RPM. It comes as no surprise that there are more than 30, 000 RPMs in existence today for a variety of operating systems/platforms, and growing.

I hope you will find the use of RPM beneficial. May be, some day you might even write one for your own favorite software.

A more appropriate title for this article might have been

Ladies and Gentlemen, Start your engines ... It's time for Linux with Maximum RPM

but I'll digress.

References

GENERAL

RPM SOURCE CODE/BINARIES

DOCUMENTATION

MAILING LISTS

Related items

Made to Measure : Apache Web Server Customization

Apache at your Web Service

Jump Start your Intranet Web Sites - Setting up Virtual Hosts on Apache

Linux #6 Stairway to Heaven? - Setting up your Linux Server as an Internet Gateway!

Linux #5 What's in a name? - Domain Name Server on Linux

Linux #4 "Setting up DHCP is not P2C2E"

Linux #3 "You teach best...."

Linux#2 Net Connection

Linux#1 A Red Hat to cover your a-- (oops!) head.

View the profile on Pankaj Kamthan and the list of other Articles by Pankaj Kamthan.

©2013 Martin Webb