yum: Keeps the System Up-to-Date (FEDORA)


yum: Keeps the System Up-to-Date (FEDORA)

Early releases of Red Hat Linux did not include a tool for managing updates. Although the rpm utility could install or upgrade individual software packages, it was up to the user to locate a package and any packages it was dependent on. When Terra Soft produced its Red Hatbased Linux distribution for the PowerPC, the company created the Yellow Dog Updater to fill this gap. This program has since been ported to other architectures and distributions. The result, named Yellow Dog Updater, Modified (yum, linux.duke.edu/projects/yum), is included with Fedora Core.

rpm packages


The yum utility works with rpm packages. When yum installs or upgrades a software package, it also installs or upgrades packages that the package is dependent on. Refer to page 487 for more information on rpm.

Repositories


The yum utility downloads package headers and packages from servers called repositories. Although Fedora provides repositories, yum is set up to use copies of these repositories that are kept on mirror sites. The next section covers repository selection.

Configuring yum

You do not need to configure yum: As it is installed, it is ready to use. This section describes the yum configuration files for users who want to modify them. The primary configuration file, /etc/yum.conf, holds global settings. As distributed with Fedora, secondary files in the /etc/yum.repos.d directory define repositories. The first example shows the Fedora yum.conf file:

$ cat /etc/yum.conf [main] cachedir=/var/cache/yum keepcache=0 debuglevel=2 logfile=/var/log/yum.log pkgpolicy=newest distroverpkg=redhat-release tolerant=1 exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 metadata_expire=1800 # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d


The section labeled [main] defines global configuration options. The cachedir specifies the directory that yum will store downloaded packages in, although with keepcache set to 0, yum does not store headers and packages after installing them. The amount of information logged is specified by debuglevel, with a value of 10 producing the most information. The logfile specifies where yum keeps its log.

The pkgpolicy defines which version of a software package yum installs; set it to newest to install the most recent versions of packages. You can also configure yum to try to install from a specific server, falling back to other servers in case of failure. The yum utility uses distroverpkg to determine which version of the distribution the system is running. You should not need to change this setting.

With tolerant set to 1, yum corrects simple command line errors, such as attempting to install a package that is already present on the system; setting tolerant to 0 turns this feature off. Setting exactarch to 1 causes yum to update packages only with packages of the same architecture, thereby preventing an i686 package from replacing an i386 package, for example. You can use retries to specify the number of times yum will try to retrieve a file before returning an error (the default is 6). Set this parameter to 0 to cause yum to continue trying forever.

Setting obsoletes to 1 causes yum to replace obsolete packages when doing an update; it has no effect during an install. When gpgcheck is set to 1, yum checks the GPG (page 992) signatures on packages it installs. This check verifies the authenticity of the packages. Setting plugins to 1 enables yum plugins, which extend yum functionality. (See wiki.linux.duke.edu/YumPlugins and yum in section 8 of the man pages for more information on yum plugins.) The metadata_expire parameter specifies the number of seconds that yum uses the metadata it downloads from the repository about packages before it downloads the information again.

Although the balance of the yum configuration information, which specifies the yum repositories, can appear in the yum.conf file, Fedora Core puts information about each repository in a separate file in the /etc/yum.repos.d directory. A parameter set in a repository section overrides the same parameter set in the [main] section.

$ ls /etc/yum.repos.d fedora-core.repo                fedora-legacy.repo fedora-development.repo         fedora-updates.repo fedora-extras-development.repo  fedora-updates-testing.repo fedora-extras.repo


Each of these files contains a header, such as [core], which provides a unique name for the repository. The name of the file is generally similar to the repository name, with the addition of a fedora- prefix and a .repo filename extension. Commonly used repositories are core (held in the fedora-core.repo file), which contains the packages present on the installation CDs; updates (held in the fedora-updates.repo file), which contains updated versions of the stable packages; and updates-testing, which contains updates that are not ready for release. This last repository is not enabled; do not enable it unless you are testing unstable packages. Never enable this repository on a production system.

Optional

Each *.repo file includes specifications for several related repositories, which are usually disabled. For example, the fedora-core.repo file holds [core-debuginfo] and [core-source] in addition to [core]. You cannot download source files using yum. Use yumdownloader (page 482) for this task.


The next example shows part of the fedora-core.repo file that specifies the parameters for the core repository:

$ cat /etc/yum.repos.d/fedora-core.repo [core] name=Fedora Core $releasever - $basearch #baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/$releasever/$basearch/os/ mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-core-$releasever enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY


Repository specification


Each repository specification contains the name of the repository enclosed in brackets ([]), a name, a baseurl, and a mirrorlist. The name provides an informal name for the repository that yum displays. The baseurl indicates the location of the main repository; it is commented out by default. The mirrorlist specifies the URL of a file that holds a list of baseurls, or mirrors of the main repository. These definitions use two variables: yum sets $basearch to the architecture of the system and $releasever to the version of the release (such as 5 for Fedora Core 5).

The repository described by the file is enabled (yum will use it) if enabled is set to 1 and is disabled if enabled is set to 0. As described earlier, gpgcheck determines whether yum checks GPG signatures on files it downloads. The gpgkey specifies the location of the GPG key. Refer to the yum.conf man page for more options.

Using yum to Update, Install, and Remove Packages

Working as root, you can run yum from a command line. The behavior of yum depends on the options you specify. The update option, without additional parameters, updates all installed packages. It downloads package headers for installed packages, determines which packages need to be updated, prompts you to continue, and downloads and installs the updated packages.

Updating packages


In the following example, yum determines that two packages, gok and gedit, need to be updated. The yum utility searches the three enabled repositories: core, extras, and updates. Once it has determined what it needs to do, yum advises you of the action(s) it will take and prompts with Is this ok [y/N].

# yum update Loading "installonlyn" plugin Setting up Update Process Setting up repositories core                                                                 [1/3] extras                                                               [2/3] updates                                                              [3/3] Reading repository metadata in from local files Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Downloading header for gok to pack into transaction set. gok-1.0.7-1.i386.rpm      100% |=========================| 112 kB     00:01 ---> Package gok.i386 0:1.0.7-1 set to be updated ---> Downloading header for gedit to pack into transaction set. gedit-2.14.1-1.i386.rpm   100% |=========================|  62 kB     00:00 ---> Package gedit.i386 1:2.14.1-1 set to be updated --> Running transaction check Dependencies Resolved =============================================================================  Package                 Arch       Version          Repository        Size ============================================================================= Updating:  gedit                   i386       1:2.14.1-1       updates            3.2 M  gok                     i386       1.0.7-1          updates            1.5 M Transaction Summary ============================================================================= Install      0 Package(s) Update       2 Package(s) Remove       0 Package(s) Total download size: 4.7 M Is this ok [y/N]: y Downloading Packages: (1/2): gok-1.0.7-1.i386.r 100% |=========================| 1.5 MB     00:06 (2/2): gedit-2.14.1-1.i38 100% |=========================| 3.2 MB     00:14 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction   Updating  : gedit                         ######################### [1/4]   Updating  : gok                           ######################### [2/4]   Cleanup   : gok                           ######################### [3/4]   Cleanup   : gedit                         ######################### [4/4] Updated: gedit.i386 1:2.14.1-1 gok.i386 0:1.0.7-1 Complete!


Optional

Some packages should only be installed; they should not be updated. The parameter installonlypkgs identifies these packages. Packages related to the kernel default to installonlypkgs. The tokeep parameter specifies the number of versions of installonlypkgs packages that yum keeps. The installonlyn plugin sets tokeep to 2.


You can update individual packages by specifying the names of the packages on the command line following the word update.

Installing packages


To install a new package together with the packages it is dependent on, give the command yum install, followed by the name of the package. After yum determines what it needs to do, it asks for confirmation. The next example installs the tcsh package:

# yum install tcsh Loading "installonlyn" plugin Setting up Install Process Setting up repositories core                                                                 [1/3] extras                                                               [2/3] updates                                                              [3/3] Reading repository metadata in from local files Parsing package install arguments Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Downloading header for tcsh to pack into transaction set. tcsh-6.14-6.fc5.1.i386.rp 100% |=========================|  11 kB    00:00 ---> Package tcsh.i386 0:6.14-6.fc5.1 set to be updated --> Running transaction check ... Is this ok [y/N]: y Downloading Packages: (1/1): tcsh-6.14-6.fc5.1. 100% |=========================| 465 kB    00:01 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction   Installing: tcsh                         ######################### [1/1] Installed: tcsh.i386 0:6.14-6.fc5.1 Complete!


You can also use yum to remove packages, using a similar syntax. The following example removes the tcsh package:

# yum remove tcsh Loading "installonlyn" plugin Setting up Remove Process Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Package tcsh.i386 0:6.14-6.fc5.1 set to be erased --> Running transaction check ... Is this ok [y/N]: y Downloading Packages: Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction   Removing  : tcsh                         ######################### [1/1] Removed: tcsh.i386 0:6.14-6.fc5.1 Complete!


yum Groups

In addition to working with single packages, yum can work with groups of packages. The next example shows how to display a list of installed and available groups:

#  yum grouplist Loading "installonlyn" plugin Setting up Group Process Setting up repositories core                                                                  [1/3] extras                                                                [2/3] updates                                                               [3/3] Installed Groups:    Office/Productivity    MySQL Database    Editors    System Tools ...    Administration Tools    Development Tools    Graphical Internet Available Groups:    Engineering and Scientific    Window Managers    XFCE Software Development ...    PostgreSQL Database    News Server Done


The command yum groupinfo followed by the name of a group displays information about the group, including a description of the group and a list of mandatory, default, and optional packages. The next example displays information about the MySQL Database group of packages. If the name of the package includes a SPACE, you must quote it.

# yum groupinfo "MySQL Database" Loading "installonlyn" plugin Setting up Group Process Setting up repositories core                                                                  [1/3] extras                                                                [2/3] updates                                                               [3/3] Group: MySQL Database  Description: This package group contains packages useful for use with MySQL.  Mandatory Packages:    mysql  Default Packages:    unixODBC    mysql-server    MySQL-python    mysql-connector-odbc    libdbi-dbd-mysql    perl-DBD-MySQL  Optional Packages:    mod_auth_mysql    mysql-devel    qt-MySQL    mysql-bench    php-mysql


To install a group of packages, give the command yum groupinstall followed by the name of the package.

Other yum Commands

Many yum commands and options are available. A few of the more useful commands are described here. See the yum man page for a complete list.

check-update


Lists packages that are installed on the local system and have updates available in the yum repositories.

clean all


Removes header files that yum uses for resolving dependencies. Also removes cached packagesyum does not automatically remove packages once they have been downloaded and installed, unless you set keepcache to 0.

clean metadata


Removes the files that yum uses to determine remote package availability. Using this option forces yum to download all metadata the next time you run it.

list available


Lists all packages that can be installed from the yum repositories.

search word


Searches for word in the package description, summary, packager, and name.

Running yum Automatically

Fedora includes a service that will call yum nightly to update the local system. This service relies on a cron script in /etc/cron.daily/yum.cron. Use service (page 406) and chkconfig (page 408) to turn on the nightly update service. The log is kept in /var/log/yum.log or as specified in yum.conf.

# /sbin/service yum start Enabling nightly yum update:                              [ OK ] # /sbin/chkconfig yum on


Upgrading a System with yum

Using yum to upgrade a system from one release to another can be problematic and is not recommended. See fedoraproject.org/wiki/YumUpgradeFaq for more information.

Downloading rpm Package Files with yumdownloader

The yumdownloader utility locates and downloadsbut does not installrpm files. If this utility is not available on the local system, use yum to download and install the yum-utils package before attempting to run yumdownloader.

The following example downloads the samba rpm file into the working directory:

$ yumdownloader samba core                                                                  [1/3] extras                                                                [2/3] updates                                                               [3/3] samba-3.0.21b-2.i386.rpm  100% |=========================|  16 MB     06:49


Downloading source files


You can use yumdownloader with the source option to download rpm source package files. To download source files, you must enable the source repository in the *.repo file you want to use. For example, to download the kernel source code, change enabled=0 to enabled=1 in the section of the fedora-core.repo file following the [core-source] header. The following example downloads in the working directory the rpm file for the latest version of the kernel source code for the installed release:

# yumdownloader --source kernel core                                                                  [1/4] core-source                                                           [2/4] extras                                                                [3/4] updates                                                               [4/4] kernel-2.6.15-1.2054_FC5. 100% |=========================|  46 MB     01:18


Without the source option, yumdownloader downloads the executable kernel rpm file.




A Practical Guide to Red Hat Linux
A Practical Guide to Red HatВ® LinuxВ®: Fedoraв„ў Core and Red Hat Enterprise Linux (3rd Edition)
ISBN: 0132280272
EAN: 2147483647
Year: 2006
Pages: 383

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