= Subset Repositories (Fedora 9) = With the move to FedoraProject:PackageKit in Fedora 9, the facility that Fedora 8 had to install packages directly from install media left in your machine (e.g. DVD in a DVD drive) or inserted on demand is no longer available (it is a work-in-progress). Follow the instructions here for creating and using a base repository based on an ISO image of the DVD media stored on your hard disk. == Creating the Base Repository == The base distribution repository is created in the same way as it's always been done on the earlier distribution releases. The files can be located anywhere but for the purposes of this article, the directory `/srv/nb/distros/fc9` is used as a base. To support both 32-bit and 64-bit machines on the network, the ISO images for both the 32-bit and 64-bit releases are needed. If you only need one architecture, skip the parts pertaining to the other architecture (similarly if you're using ''ppc'', substitute `ppc` for `i386` or `x86_64` as appropriate). The ISO images should be placed the repository area on the server that you are using, e.g.: {{{ # mkdir -p /srv/nb/distros/fc9/os/i386/iso/ # cp Fedora-9-i386-DVD.iso /srv/nb/distros/fc9/os/i386/iso/ # mkdir -p /srv/nb/distros/fc9/os/x86_64/iso/ # cp Fedora-9-x86_64-DVD.iso /srv/nb/distros/fc9/os/x86_64/iso/ }}} Create mount points so that the ISO images can be loopback-mounted: {{{ # mkdir /srv/nb/distros/fc9/os/i386/dvd/ # chcon -t mnt_t /srv/nb/distros/fc9/os/i386/dvd # mkdir /srv/nb/distros/fc9/os/x86_64/dvd/ # chcon -t mnt_t /srv/nb/distros/fc9/os/x86_64/dvd }}} Edit `/etc/fstab` and add entries for the DVD images to get them mounted at boot time: {{{ /srv/nb/distros/fc9/os/i386/iso/Fedora-9-i386-DVD.iso /srv/nb/distros/fc9/os/i386/dvd iso9660 _netdev,ro,loop,fscontext=system_u:object_r:public_content_t:s0 0 0 /srv/nb/distros/fc9/os/x86_64/iso/Fedora-9-x86_64-DVD.iso /srv/nb/distros/fc9/os/x86_64/dvd iso9660 _netdev,ro,loop,fscontext=system_u:object_r:public_content_t:s0 0 0 }}} Note that these are just single long lines for each ISO image It should now be possible to mount the ISO image(s) by issuing the command: {{{ # service netfs start }}} It may seem strange to treat local loopback mounts as "network filesystems" but this is the point during the boot process where loopback mounts get done. Using `service netfs start` rather than plain `mount -a` checks that there are no SELinux issues (the former runs confined by SELinux, the latter does not). The long-winded mount options in the `fstab` entries prevent SELinux objecting if you serve out the repository using `ftp`, `httpd`, `rsync` etc. You can then use `createrepo` to build the repository metadata: {{{ # cd /srv/nb/distros/fc9/os/i386 # createrepo -d . # cd /srv/nb/distros/fc9/os/x86_64 # createrepo -d . }}} /!\ Be careful with your directory hierarchy; it is important that the only RPM files that live in the `/srv/nb/distros/fc9/os/i386` etc. directory or anywhere underneath that directory are the RPMs from your DVD ISO (i.e. the ones in the `dvd/Packages` directory); any other RPMs that may be present will also be found by `createrepo` and included in the repository, which is probably not what you want. {i} `createrepo` is in the `createrepo` package on the media == Using the Base Repository == Using the base repository is very straightforward. Using your favourite editor, create a file `/etc/yum.repos.d/fedora-local.repo`: {{{ [fedora-local] name=Fedora $releasever - $basearch (local) baseurl=file:///srv/nb/distros/fc9/os/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY metadata_expire=-1 cost=500 }}} You should now be able to test your setup by installing some package. Packages on the media will be shown as coming from `fedora-local` and other packages will be shown as coming from `fedora`. == Creating the Updates Repository == The object here is to create an updates repository that contains only updates for the packages available on the original media. This will reduce the bandwidth and disk space needed to maintain the mirror. The tool to be used is `reposync`, which is part of the `yum-utils` package. The first step is to create lists of the packages on the media (and hence those we want to mirror updates for): {{{ # cd /srv/nb/distros/fc9/os/i386 # ls dvd/Packages | awk '{ pkgname = $1; sub("-[^-]*-[^-]*$", "", pkgname); print "\t" pkgname }' | uniq > fedora-9-i386-dvd-pkgs.conf # cd /srv/nb/distros/fc9/os/x86_64 # ls dvd/Packages | awk '{ pkgname = $1; sub("-[^-]*-[^-]*$", "", pkgname); print "\t" pkgname }' | uniq > fedora-9-x86_64-dvd-pkgs.conf }}} This process creates a sorted list of the packages on each DVD ISO (the lists are slightly different for each architecture), one per line, indented with a tab character at the start of each line. The tab character (or at least some form of leading space) is important for later use. You need to ensure that you have the latest `fedora-release` package, which contains an updated set of GPG keys for the updates: {{{ # yum update fedora-release }}} Now create a mirror configuration file, `/etc/yum.repos.d/fedora-updates-mirror.repo`: {{{ [fedora-9-updates-subset-i386] name=Fedora 9 - i386 - Updates Subset mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f9.newkey&arch=i386 #baseurl=http://mirrors.eu.kernel.org/fedora/updates/9/i386.newkey/ # http://sunsite.mff.cuni.cz/MIRRORS/fedora.redhat.com/linux/updates/9/i386.newkey/ # ftp://ftp.tudelft.nl/pub/Linux/download.fedora.redhat.com/linux/updates/9/i386.newkey/ # http://download.fedora.redhat.com/pub/fedora/linux/updates/9/i386.newkey/ includepkgs= include=file:///srv/nb/distros/fc9/fedora-9-i386-dvd-pkgs.conf selinux-policy-devel enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-8-and-9-i386 failovermethod=priority [fedora-9-updates-subset-x86_64] name=Fedora 9 - x86_64 - Updates Subset mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f9.newkey&arch=x86_64 #baseurl=http://mirrors.eu.kernel.org/fedora/updates/9/x86_64.newkey/ # http://sunsite.mff.cuni.cz/MIRRORS/fedora.redhat.com/linux/updates/9/x86_64.newkey/ # ftp://ftp.tudelft.nl/pub/Linux/download.fedora.redhat.com/linux/updates/9/x86_64.newkey/ # http://download.fedora.redhat.com/pub/fedora/linux/updates/9/x86_64.newkey/ includepkgs= include=file:///srv/nb/distros/fc9/fedora-9-x86_64-dvd-pkgs.conf selinux-policy-devel enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-8-and-9-x86_64 failovermethod=priority }}} It's a good idea to replace the `mirrorlist` entries with `baseurl` entries pointing to one or more fast, nearby mirrors as shown in the commented-out `baseurl` entries above; not all mirrors are as up to date as each other, so with the `mirrorlist` you might find that one day's `reposync` run removes the updates downloaded in the previous day's run. {i} If you want to include additional packages in your local updates repository for packages that were not included on the release media, you can add them (indented by a tab) one per line after the `include=` lines in the repository configuration, as I have shown in the examples above for `selinux-policy-devel`. Then create a script `updates-sync`, and put it somewhere in your `PATH`, such as `/usr/local/bin`: {{{#!format plain #!/bin/bash echo "Updating mirror of fedora-9-updates-subset-x86_64" reposync -n -g -d -a x86_64 -r fedora-9-updates-subset-x86_64 -p /srv/nb/distros/fc9 | grep -Ev "Skipping existing|%" createrepo -q -d -C /srv/nb/distros/fc9/fedora-9-updates-subset-x86_64 echo "" # Hard link i386 and noarch packages from the x86_64 repo to the i386 repo # so as to avoid having to download them again, and to save space commonpkgs=$(echo /srv/nb/distros/fc9/fedora-9-updates-subset-x86_64/*.{i386,noarch}.rpm) if [ "$commonpkgs" != "/srv/nb/distros/fc9/fedora-9-updates-subset-x86_64/*.{i386,noarch}.rpm" ]; then ln -f $commonpkgs /srv/nb/distros/fc9/fedora-9-updates-subset-i386/ fi echo "Updating mirror of fedora-9-updates-subset-i386" reposync -n -g -d -r fedora-9-updates-subset-i386 -p /srv/nb/distros/fc9 | grep -Ev "Skipping existing|%" createrepo -q -d -C /srv/nb/distros/fc9/fedora-9-updates-subset-i386 echo "" }}} /!\ The `createrepo` shipped with Fedora 9 crashes if you use the `-C` option ([[RedHatBugzilla:446040|Bug #446040]]); either make the edit described in the bug report or remove the `-C` option in the `createrepo` calls in the script until an updated `createrepo` version is available. Skip the parts of the script for any architecture you're not interested in. The section in the middle hardlinking files between the x86_64 and i386 repos is only useful if you are mirroring both x86_64 and i386 updates. The `grep` command here reduces the volume of output from `reposync` whilst leaving the interesting output alone (unlike the `-q` option of `reposync`). Don't forget to make the script executable: {{{ # chmod 755 /usr/local/bin/updates-sync }}} To populate the repository (download the update packages), just run `/usr/local/bin/updates-sync`. This will create repositories in directories `/srv/nb/distros/fc9/fedora-9-updates-subset-i386` and `/srv/nb/distros/fc9/fedora-9-updates-subset-x86_64` for `i386` and `x86_64` respectively. == Using the Updates Repository == Create a new repository configuration file `/etc/yum.repos.d/fedora-local-updates.repo` as follows: {{{ [updates-local] name=Fedora $releasever - $basearch - Updates (local) failovermethod=priority baseurl=file:///srv/nb/distros/fc$releasever/fedora-$releasever-updates-subset-$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-8-and-9-$basearch metadata_expire=120 cost=500 }}} {i} A low value for `metadata_expire` is used so that users of your local updates repo see the updates there very soon after you've sync'ed your mirror, and get fresh updates from there instead of downloading them themselves from the main updates repo over the Internet. You should now be able to test your setup by running `yum update`. Packages in the local repository will be shown as coming from `updates-local` and other packages will be shown as coming from `updates`. == No/Slow Internet Connection? == Edit the configuration files: * `/etc/yum.repos.d/fedora.repo` * `/etc/yum.repos.d/fedora-updates.repo` Change the line: {{{ enabled=1 }}} to: {{{ enabled=0 }}} for the network repositories and leave just the local repositories enabled by default. You should then be able to use the package management tools whilst offline, though you may find that things you'd like to install appear not to be available. To enable the Internet repositories for a single `yum` run whilst you're online, use: {{{ # yum --enablerepo=fedora --enablerepo=updates update }}} or {{{ # yum --enablerepo=fedora --enablerepo=updates install somepackage }}} etc. ---- CategoryTip