Книга: Fedora™ Unleashed, 2008 edition

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 and save time.

Before you 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 the example, we use /home/andrew/repo/ as the target directory. Next, find the site you want to mirror (a selection of sites for Fedora can be found at http://fedora.redhat.com/download/mirrors.html). This example uses the UK Mirror service in Canterbury, Kent.

# rsync -avz rsync://rsync.mirrorservice.org/sites/
7/i386/ /home/andrew/repo
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, about 5GB of updates are available at the previous address.) To ensure that rsync really is working, use Nautilus to navigate 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.

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 the following:

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.

At this point, you need to move your newly created repository into a subdirectory of /var/www/html/ so that they are accessible via apache and the HTTP protocol. Use this command:

#mv /home/andrew/repo /var/lib/html/

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
name=Fedora $releasever - $basearch - Updates

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 provides the display name for yum to show while it is busy working; for this repository, it uses Fedora $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 with 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. Use the following command to import this into the RPM database:

# rpm --import thiskey.txt

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


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. 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.

Оглавление книги

Генерация: 0.330. Запросов К БД/Cache: 3 / 1
Вверх Вниз