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':

#!/bin/bash

LS=/bin/ls
FIND=/usr/bin/find
YUMARCH=/usr/bin/yum-arch
YOPT=-q

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
		MAIN=/var/ftp/pub/redhat/$VER
		LAG=$MAIN/${DAYS}days
		UPDATES=../../updates
		echo "    = $DAYS Day Lag Updates RH$VER ="
		cd $LAG
		if [ $? == 0 ]; then
			for d in athlon i386 i586 i686 noarch SRPMS ; do
				CURRENT=$LAG/$d
				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 \{\} \;
			done
			$YUM $YOPT $LAG > /dev/null
		else
			echo Error changing to $LAG, skipping $DAYS 
		fi
	done
done

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:

  [main]
  cachedir=/var/cache/yum
  debuglevel=2
  logfile=/var/log/yum.log
  pkgpolicy=newest

  [base]
  name=Red Hat Linux $releasever base
  baseurl=ftp://ftp.example.com/pub/redhat/$releasever/RedHat/RPMS/

  [updates3days]
  name=Red Hat Linux $releasever updates3days
  baseurl=ftp://ftp.example.com/pub/redhat/$releasever/3days/

  [extras]
  name=Example Red Hat Linux $releasever extras
  baseurl=ftp://ftp.example.com/pub/redhat/$releasever/extras/
and putting them here:
  /var/ftp/pub/yum/yum-3days.conf
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:
  /var/ftp/pub/yum/yum-7days.conf
  /var/ftp/pub/yum/yum-14days.conf
to copy them into a client machines '/etc/yum.conf' on installation if I wanted it to lag other machines in 'updatedness'.