Installing and Upgrading, Simplified

Installations and upgrades form the essence of managing RPM packages. When you install an RPM, you re adding new software to your system. When you re upgrading an RPM, you re updating the associated software with the latest features.

Before you install or upgrade an RPM, you should know whether the desired package is already on your system. The RPM query can also give you descriptive information about the package, and verify and list the files associated with the package.

You can install or upgrade RPMs from local or remote sources. There are provisions to include username/password combinations when you access a binary RPM from a remote location.

RPM packages include dependency information. For example, the kernel source code RPM needs the GNU C language compiler. Since the kernel source is dependent, you should install the compiler before installing the source code.

If you re looking for a specific file, install the standard Red Hat Linux database of RPMs. This can help you identify packages that you might need to install.

Queries

The query mode of the rpm command has many dimensions. In its simplest form, you can run this command to find the version of an installed package. With additional switches, you can use it to view summary information, list the files, verify the contents, and more.

A Simple Query

The simplest query takes the form of rpm -q packagename . For example, you can locate the installed version of the setup RPM, which contains a number of basic configuration files. Just run the following command:

 #  rpm -q setup  setup-2.5.25-1 

Information Queries

Queries can provide more information about a package. For example, the rpm -qi packagename command helps you get the summary information associated with the setup RPM. The output, as shown in Figure 10.1, can reveal a lot of good information about a specific package.

Identifying the Owner

Suppose you ve heard that upgrades are available for a certain file but you don t know what RPM package to use. In this case, just use the rpm -qf filename command to identify the name of the package. For example, if you need to identify the RPM package that owns the /etc/passwd configuration file, run the following command:

 #  rpm -qf /etc/passwd  setup-2.5.25-1 

Note that you need the full path to the file in question.

click to expand
Figure 10.1: An RPM package summary information

Listing the Files in an RPM

If you re not sure about a package, you can list the files within by using the rpm -ql packagename command. That list confirms whether certain configuration files or commands are part of that package. If you re upgrading, that information can help you understand what is at risk when you upgrade. Listing the files in the setup RPM provides a good example, as shown in Figure 10.2.


Figure 10.2: A list of files in an RPM package
Tip  

Package upgrades are always a risk. If you ve configured a daemon and then overwrite it with an upgrade, you may lose your custom configuration. While RPM is supposed to save configuration files with the .rpm* extension, it is still a good practice to back up key configuration files. In some cases, installing two versions of the same package is safer than upgrading. You ll see an example of where this is true when you upgrade the Linux kernel in Chapter 12 .

RPMs and CPUs

Many RPMs are built for specific CPUs. For example, many RPMs have an extension such as .i386.rpm or .noarch.rpm . While Red Hat Linux 9 can t be installed on computers with Intel 386 “level CPUs, RPMs with the .i386.rpm extension can be installed on all Red Hat Linux computers with Intel-compatible Pentium-level CPUs.

RPMs with other extensions are optimized for their CPUs. When possible, you should install the RPM associated with your CPU. To find your CPU identifier, type the uname -p command. Table 10.1 shows several optional extensions.

Table 10.1: RPM Extensions

Extension

CPU

noarch.rpm

Does not depend on the CPU; can be installed on all computers.

i386.rpm

Based on the Intel 386 CPU, these RPM packages can be installed on all Intel-compatible computers.

i486.rpm

For computers with the Intel 486 CPU (now obsolete).

i586.rpm

For computers with the Intel 586 CPU.

i686.rpm

For computers with the Intel 686 CPU.

ia64.rpm

For computers with the Intel Itanium 64-bit CPU.

alpha.rpm

For computers with the HP Alpha CPU, originally developed by the former Digital Equipment Corporation.

athlon.rpm

Based on the AMD Athlon CPU.

ppc.rpm

For computers with the Apple PowerPC CPU.

s390.rpm

For IBM servers based on the S/390 CPU.

sparc.rpm

For computers with the Sun Microsystems SPARC CPU.

The Basic Installation

Installing a new RPM package is simple. Just use the rpm -i packagename-versionnumber command, and if that package is not already on your system, it is automatically installed. Normally, you ll be

installing new RPMs from a source such as the Red Hat Linux installation CDs, mounted on /mnt/ cdrom . Once the source is mounted, you might run the following command to install the setup RPM package:

 # rpm -i /mnt/cdrom/RedHat/RPMS/setup-* 

The asterisk is an appropriate wildcard, because RPM packages are updated frequently but the actual name of the package usually remains constant. If multiple packages start with setup-* , this command installs all of them.

If you have a favorite online source for RPM packages, you can install them directly from the source. For example, if you want to install the lynx RPM package from the RedHat/RPMS directory on a server named abcd, run the following command:

 # rpm -ivh ftp://abcd/RedHat/RPMS/lynx-* 

As the -i extension installs, the -v and -h extensions set up verbose output with hashing, so you can monitor the progress of the installation. Some FTP servers require usernames and passwords. If you were installing the lynx RPM package, with a username of anonymous and a password of efgh, you could use the following command:

 #  rpm -ivh ftp://anonymous@ftp.redhat.com/pub/redhat/linux/rawhide/i386/RPMS/  ?lynx-* Password for anonymous@ftp.redhat.com: 

The password that you enter at the prompt is not shown on the screen. While you could add the password to the rpm command, it isn t advisable, since the password would appear on your screen and be transmitted in clear text over the Internet.

You can even use this command to install the latest version of multiple packages. But this command often does not work over the Internet; if you want to install a package reliably, download it first. The Rawhide packages discussed near the end of this chapter are the latest packages available from Red Hat.

Note  

When Red Hat develops a later version of an RPM package, it stores it in Rawhide. You can find these packages on the Red Hat FTP server (and mirror sites). As of this writing, they re stored in the /pub/redhat/linux/rawhide/ cputype/RedHat/RPMS directory, where cputype represents the CPU for your system, such as i386 or sparc .

Upgrades

There are always risks associated with upgrades. You may accidentally overwrite configuration files that you ve customized for your computer and/or your network. Or perhaps the upgraded software has interaction problems with other applications installed on your system.

However, there are often good reasons to upgrade an RPM package. Sometimes, you or your users need updated features. You may be upgrading software to address a security alert. Or you may need upgraded software (such as compilers) to handle upgraded versions of other new packages, such as kernels .

Two switches are associated with upgrades: -U and -F . Both switches can upgrade an RPM package. The difference is what happens if there is no installed RPM package to upgrade. In that case, the rpm -U packagename command installs the new package, and the rpm -F packagename command does not.

Generally, it is a good practice to include the -v (verbose) and the -h (hash mark) switches whenever you upgrade or freshen an RPM package. For example, if you re upgrading an installed version of the lynx RPM from a mounted CD, the following command can help you monitor the progress of the installation (with hash marks), as well as any error messages that might appear:

 # rpm -Uvh /mnt/cdrom/RedHat/RPMS/lynx-* 

Dependencies

When you try to install or upgrade an RPM, you may get an error message. Perhaps the most common rpm error message is based on dependencies.

An RPM dependency occurs when one package will not work unless a different package is already installed. The source code for the package lists other RPM packages that it needs ”in other words, packages that it depends upon. You can see an example of a dependency from when I tried to install the kernel-source RPM:

 #  rpm -Uvh /mnt/cdrom/RedHat/RPMS/kernel-source-*  warning: /mnt/cdrom/RedHat/RPMS/ kernel-source-2.4.20-11.i386.rpm: Header V3 DSA ? signature: NOKEY, key ID 89da07a error: Failed dependencies:   gcc >= 2.96-98 is needed by kernel-source-2.4.20-11 Suggested resolutions:   gcc-3.2.2-5.i386.rpm 

The output suggests that I need to install the gcc (GNU C Compiler) package first. You could install both packages simultaneously , or install gcc first. If this seems like a lot of trouble, you could also use the rpm --nodeps switch to ignore the dependency. As long as you install gcc before you actually use the kernel-source package, this should not be a problem. One way to do that is with the following commands:

 # rpm -Uvh --nodeps /mnt/cdrom/RedHat/RPMS/kernel-source-* # rpm -Uvh /mnt/cdrom/RedHat/RPMS/gcc-3* 

Deletions

It s easy to delete an RPM package by using the -e switch. You don t even have to know the version number of the package. For example, the following command deletes the kernel-source RPM:

 # rpm -e kernel-source 

Since you do not need to cite the path to delete an RPM, it is easy to delete multiple packages with the same command:

 # rpm -e kernel-source gcc 

A Database of RPMs

Say you re looking for a file or a command, and discover that it isn t yet installed on your computer. You know that Red Hat Linux files are organized by RPM packages. In some cases, it isn t too difficult to figure out the right RPM to install; for example, commands such as smbclient are part of the samba-client-* RPM package. However, if you re looking for the RPM associated with some obscure program library, finding the right package can be more difficult.

This is where the Red Hat Linux database can help. Once installed, the rpmdb-redhat-* RPM can help you find the RPM package associated with every file that you can install in the current version of Red Hat Linux.

As an example, if you re looking for the package associated with /etc/exports , the following command will work, once the rpmdb-redhat-* RPM package is installed:

 #  rpm --redhatprovides /etc/exports  setup-  versionnumber  
 


Mastering Red Hat Linux 9
Building Tablet PC Applications (Pro-Developer)
ISBN: 078214179X
EAN: 2147483647
Year: 2005
Pages: 220

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