Creating a Local yum Repository


Creating a Local yum Repository

When yum is active, it can download a lot of information in the form of RPM headers and files, which can easily eat up bandwidth. If you have three or more Fedora-based machines on a local network, creating a local yum repository can be a good way to conserve bandwidth.

Before we start setting up the repository, you need to have the rsync and createrepo packages installed because you will need them both. Use the command yum install rsync createrepo to make sure that they are installed.

To begin, create a directory that will house your repository. In our example, we will use /home/andrew/repo/ as our target directory. Next, find the site you want to mirror (a selection of sites for the Fedora can be found at http://fedora.redhat.com/download/mirrors.html). For this example, we will use the UK Mirror service in Canterbury, Kent, which is rsync.mirror.ac.uk/fedora.redhat.com/updates/5/i386/.

rsync itself is easy to use as follows:

# rsync rsync://rsync.mirror.ac.uk/fedora.redhat.com/updates /5/i386/*.rpm /home/andrew/repo


rsync then starts to download the files it finds within that directory to /home/andrew/repo. This can take some time (at the time of writing, there is about 5GB of updates available at the previous address). To ensure that rsync really is working, navigate using Nautilus to /home/andrew/repo; here you should see a number of packages appearing one after the other.

After you have completed downloading the updates you want, you need to create your repository. This is where the createrepo command comes in.

Using createrepo

createrepo is a program designed to quickly and efficiently draw the relevant information from a collection of rpm files to make the metadata yum requires to successfully install or update your currently installed package base.

The command is simply

createrepo /yourtargetdirectoryhere


So, if we were to use the example in the previous section, the syntax would look something like this:

$ createrepo /home/andrew/repo


This would give you the following output:

88/88 - alsa-lib-1.0.6-5.i386.rpm Saving Primary metadata Saving file lists metadata Saving other metadata


This shows that 88 RPMs were cataloged and that the relevant metadata was saved. The program automatically uses the given directory, so you do not have to worry about making several copies of directories.

After this is done, you are ready to include your new repository into the /etc/yum.conf file or into its own file under /etc/yum.repo.d. Let's take a look at a typical configuration file for use with yum:

$ cat /etc/yum.repos.d/local.repo [local] name=Fedora Core $releasever - $basearch - Updates baseurl=http://192.168.2.5/repo enabled=1 gpgcheck=0


This file is fairly easy to read. Line one is the name of the repository that is passed to yum. The name must be enclosed in square brackets for it to be picked up; in this case, it is simply local. Line two gives us the display name for yum to show while it is busy working; for this repository, it uses Fedora Core $releasever - $basearch - Updates, which prints the release version (in this case 4) and the base architecture (i386). Next comes the base URL, or the primary download point. This is used for yum to scan and download the metadata it needs. The fourth line shows whether this repository is enabled: enabled=0 means it is disabled, and enabled=1 means it is enabled and able to be used. The final line determines whether the RPMs are checked using a GnuPG key. You are advised to obtain the relevant GnuPG key from the original repository to ensure that the packages you install have not been tampered with. This can then be imported into the RPM database by using the following command:

# rpm --import thiskey.txt


After the key has been imported into the database, yum can use it to verify that the packages are intact and safe to use.

Caution

Notice that we say the use of GPG keys can make packages safer to use. This is certainly true, but be aware that sometimes packages can conflict with each other. You should be careful about which repositories you use because some are incompatible with others. When selecting a repository, always read any FAQs for warnings of incompatibilities. Check out http://fedoraproject.org/wiki/Extras/RepositoryMixingProblems for the official Fedora stance on this.




Red Hat Fedora 5 Unleashed
Red Hat Fedora 5 Unleashed
ISBN: 067232847X
EAN: 2147483647
Year: 2004
Pages: 362

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