Creating and Maintaining Lag Update Repositories

To create and keep "lag update" RPM update package repositories updated, I will need these packages:

What are "lag update" repositories? If I have more than one machine to maintain, and one is more important than another, I might want to "test drive" new update packages on the less important machine(s) (a couple test client machines) before applying them to the more important ones (a web or file server). Lag repositories are different sources for packages that 'lag' behind the "up to date" repository by some number of days.

To satisfy my want for variety, and because it is reasonably easy, I create three different time lag repositories: 3 days, 7 days, and 14 days.

To prepare the repositories I just need to create some directories:

# cd /var/ftp/pub/redhat/9/
# mkdir 3days 7days 14days
# for d in athlon i386 i486 i586 i686 noarch SRPMS ; do mkdir 3days/$d 7days/$d 14days/$d ; done

Another simple bash shell script running as a cron (or anacron) job on a daily or weekly basis keeps the 'lagging' part of the RPM repository updated and also 'Yum friendly':



echo "=== Making Time Lag Links For Yum Updates==="

for VER in 7.3 8.0 9 ; do 
	echo "  = Red Hat $VER ="
	for DAYS in 3 7 14 ; do
		echo "    = $DAYS Day Lag Updates RH$VER ="
		cd $LAG
		if [ $? == 0 ]; then
			for d in athlon i386 i586 i686 noarch SRPMS ; do
				if [ ! -d $CURRENT ]; then mkdir $CURRENT; fi
				echo Removing links in $CURRENT
				rm -f $CURRENT/*
				echo Creating links in $CURRENT
				cd $CURRENT
				$FIND $UPDATES/$d -mtime +$DAYS -exec ln \{\} \;
			$YUM $YOPT $LAG > /dev/null
			echo Error changing to $LAG, skipping $DAYS 

echo "=== Time Lag Links Complete ==="
Note that this script also will create lag repositories for multiple Red Hat versions. And again, I prefer cron to anacron because I can know exactly when things are supposed to happen.

I put the script in my unprivileged user's '~/cron/' directory and schedule it daily (using 'crontab -e'). This is a typical crontab entry:

  0 2 * * * /home/myuser/cron/make-lag-links
assuming that 1 AM is a slow time for the FTP mirror, and that mirroring updates will typically take no more than one hour. Note that this is very dependent on making sure that the update packages keep their original dates.

Now that I have the lag repositories in place, I would like to make them easy to use. I can do this by making another alternative 'yum.conf' file containing:


  name=Red Hat Linux $releasever base

  name=Red Hat Linux $releasever updates3days

  name=Example Red Hat Linux $releasever extras
and putting them here:
For the other repositories I would create similar files (named 'yum-7days.conf' and 'yum-14days.conf') and refer to their respective update repository locations and using their respective labels. I would put them here:
to copy them into a client machines '/etc/yum.conf' on installation if I wanted it to lag other machines in 'updatedness'.