5.2. Installing and Removing Software Using RPMIn addition to queries, rpm performs package installation, updating, and removal. As well as copying files to the correct locations (or deleting them), rpm checks file integrity, sets permissions, backs up configuration files, and executes scripts within the affected package and other packages that have asked to be notified of changes (trigger scripts). These scripts can in turn start or stop services, modify configuration files, or perform other operations. 5.2.1. How Do I Do That?rpm provides four options for installing, upgrading, and removing software: 
 All of these operations must be performed as the root user (unlike queries, which may be performed by anyone). This prevents unwanted software, such as viruses and worms, from being installed in the normal course of activities. To perform a basic installation of a package, use the -i option and supply the name of a package file: # rpm -i httpd-2.0.54-10.i386.rpm To upgrade the package: # rpm -U httpd-2.0.62-3.i386.rpm In this case, the upgrade would succeed even if httpd package weren't already present on the system; it would be installed. # rpm -e httpd Note that in this case, only the package name is given, not a package filename. No additional arguments are needed if the installation or removal does not affect any other packages, but frequently a package to be installed will depend on other packages: # rpm -i ogle-0.9.2-1.1.fr.i386.rpm
error: Failed dependencies:
        libdvdread >= 0.9.4 is needed by ogle-0.9.2-1.1.fr.i386
        libdvdread.so.3 is needed by ogle-0.9.2-1.1.fr.i386
        libmad.so.0 is needed by ogle-0.9.2-1.1.fr.i386Likewise, when removing a package, other packages can depend on that package: # rpm -e httpd
error: Failed dependencies:
        httpd-mmn = 20020903 is needed by (installed) mod_auth_kerb-5.0-6.i386
        httpd-mmn = 20020903 is needed by (installed) mod_auth_mysql-2.6.1-4.i386
...(Lines snipped)...
        httpd = 2.0.54-10.2 is needed by (installed) mod_ssl-2.0.54-10.2.i386
        httpd is needed by (installed) squirrelmail-1.4.6-0.cvs20050812.1.fc4.noarchThe solution is to add or remove all of the needed packages at the same time ( \ indicates that the line is continued): # rpm -i a52dec-0.7.4-4.fr.i386.rpm libdvdcss-1.2.8-2.fr.i386.rpm \ libdvdread-0.9.4-4.fr.i386.rpm libmad-0.15.0b-3.fr.i386.rpm \ ogle-0.9.2-1.1.fr.i386.rpm ogle_gui-0.9.2-1.1.fr.i386.rpm However, each of the other package may have other dependencies, which is why repositories are so helpful (see Lab 5.3, "Using Repositories"). Table 5-3 outlines the most common options used when installing or upgrading packages. 
 This command installs httpd (Apache) without documentation, using a verbose display with hash marks to show progress: # rpm -ivh --excludedocs httpd-2.0.54-10.i386.rpm Preparing... ########################################### [100%] 1:httpd ########################################### [100%] If you later decide that you want the documentation files after all, you can't simply reinstall httpd: # rpm -ivh httpd-2.0.54-10.i386.rpm
Preparing...                ########################################### [100%]
        package httpd-2.0.54-10 is already installedBut if you add the --force option, the reinstallation will be successful: # rpm -ivh --force httpd-2.0.54-10.i386.rpm Preparing... ########################################### [100%] 1:httpd ########################################### [100%] The httpd package normally places the DocumentRoot (start of the HTML document tree) in /var/www; to change this to /usr/share/html, use the --relocate option: # rpm -ivh --force --relocate /var/www=/usr/share/html/ httpd-2.0.54-10.i386.rpm Preparing... ########################################### [100%] 1:httpd ########################################### [100%] The change is recorded in the RPM database, so querying the database will show the actual, installed paths: # rpm -ql httpd /etc/httpd /etc/httpd/conf /etc/httpd/conf.d /etc/httpd/conf.d/README /etc/httpd/conf.d/welcome.conf ...(Many lines snipped)... /usr/share/html/icons/world1.png /usr/share/html/icons/world2.gif /usr/share/html/icons/world2.png 
 The options for erasing software are a subset of the options for installing and upgrading; the most useful options are listed in Table 5-4. 
 5.2.2. How Does It Work?RPMs are named using the pattern: 
               name-version-packagerelease.arch.rpmin which: 
 rpm goes through many steps when performing an installation or upgrade/freshen: 
 There are four opportunities for scripts to run. This permits configuration files to be backed up before new packages are installed, services to be stopped before upgrading and restarted after, and configuration data to be copied from the old to the new package. There are also three opportunities for trigger scripts to run. Each RPM operation is called a transaction. All of the packages processed in one operation are called a transaction set; this may include a large number of packages. For example, an update transaction could include dozens of packages processed at one time. In the RPM database, a transaction set identifier (TID) is used to tie together all of the packages processed in the same transaction set. The TID currently used is the time in seconds since the start of the 1970s (called a utime). 5.2.3. What About...5.2.3.1. ...installing multiple versions of a package?It's possible, but it can create a lot of problems. The --force option is required, and it's probably best to relocate the second installation to avoid file conflicts: # rpm -q httpd httpd-2.0.54-10.2 # rpm -i --force httpd-2.0.54-10.i386.rpm \ --relocate /=/var/compare/httpd-old # rpm -q httpd httpd-2.0.54-10.2 httpd-2.0.54-10 This will install the old version of httpd into /var/compare/httpd-old so that you can compare that installation with the current one. To remove the packages, you'll either need to specify the full package name including the software and package version numbers (e.g., httpd-2.0.54-10 instead of httpd) to delete one specific version, or use the --allmatches option to remove all versions: # rpm -e httpd error: "httpd" specifies multiple packages # rpm -e --allmatches httpd 5.2.4. Where Can I Learn More?
  |