Let us as a demonstration create a mirror of a Fedora repository that can
be used to install and maintain a Fedora-based LAN (both workstations
and servers). For the sake of being concrete, it will be assumed that
the repository is being created on a web server, although it might
equally well be created on an FTP server or NFS server (or the same
repository exported all three different ways to different clients).
This article will not detail the process of setting up any sort of
server initially; support for this is readily available from many books
and in HOWTOs provided by The Linux Documentation Project:
The following is a trivial script that uses anonymous rsync to make a copy of the entire fedora core repository. Note that you will have to install rsync for this to work! Rsync is available as a standard rpm in most distributions and on many public repositories and mirrors. If necessary, obtain and install rsync before attempting to use it to create a mirror.
When this is done, enter this into a file named (for example) rsync.fedora and use chmod 755 rsync.fedora to make it executable.
#!/bin/sh rsync -av --partial --stats \ mirror.dulug.duke.edu::archive/pub/fedora/linux/core .Place this script on an executable path or prepare to execute it by explicit path.
Note that one can add an -exclude argument to this command if one wishes to omit part of the tree for any reason. For example, adding -exclude isolinux after the -stats argument causes the isolinux directory under the fedora core to be omitted. If you don't plan to turn the mirror into a bootable cd, this directory is of no particular use to yum, although it is also not terribly large. This exemplifies how the distribution can be further trimmed or expanded according to your needs by editing the script. As long as the RPMs themselves are mirrored, yum itself will function.
On the server, create a suitable directory path and rsync mirror the repository using the script. For a web-based repository, this might be done with the following commands:
$ cd /var/www $ mkdir fedora $ cd fedora $ rsync.fedoraThis script will typically take a fairly long time to complete the first time, depending on your bandwidth and the load on the Fedora mirror server. Afterward, however, running the script will only cause changes in the repository to be downloaded.
In many cases one will want to create a short nightly or weekly cron script to automate a regular resynchronization of your mirror with the original. You may also want to add a step to check the MD5 or GPG signatures of the packages (if any are available) to ensure that they have not be tampered with.