Automating RedHat RPM updates

Rsync method

LOCAL UPDATE SERVER

-- Pull updates from RedHat mirror (e.g. redhat.seas.upenn.edu):

	cd /local/updates/directory
	for dir in i386 i686 noarch
	do
	  # This is all on one line, continuation for readability
	  rsync -auvr --delete \
	    redhat.seas.upenn.edu::redhat-updates/7.3/en/os/$dir/ $dir/
	done


-- Set up a cron job to run the above script each day at e.g. 3AM:

	00 03 * * *	rsync-get-updates


-- Check local updates directory for duplicates of individual packages
        (e.g. kernel, glibc, different versions lying around)

	cd /local/updates/directory
        ls | sed -e 's/-[0-9]*\.[0-9].*//' | uniq -c | grep -v '      1'
	# That's grep -v '<SIX SPACES FOLLOWED BY THE DIGIT 1>'

    For instance, this may show:

	2 foomatic
	2 nscd
	2 util-linux

    The 2's are doubles, there may even be triples etc. if you never clean this
    directory up (using rsync, you ought to see very few, if any, of these; the
    only ones you will see, in fact, are mistakes by RedHat in their own updates
    tree).


-- Clean up this updates directory.  For each of the above 2's and 3's etc.,
        simply remove all old versions (or temporarily move them out of 
	the way before doing your actual update).



CLIENTS TO BE UPDATED


-- If you care which architecture to keep, use the following to determine
	what you installed in the past:

	In my .bashrc I have:

	rpmq () {
		rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm\n" "$@"
	}

    This may be useful like so:

	rpmq -a | sort > current

	cd /local/updates/directory/i386; rpmq -p * > ../new
	cd /local/updates/directory/i686; rpmq -p * >> ../new
	cd /local/updates/directory/noarch; rpmq -p * >> ../new
	sort ../new

    You can then look for differences (diff won't help since there will be
	packages in new which you never installed)


-- Run the freshen command and cleanup as necessary:

	# NOTE: See discussion here for special handling of i686, and of kernel
	#  update issues
        rpm -Fvh /local/updates/directory/*.rpm


-- Reboot!



Working with Source RPM's

Use "%_topdir /new/path" in ~/.rpmmacros to move RPM builds to a different directory other than /usr/src.
Created: 20020130 widyono
Last updated: 20020807 widyono