rpm. Of course, this isn’t required, but just about every RPM package is stored in a file with a rpm extension. For example, the following file holds an RPM package, ready to be installed:
jikes-1.16-1.i386.rpm
jikes (a Java language compiler application). From the discussion in the last two chapters, you should be able to determine the version of the program this RPM holds and which release of the RPM package this represents.
jikes-1.16-1.src.rpm
src in the package name is short for source. This file-naming convention is not required, but is used by just about all source code packages. (Following conventions helps other administrators know what to expect.)
Building Packages from Source RPMs
rpmbuild for information on building RPMs from source RPMs.
rpm command provides three main operations for upgrading and installing packages:
rpm commandrpm command with the –U option, short for upgrade, as introduced in Chapter 2, RPM Overview . The basic syntax is:
rpm -U package_name
rpm –i jikes-1.16-1.i386.rpm
--upgrade long option in place of -U.
rpm command, covered shortly, present positive feedback that the package has been installed.
rpm command may print out warnings, such as the one following:
warning: pyxf86config-0.3.1-2.i386.rpm: Header V3 DSA signature: NOKEY, key ID 897da07arpmbuild covers signing packages. In most cases, warnings such as this one are not that serious. Errors, though, should be treated seriously.
root Permissions
root, or super user, permissions. That’s because most Linux application RPMs hold files that must be installed in a protected directory such as /usr/bin/. In addition, RPM requires root access to modify the RPM database. Even if you could modify the system directories like /usr/bin/, you must also be able to modify the RPM database to successfully install or remove packages.
rpm –q command to quickly verify a package has been installed. To verify, you need to use the name of the installed package, not the name of the RPM file. You can also use a partial package name, such as jikes in this case. For example:
rpm –q jikes
jikes-1.16-1jikes-1.16-1 has been installed. This package name corresponds to the RPM file used in the preceding installation example.
rpm -q command just asks the RPM database if the package has been installed. There may be other issues with the package that this command won’t show. For now, though, the rpm –q command verifies that package has been installed.
package jikes is not installed-h option to the rpm command prints out # signs, also called hash marks (hence the -h). These hash marks provide some confirmation that the rpm command is still running. This is important, since large packages may take a long time to install or upgrade. Run this command like the following:
rpm -Uh jikes-1.16-1.i386.rpm
########################################### [100%] ########################################### [100%]
########################################### [100%] warning: user cabbey does not exist - using root warning: user cabbey does not exist - using root warning: user cabbey does not exist - using root ########################################### [100%]Reinstalling Packages
rpm command won't complain. The upgrade operation, though, will remove all other versions of a package. This is one more reason to use the –U upgrade option.
rpm command. The -v option to the rpm command tells the command to print out verbose information as the command runs. Remember, though, that verbose is used in the traditional Unix and Linux meaning, which is normally not all that verbose. In the Unix/Linux context, verbose usually means slightly more than nothing. The syntax for the command follows:
rpm -Uhv jikes-1.16-1.i386.rpm-v command-line option, you will see output more like the following:
Preparing... ########################################### [100%] 1:jikes ########################################### [100%]Standard Command for Package Installation
rpm -Uhv package_file.rpm. That is, upgrade with verbose output and hashes.
-vv command-line option. Think of this as doubly verbose. Usually, though, this extra information has no meaning unless you are debugging an RPM package that you are building. See the chapters in Part II on Creating RPMs for more on how to build RPM packages.
rpm -Uhvv jikes-1.16-1.i386.rpm
D: ============== jikes-1.16-1.i386.rpm D: Expected size: 702988 = lead(96)+sigs(100)+pad(4)+data(702788) D: Actual size: 702988 D: jikes-1.16-1.i386.rpm: MD5 digest: OK (2dba32192eca23eb480d1d02a9b6c022) D: added binary package [0] D: found 0 source and 1 binary packages D: opening db environment /var/lib/rpm/Packages joinenv D: opening db index /var/lib/rpm/Packages rdonly mode=0x0 D: locked db index /var/lib/rpm/Packages D: ========== +++ jikes-1.16-1 D: opening db index /var/lib/rpm/Depends create mode=0x0 D: Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1 YES (rpmlib provides) D: opening db index /var/lib/rpm/Providename rdonly mode=0x0 D: opening db index /var/lib/rpm/Pubkeys rdonly mode=0x0 D: read h# 9 Header V3 DSA signature: NOKEY, key ID 897da07a D: Requires: ld-linux.so.2 YES (db provides) D: read h# 9 Header V3 DSA signature: NOKEY, key ID 897da07a D: Requires: libc.so.6 YES (db provides) D: read h# 9 Header V3 DSA signature: NOKEY, key ID 897da07a D: Requires: libm.so.6 YES (db provides) D: read h# 633 Header V3 DSA signature: NOKEY, key ID 897da07a D: Requires: libstdc++-libc6.2-2.so.3 YES (db provides) D: read h# 9 Header V3 DSA signature: NOKEY, key ID 897da07a D: Requires: libc.so.6(GLIBC_2.0) YES (db provides) D: read h# 9 Header V3 DSA signature: NOKEY, key ID 897da07a D: Requires: libc.so.6(GLIBC_2.1) YES (db provides) D: read h# 9 Header V3 DSA signature: NOKEY, key ID 897da07a D: Requires: libc.so.6(GLIBC_2.1.3) YES (db provides) D: Requires: rpmlib(CompressedFileNames) <= 3.0.4-1 YES (rpmlib provides) D: closed db index /var/lib/rpm/Pubkeys D: closed db index /var/lib/rpm/Depends D: closed db index /var/lib/rpm/Providename D: closed db index /var/lib/rpm/Packages D: closed db environment /var/lib/rpm/Packages D: ========== recording tsort relations D: ========== tsorting packages (order, #predecessors, #succesors, tree, depth)D: 0 0 0 0 0 +jikes-1.16-1 D: installing binary packages D: opening db environment /var/lib/rpm/Packages joinenv D: opening db index /var/lib/rpm/Packages create mode=0x42 D: getting list of mounted filesystems D: sanity checking 1 elements D: opening db index /var/lib/rpm/Name create mode=0x42 D: read h# 707 Header sanity check: OK D: computing 3 file fingerprints Preparing... D: computing file dispositions D: opening db index /var/lib/rpm/Basenames create mode=0x42 ########################################### [100%] package jikes-1.16-1 is already installed D: closed db index /var/lib/rpm/Basenames D: closed db index /var/lib/rpm/Name D: closed db index /var/lib/rpm/Packages D: closed db environment /var/lib/rpm/PackagesShort and Long Options
rpm -U, many programs use two minus signs to indicate longer option names. For example, with the rpm command, -U and --upgrade are treated the same. You can use the short option, -U, or the long option, --upgrade.
--percent. The --percent option prints out decimal numbers that show the percentage completed as the rpm command executes. This option is most useful if you wrap the rpm command within some other command, such as a graphical user interface created from a Perl, Python, or Tcl/Tk script.
rpm -U --percent jikes-1.16-1.i386.rpm
%% 0.000000 %% 2.661902 %% 5.318614 %% 10.632039 %% 15.945465 %% 18.602177 %% 23.915603 %% 29.229028 %% 34.542453 %% 39.855879 %% 45.169304 %% 50.482729 %% 53.139442 %% 55.796154 %% 61.109580 %% 66.423005 %% 71.736430 %% 74.393143 %% 79.706568 %% 82.363281 %% 87.676706 %% 90.333419 %% 95.646844 %% 98.303557 %% 99.422736 %% 99.910411 %% 99.994892 %% 100.000000--percent option are really meant to be input into another program, perhaps a program that shows a graphical progress meter. Each number output then updates the meter.
Percentages may be Approximate
rpm –U command or the rpm –i command to install a package. When the rpm command installs a package, it goes through a number of steps:
rpm checks that all the dependencies are installed. Dependencies are packages required by the RPM package you want to install. For example, a database-administration package for a particular database may require that the database itself was already installed.
rpm command checks for conflicting packages. For example, when you are trying to install an older version of a package on top of a newer version, running the rpm command alerts you to that conflict. This conflict-checking goes deeper than packages, though. Individual files may conflict if you are trying to install a package that has an older version of a particular file.
rpm command executes the preinstallation tasks (covered in depth in Part II). After all this preparatory work, the rpm command finally gets down to business and installs the files in the package. These files are stored in compressed format (compressed with gzip compression) inside the RPM file.
rpm command updates the RPM database to reflect the new package information. This update is very important and allows you to track packages.
--test command-line option tells the rpm command to test the installation or upgrade process but not to install the file. For example, the following command performs an upgrade or install of the jikes package, but in test mode only. No files will actually be installed.
rpm -U --test jikes-1.16-1.i386.rpm
package jikes-1.16-1 is already installed
chap4.txt: not an rpm package (or package manifest):eruby, such as eruby-devel-0.9.8-2.i386.rpm, will depend on a base ruby package.
ruby packages by using a command like the following:
rpm -q rubyruby package, you'll see a message like the following:
package ruby is not installedPackage Names
ruby.
--test option comes in handy, since you can check that the dependencies are resolved prior to trying to install. (Note that the rpm command will check dependencies on real installs as well. The --test option just allows you to check that the installation will succeed prior to trying it.) For example, if you try to install a package named eruby-devel-0.9.8-2.i386.rpm, you may want to run a --test option first:
rpm -U --test eruby-devel-0.9.8-2.i386.rpmruby packages installed:
error: Failed dependencies: eruby-libs = 0.9.8 is needed by eruby-devel-0.9.8-2eruby-devel-0.9.8-2.i386.rpm depends on another package, eruby-libs in this case. In fact, this package depends on the eruby-libs package having a version number of 0.9.8. These packages are obviously interrelated. From the name eruby-libs, you can guess that the package will be in a file with a name like eruby-libs-0.9.8-2.i386.rpm. (I cheated and used the actual package on the Red Hat installation CDs.)
eruby-devel-0.9.8-2.i386.rpm
eruby-libs-0.9.8-2.i386.rpm
eruby-devel-0.9.8-2.i386.rpm depends on: eruby-libs-0.9.8-2.i386.rpm. Just to be careful, though, you can test that package as well, with a command like the following:
rpm -U --test eruby-libs-0.9.8-2.i386.rpm
error: Failed dependencies: ruby-libs >= 1.6.4 is needed by eruby-libs-0.9.8-2 libruby.so.1.6 is needed by eruby-libs-0.9.8-2rpm command to install or upgrade one package at a time. You can optionally choose to install or upgrade a number of packages at the same time. Just list each file name on the rpm command line. The basic syntax follows:
rpm -U package1.rpm package2.rpm .. package100.rpm
rpm -U aspell-en-ca-0.33.7.1-16.i386.rpm aspell-en-gb-0.33.7.1-16.i386.rpmaspell packages for Canadian and British English, respectively.
--noorder option tells the rpm command not to reorder the packages you are trying to install. Usually, the rpm command will reorder the list of packages in the best order for handling the dependencies. This option really only comes into play when you are installing more than one package where the packages depend on each other. In most cases, you do not want to use this option, since this may mean that packages fail to properly install because necessary packages are not already installed.
--prefix and --relocate options should make the rpm command relocate a package to a new location. Not all packages allow relocations, though. The basic format of the command with the --prefix option is:
rpm -U --prefix /new/directory package.rpm--relocate option, the command format is:
rpm -i --relocate /old/directory=/new/directory package.rpm--root option to specify a different directory for the rpm command to assume is the system's root, or /, directory. This causes the rpm command to install files under the new root, instead of in system locations under /. This option is most useful for testing the installation of a complete system under a test directory. The command should use the following format:
rpm -U --root /tmp --dbpath /var/lib/rpm jikes-1.16-1.i386.rpm--root option tells the rpm command that the root for this install is in /tmp/. Installs with the --root option take place within a chroot() environment. This is often useful for setting up a test environment.
--dbpath option tells the rpm command that the RPM database is located in the normal location, /var/lib/rpm/.
--dbpath and --root options will give you problems unless you have installed all the dependencies in the same virtual root directory. This includes all the standard Linux C libraries. For example, if you just run the example command, you'll see error output like the following:
error: Failed dependencies: ld-linux.so.2 is needed by jikes-1.16-1 libc.so.6 is needed by jikes-1.16-1 libm.so.6 is needed by jikes-1.16-1 libstdc++-libc6.2-2.so.3 is needed by jikes-1.16-1 libc.so.6(GLIBC_2.0) is needed by jikes-1.16-1 libc.so.6(GLIBC_2.1) is needed by jikes-1.16-1 libc.so.6(GLIBC_2.1.3) is needed by jikes-1.16-1--badreloc option with the --relocate option to permit relocations on all files in the package. Usually, only those paths to files that are listed as relocatable are supported by the --relocate option.
rpm options cause the rpm command to complain about problems and, in general, fail to install your package. You can use a number of options to run roughshod over the RPM and get it to do what you want.
--replacepkgs option tells the rpm command to replace, or reinstall, packages it may have already installed.
--replacefiles option tells the rpm command to overwrite files owned by a another package.
--justdb option tells the rpm command to update the RPM database, not to install the files. You will need to be logged in as the root user to modify the RPM database.
--nosuggest option tells the rpm command to skip any suggestions for packages that may fill in missing dependencies. You almost never want to use this option.
--excludepath option tells the rpm command to exclude all files that start with the given path. For example:
rpm -U --excludepath /usr/lib eruby-devel-0.9.8-2.i386.rpm/usr/lib/.
--allfiles option tells the rpm command to install or upgrade all files in the package, regardless of whether the files exist or not on your hard disk.
--oldpackage tells the rpm command to allow you to install an older version of a package on top of a more recent one. You don't usually want to do this, but you may need to under the following circumstances:
--force, which tells the rpm command to turn on the --replacepkgs, --replacefiles, and --oldpackage modes.
--nodeps command-line option tells the rpm command to skip the dependencies check and install anyway.
Avoid Forcing Package Operations
rpm command complains with good reason. Unless you really, really know what you are doing, don't force the issue by using these command-line options.
eruby-devel-0.9.8-2.i386.rpm from the previous example. You can force the rpm command to install this package, even though it depends on another package that in turn depends on yet another. The following command will force the installation of the package in the eruby-devel-0.9.8-2.i386.rpm file:
rpm -U --nodeps eruby-devel-0.9.8-2.i386.rpm
rpm -q eruby-devel
eruby-devel-0.9.8-2rpm command not to do certain things, you can use the --aid option to have the rpm command do something nice for you. The --aid option tells the rpm command to add all the packages it would suggest into the set of packages to install. The rpm command has enough information to suggest a package or packages that ought to contain the dependent files.
--aid option depends on a separate package that contains an RPM database with all packages installed. For Red Hat Linux, this package is rpmdb-redhat. This separate database, built as if all packages were installed (all packages that come with Red Hat Linux in this case), allows the rpm command to search for which packages would solve dependencies.
rpm command should run. These include pre- and post-installation scripts, as well as pre- and post-uninstallation scripts. These scripts can perform options such as automatically configuring the application based on the target environment. For example, an installation script may try to detect whether a site uses Postfix or Sendmail for transferring mail messages and configure the newly-installed package accordingly.
rpm command will execute these scripts at the proper time, unless you explicitly turn the command to skip the scripts. The --noscripts option tells the rpm command to skip running the pre- and post-installation scripts.
--nopre option tells the rpm command to skip any pre-installation scripts. The --nopost option tells the rpm command to skip any post-installation scripts.
--nopreun option tells the rpm command to skip any pre-uninstallation scripts, and the --nopostun option tells the rpm command to skip any post-uninstallation scripts.
--noscripts option is the same as turning on all these options.
Table 3.1. Skipping scripts
| Option | Usage |
|---|---|
--nopre
|
Skip pre-installation scripts.
|
--nopost
|
Skip post-installation scripts.
|
--nopreun
|
Skip pre-uninstallation scripts.
|
--nopostun
|
Skip post-uninstallation scripts.
|
--noscripts
|
Skip all the scripts; same as
--nopre, --nopost, --nopreun, and --nopostun.
|
rpm command not to execute all the triggers or not to execute certain triggers. The --notriggers option tells the rpm command to skip all triggers.
--notriggers. The --notriggerin option turns off triggers during installation. The --notriggerun option turns off uninstallation triggers, and the --notriggerpostun option turns off the post-uninstallation triggers.
--notriggers option is the same as all three, --notriggerin, --notriggerun, and --notriggerpostun.
Table 3.2. Skipping Triggers
| Option | Usage |
|---|---|
--notriggerin
|
Skip installation triggers.
|
--notriggerun
|
Skip uninstallation triggers.
|
--notriggerpostun
|
Skip post-uninstallation triggers.
|
--notriggers
|
Skip all the triggers; same as
--notriggerin, --notriggerun, and --notriggerpostun.
|
rpm command supports several ignore options that tell the command to ignore some aspect of a package it would normally complain about.
--ignorearch option tells the rpm command to ignore the architecture of the package and install the package, even if the architecture of the package and the architecture of your system do not match. This is a very dangerous option. Linux runs on everything from tiny wristwatches, PDAs such as the Sharp Zaurus, PCs, Macintosh PCs, RISC servers, and all the way up to huge supercomputers and mainframes. If you try to install a binary package compiled for the ARM or PowerPC processor on an Intel-architecture Linux system, the package will at best fail. At worst, it may damage parts of your system.
--ignoreos command-line option tells the rpm command to ignore the operating system. Again, this is likely not a good idea in most situations. Applications compiled for Windows generally won’t run on Linux. SCO Unix systems, however, can run some Linux applications, so you may have a valid reason to ignore the operating system. Again, use only with extreme care.
--ignoresize option tells the rpm command to ignore or skip a check of your hard disk to ensure it has enough space to install the package.
Ignoring Storage Limits
--ignoresize option if you have a nearly full hard disk, especially for a root, or /, partition.
--nodigest option tells the rpm command to skip the test of the digest, the special value that helps verify the package correctness.
--nosignature option tells the rpm command to skip the test of the digest, the encrypted key, that helps also verify the package correctness.
Unsafe Options
rpm command-line options with extreme care and only after carefully considering the circumstances. Wrongful use of these options may damage your operating system.
--excludedocs command-line option tells the rpm command to ignore any files in the RPM package that are marked as documentation. Considering the general lack of documentation for many Linux applications, you are really asking for trouble by invoking this option. If the documentation takes up a lot of disk space, however, you may want to avoid installing documentation files. This is about the only situation in which this option makes sense.
--excludedocs, the --includedocs command-line parameter tells the rpm command to install documentation. This is usually the default, so you rarely need this option.