Keeping Fedora upto date with Yum !

Written by Rick Nicholas

Yum is an automatic updater and package management tool for rpm based systems. Yum automatically computes dependencies and figures out what steps need to occur in order to install packages. It makes it much easier to maintain groups of machines without having to manually update each one using rpm.

Yum can be used in place of, or in addition to the Red Hat up2date and rpm tools which also come with Fedora Core 1. My personal preference is to use Yum as a complete replacement for both tools as it has proven to be faster, more reliable, and also offers functionality not available when using the other tools such as;


  • Multiple Repositories

  • Simple Configuration File

  • Correct Dependency Calculation

  • rpm-consistant behavior

  • comps.xml group support, including multiple repository groups

  • Simple interface

Yum can not only be used to keep packages already installed on your system updated, but can also be used to install packages directly, which is awesome on those days when you can't find a cd to save your life. Yes, you could always download the sourceball, or go looking for an rpm on the net, but this is soooo much simpler. Yum is developed and maintained through the hard work of the folks at Duke University and is made available to the rest of us under the GNU GPL. So now you know a little about Yum, lets check out what it can do for you !

Please note that this tutorial makes the assumption that you have Yum installed currently, and that you can use a text editor such as vi for basic editing tasks. If you do not have Yum installed currently, it can be installed from your Fedora Core 1 installation cd's, or, you can visit the mirrors.kernel.org site and obtain the required rpm's from there.

Configuring Yum

Before using Yum we need to modify its configuration file which is called yum.conf and edit the lines which tell Yum which repository server to use. By default this is set to the main Fedora Core 1 download server, and while this works, it is brutally slow and also has a tendancy to time out, this due to the fact so many folks are using the server at once. So we will instead set Yum to utilize one of the many available mirror sites listed at The Fedora Mirror Site. Usually you will want to select a primary site which is close to you geographically, this generally helps to provide increased speed, however, your mileage may vary. So lets edit yum.conf, set the server, and start using Yum. You'll need to be root for the rest of this tutorial, so grab a terminal window and issue the following comand;

$su  
$password  

Ok, now using your favorite text editor open the /etc/yum.conf file and edit it as follows replacing the baseurl line with the address of the repository you chose. In this example we are using the mirror site mirrors.kernel.org, this works for me as I am in the Western US, substitute as needed with the mirror site you selected.

[base]
name=Fedora Core $releasever - $basearch - Base 
baseurl=http://mirrors.kernel.org/fedora/core/$releasever/$basearch/os 

[updates-released]
name=Fedora Core $releasever - $basearch - Released Updates 
baseurl=http://mirrors.kernel.org/fedora/core/updates/$releasever/$basearch 

You do not need to worry about the [updates-testing] portion of this file as it is not used for general updates and package installation. So having made the required changes, save the file and close it. Now lets edit the /etc/sysconfig/rhn/sources file as follows, again, substitue as needed with the mirror site you have chosen.

yum fedora-core-1 http://mirrors.kernel.org/fedora/core/1/i386/os 
yum updates-released http://mirrors.kernel.org/fedora/core/updates/1/i386 

Cool, that change insures that the Redhat tools work as well. Thats it, save the file and close it and lets move on.

Using Yum

The first thing we need to do with Yum is to have it update its rpm headers listing, each rpm has a header which contains a complete file listing, package descriptions, a list of what features and / or libs it provides, a list of what it requires, and a list of what it conflicts with. Yum uses this information to make decisions about how to update and install packages.

So, still as root issue the following command;

#yum check-update  

Yum will download the complete set of current headers from the repository server you specified in your yum.conf file. This usually takes a few minutes and looks something like the following;

     Gathering header information file(s) from server(s) 
     Server: Fedora Core 1 - i386 - Base 
     Server: Fedora Core 1 - i386 - Released Updates 
     Finding updated packages 
     Downloading needed headers 

When Yum finishes downloading the header files it is ready to go on to bigger and better things, lets say you want to make sure all of the packages currently installed on your system are up to date with the latest version, simply enter the following command;

#yum update  

Yum will proceed to compare all packages currently installed on your system with those currently available on the repository server, once complete, it will present you with an information screen listing details of what it intends to do and ask you for confirmation, such as;

     Gathering header information file(s) from server(s) 
     Server: Fedora Core 1 - i386 - Base 
     Server: Fedora Core 1 - i386 - Released Updates 
     Finding updated packages 
     Downloading needed headers 
     getting /var/cache/yum/updates-released/headers/rdesktop-0-1.3.0-2.i386.hdr 
     rdesktop-0-1.3.0-2.i386.h 100% |=========================| 3.1 kB 00:00 
     Resolving dependencies 
     Dependencies resolved 
     I will do the following: 
     [install: rdesktop-0-1.3.0-2.i386] 
     Is this ok [y/N]: y 

In this case Yum is telling me that there is an update available for Rdesktop, all I need to do is reply yes to the question and the package is updated. Cool huh ?, now lets say maybe you just want to update a specific package, just modify the command you used above by adding a package name, such as;

#yum update nmap  

You'll see something like this;

     Gathering header information file(s) from server(s) 
     Server: Fedora Core 1 - i386 - Base 
     Server: Fedora Core 1 - i386 - Released Updates 
     Finding updated packages 
     Downloading needed headers 
     No Packages Available for Update 
     No actions to take 

In this case Yum is telling me that the version of nmap installed on my system is current, therefore it will take no actions as far as updating. Nice eh ?, so lets say you want to install a package you don't have currently, like the XChat IRC client, simply enter the following;

#yum install xchat  

You'll see something like the following;

     Gathering header information file(s) from server(s) 
     Server: Fedora Core 1 - i386 - Base 
     Server: Fedora Core 1 - i386 - Released Updates 
     Finding updated packages 
     Downloading needed headers 
     getting /var/cache/yum/base/headers/xchat-1-2.0.4-4.i386.hdr 
     xchat-1-2.0.4-4.i386.hdr 100% |=========================| 6.8 kB 00:00 
     Resolving dependencies 
     Dependencies resolved 
     I will do the following: 
     [install: xchat 1:2.0.4-4.i386] 
     Is this ok [y/N]: 

Simply respond with a yes to Yum's question and presto that package is installed and available. Sweet isn't it ?, ok, lets say you have nmap installed already, and you'd like a gui interface to it, but you have no idea what the package might be called, just enter the following;

#yum search nmap gui  

This is what you might see;

     Gathering header information file(s) from server(s) 
     Server: Fedora Core 1 - i386 - Base 
     Server: Fedora Core 1 - i386 - Released Updates 
     Finding updated packages 
     Downloading needed headers 
     Looking in available packages for a providing package 
     Available package: nmap-frontend.i386 2:3.48-1 from base matches with 
      Gtk+ frontend for nmap. 
     Available package: nmap-frontend.i386 2:3.48-1 from base matches with 
      nmap-frontend 

Just pick the package you want and install it using the command you used earlier in the tutorial. The search option also accepts wildcard characters in the event you need to utilize them. How much better can it get you ask ?, how about this scenario, lets say you need a certain library which is not a standalone package, such as libc6.1-1.so.2, how do you go about aquiring it ?, just do the following;

#yum provides libc6.1-1.so.2  

This is what you'd get;

     Gathering header information file(s) from server(s) 
     Server: Fedora Core 1 - i386 - Base 
     Server: Fedora Core 1 - i386 - Released Updates 
     Finding updated packages 
     Downloading needed headers 
     Looking in available packages for a providing package 
     Available package: compat-libstdc++.i386 0:7.3-2.96.118 from base matches with 
      libstdc++-libc6.1-1.so.2 
     Available package: compat-libstdc++.i386 0:7.3-2.96.118 from base matches with 
      libstdc++-libc6.1-1.so.2(GCC.INTERNAL) 
     2 results returned 
     Looking in installed packages for a providing package 
     No packages found 

Yum tells you that the package compat-libstdc++ contains the library you are looking for which is libc6.1-1.so.2, and that it is not currently installed on your system. So just run yum install compat-libstdc++ and you've got your library. Now, lets say you are sick of running portscans against the machines of unsuspecting users (kidding of course), so you want to get rid of nmap all together, just enter the following command;

#yum remove nmap  

This removes the selected package as well as removing any other packages which depend on it. One thing worth noting is that when Yum downloads packages or updates for installation it does not remove them automatically from its disk cache, so some periodic maintenance is required, luckily the maintenance is as simple and quick as the rest, just run the following command from time to time;

#yum clean all  

This deletes any old cached packages from your system as well as removing any old rpm headers that are no longer needed. Gotta love it, simple and quick. Ok, one last example and we'll call it a day, lets say you just want to know about the Xchat package without actually installing it, all you need to do is;

#yum info xchat  

And this is what you'll see;

     Gathering header information file(s) from server(s) 
     Server: Fedora Core 1 - i386 - Base 
     Server: Fedora Core 1 - i386 - Released Updates 
     Finding updated packages 
     Downloading needed headers 
     getting /var/cache/yum/base/headers/xchat-1-2.0.4-4.i386.hdr 
     xchat-1-2.0.4-4.i386.hdr 100% |=========================| 6.8 kB 00:00 
     Looking in Available Packages: 
     Name : xchat 
     Arch : i386 
     Version: 2.0.4 
     Release: 4 
     Size : 2.40 MB 
     Group : Applications/Internet 
     Repo : Fedora Core 1 - i386 - Base 
     Summary: A GTK+ IRC (chat) client. 
     Description: 
      X-Chat is an IRC client for the X Window System and GTK+. X-Chat is 
     fairly easy to use and includes a nice interface. 

That brings us to the end of this tutorial, hopefully you found this information helpful, and it has shown you what a great and easy to use tool Yum can be. If you'd like to learn more about Yum and all it can do, you can visit their site, or read through the man pages which are very straight forward and easy to understand. Good Luck !

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Support for un-supported Redhat Linux and FedoraCore versions...

If you're using yum on Red Hat Linux, add the following blocks to your "/etc/yum.conf" (these work for all supported releases of Red Hat Linux):

[base]
name=Red Hat Linux $releasever base
baseurl=http://download.fedoralegacy.org/redhat/$releasever/os/$basearch

[updates]
name=Red Hat Linux $releasever updates
baseurl=http://download.fedoralegacy.org/redhat/$releasever/updates/$basearch

	1;legacy-utils]
name=Fedora Legacy utilities for Red Hat Linux $releasever
baseurl=http://download.fedoralegacy.org/redhat/$releasever/legacy-utils/$basearch

If you're using yum on Fedora Core 1, add the following blocks to your "/etc/yum.conf":

[base]
name=Fedora Core $releasever base
baseurl=http://download.fedoralegacy.org/fedora/$releasever/os/$basearch

[updates]
name=Fedora Core $releasever updates
baseurl=http://download.fedoralegacy.org/fedora/$releasever/updates/$basearch

	1;legacy-utils]
name=Fedora Legacy utilities for Fedora Core $releasever
baseurl=http://download.fedoralegacy.org/fedora/$releasever/legacy-utils/$basearch

If you are already using another repository for official Red Hat Linux or Fedora Core packages and updates, please note the following:

* You only need one repository providing the "base" (aka "os") channel. If you already have a repository providing it, you may want to keep only one (either one). The contents of this channels will never change.

* The "updates" channel is the channel used for Fedora Legacy updates. If you already have a repository providing a Red Hat or Fedora Core "updates" channel, make sure that you keep only the "updates" channel from Fedora Legacy and remove that channel from your other repository. Your former "updates" channel will only provide Red Hat or Fedora Core official updates. Your system will NOT receive Fedora Legacy updates if you're using any other "updates" channels providing only official Red Hat or Fedora Core updates!

Additional config notes for YUM...
  1. In the global section, debuglevel determines how verbose Yum's output is. This value may range from 0, for no output, to 10, for maximum debugging output. The default value is set to 2. This debuglevel affects only standard output, not Yum's log file. However, my recommendation is to set it to 4 arrived by playing with the yum command's -d value. For example, (yum -d 4 yum-commands) is equivalent to and over-rides debuglevel.

  2. Fedora mirrors that contain the same collection of RPMs can be listed with additional "baseurl" line and is recommended to minimize the chance of updates failing due to server being unavailable. Be sure to use your favourite web browser to test-drive any URL you add to yum.conf to make sure it successfully resolves to a directory containing a directory named headers. Also, make sure that your URL ends with a trailing slash.

  3. Set "gpgcheck=1" which causes Yum to check the GnuPG signature in each RPM it downloads. For this to work, you need the appropriate GnuPG keys incorporated into your RPM database. On Fedora Core 1 systems, these keys are installed on your system as part of the fedora-release package. To copy them to your RPM databasee, execute:

    rpm --import /usr/share/doc/fedora-release-1/RPM-GPG*
    

    The rpm --import command also can use a URL as its argument, so if the GnuPG key of your Yum source is online, you can use the form:

    rpm --import http://your.distro.homepage/GPGsignature
    

    where http://your.distro.homepage/GPGsignature should be replaced with a real URL.

    This may seem like a hassle, but it's worth it. Several intursions on Linux distributors' sites over the years have resulted in trojaned or otherwise compromised software packages being downloaded by unsuspecting users.

  4. You could also specify "failovermethod=priority", which tells Yum to try the URLs in order, starting with the one at the top. The default behavior, "failovermethod=roundrobin", is for Yum to choose one of the listed URLs at random. The priority method lets you prioritize faster, closer mirrors.

Comment