Using local media first with Fedora and Yum
With CentOS, if you have the DVD or ISO install image on your CentOS system, just disable the [base] repo in /etc/yum.repos.d/CentOS-Base.repo and enable [c5-media] repo in /etc/yum.repos.d/CentOS-Media.repo and point baseurl= to the right location where the ISO or DVD is mounted (baseurl=/media/PATH-TO-DVD).
This works out great as the CentOS [base] repo and the DVD have the identical contents.
However, with Fedora 7 and newer, this is not the case and things are a bit messy. The contents of the [fedora] repo in /etc/yum.repos.d/fedora.repo have Everything in Fedora since the Core split was dropped, which is a huge amount of packages than ever ship on the DVD.
So, how to use local [InstallMedia] first, while still searching the [fedora] repo, and still get [updates]? The answer is to use yum priorities.
Install this yum plug-in package:
yum install yum-priorities
Once this is installed, use a new priority= option with any repo with conflicting or duplicate packages. In this case we want:
priority = 1 [InstallMedia]
priority = 1 [updates]
priority = 2 [fedora]
This means [InstallMedia] and [updates] are the highest priority. [updates] will win out over [InstallMedia] as it will have newer version numbers. [InstallMedia] will win out over [fedora] as it has a higher priority value (lower number). The exception where packages will be installed from [fedora] is when [InstallMedia] doesn't have it (remember "Everything") and [updates] doesn't contain anything newer.
So the edits needed are:
/etc/yum.repos.d/fedora.repo
Under [fedora] add:
priority=2
Edit:
/etc/yum.repos.d/fedora-updates.repo
Under [updates] add:
priority=1
Finally, copy from the DVD or mounted DVD ISO:
cp /media/DVD/media.repo /etc/yum.repos.d/
Edit /etc/yum.repos.d/media.repo which contains the [InstallMedia] repo to add:
priority=1
baseurl=file:///PATH-TO-DVD/
PATH-TO-DVD should replaced with /media/WHATEVER or where ever the ISO is mounted.
In my case, I have this in my /etc/fstab to mount the ISO on boot:
/storage/f12/Fedora-12-i386-DVD.iso /storage/f12/dvd iso9660 ro,user,loop 1 1
So my /etc/yum.repos.d/media.repo has added:
priority=1
baseurl=file:///storage/f12/dvd/
Now just reset yum's info and install away:
yum clean all
So for a test, I will install a few packages, which will show all 3 repos being used:
# yum install openoffice.org-writer kdegames frozen-bubble
Loaded plugins: fastestmirror, presto, priorities, refresh-packagekit, verify
...
Dependencies Resolved
===================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================
Installing:
frozen-bubble i686 2.2.0-4.fc12 updates 20 M
kdegames i686 6:4.3.4-1.fc12 updates 41 M
openoffice.org-writer i686 1:3.1.1-19.14.fc12 InstallMedia 143 k
Installing for dependencies:
kde-filesystem noarch 4-30.fc12 InstallMedia 45 k
kde-settings noarch 4.3-15.1 updates 41 k
kdegames-libs i686 6:4.3.4-1.fc12 updates 1.1 M
kdelibs i686 6:4.3.4-3.fc12 updates 11 M
kdelibs-common i686 6:4.3.4-3.fc12 updates 765 k
openoffice.org-brand i686 1:3.1.1-19.14.fc12 InstallMedia 384 k
openoffice.org-core i686 1:3.1.1-19.14.fc12 InstallMedia 81 M
openoffice.org-opensymbol-fonts noarch 1:3.1.1-19.14.fc12 InstallMedia 171 k
openoffice.org-ure i686 1:3.1.1-19.14.fc12 InstallMedia 2.5 M
openoffice.org-writer-core i686 1:3.1.1-19.14.fc12 InstallMedia 5.3 M
perl-SDL i686 2.1.3-11.fc12 fedora 313 k
Transaction Summary
===================================================================================================================================
Install 14 Package(s)
Upgrade 0 Package(s)
Total download size: 165 M
As you can see, a huge amount will not need to be downloaded from the internet as they will come from the local [InstallMedia] (all of the OOo packages). However, there are still many packages from [updates] which are needed, and one package from [fedora].
To quickly see the priorities of repos, use this bit of code:
$ cat /etc/yum.repos.d/*.repo | sed -n -e "/^\[/h; /priority *=/{ G; s/\n/ /; s/ity=/ity = /; p }" | sort -k3n
priority = 1 [InstallMedia]
priority = 1 [updates]
priority = 2 [fedora]
As a side note, the default priority is 99. So, if you forget to give [updates] priority 1 it will default to 99. That will mean that [fedora] or [InstallMedia] will have a preferred priority and actually downgrade any updates you already have and/or prevent them from being installed in the future.
There is newer cost= option as of Fedora 9. However, as I support both RHEL/CentOS 5 systems and Fedora, I'm sticking with priority= which works with both RHEL/CentOS and Fedora.