[wplug] scripting help for RH updates

Vanco, Donald VANCOD at PIOS.com
Wed Jul 2 13:46:27 EDT 2003


Hi all -
	Let me preface this by reminding you that I'm a hardware and
sometimes application guy, and hacking code is not my strong point.  I know
enough to break things at will... What follows is likely less than elegant,
but is functional and requires no additional degree of complexity (perl,
python, etc - things that aren't necessarily on every install we do) 

	I'm automating a process for pulling Red Hat updates.  Because of
the client profile we have I need to archive updates for several releases.
To this point I've done things as separate processes - I am striving to
automate as much as possible.  It may be that I leave things as several
individual process, it may be that I can lump much together.

My basic activity:
	- rsync with the RH beta FTP site (gives me optimal bw over public
mirrors) to any of several directories
	- copy sync'd files to common directory
	- remove "duplicates" of RPMs compiled for multiple architectures,
favoring those compiled against i686
		- this is the part I need help with
	- make an ISO

What I do now:

for the rsync I have this scripted: (the yum portion is ancillary and not
really a requirement for this process)
_______________________________________________
#!/bin/sh
export RSYNC_PASSWORD=**********
REMOTE_DIR="rsync://beta@ftp.beta.redhat.com/beta/pub/redhat/linux/updates/7
.3/en/os/noarch/"
LOCAL_DIR=/home/RedHat/7.3/noarch/

mirror() {
        rsync -LvvH --delete --stats --progress --recursive
--exclude=headers --size-only $REMOTE_DIR $LOCAL_DIR
}

mirror
yum-arch /home/RedHat/7.3/noarch
_______________________________________________

...and I do this against several directories for this particular release



I then copy all the RPMs to a directory called updates, where I run the
following script to find duplicates:
_______________________________________________
#!/bin/sh
ls | sed 's/-[0-9]*\..*//g' | sort > /tmp/lsdup.all.$$
ls | sed 's/-[0-9]*\..*//g' | sort | uniq > /tmp/lsdup.uniq.$$
diff -y --suppress-common-lines /tmp/lsdup.all.$$ /tmp/lsdup.uniq.$$ | tr -d
"[:blank:]\<" | sort | uniq
rm -rf /tmp/lsdup.all.$$ /tmp/lsdup.uniq.$$
_______________________________________________

which gives me output like this:
[root at lappydappydoo updates]# lsdup
glibc
kernel
kernel-bigmem
kernel-BOOT
kernel-doc
kernel-smp
kernel-source
openssl
	...so I know that I have to remove those packages named above that
have been compile for i386 architecture.

Normally I'd manually remove the i386 packages...

[root at lappydappydoo updates]# ls glibc*
glibc-2.3.2-27.9.i386.rpm  <-- nuke this RPM
glibc-2.3.2-27.9.i686.rpm
glibc-common-2.3.2-27.9.i386.rpm
glibc-debug-2.3.2-27.9.i386.rpm    
glibc-devel-2.3.2-27.9.i386.rpm
glibc-profile-2.3.2-27.9.i386.rpm
glibc-utils-2.3.2-27.9.i386.rpm         

	This is the part I want to script (and the point of this novella) -
what would be the best (automated) method to remove the "duplicate" RPMs
with i386 architecture?  I have some ideas, but don't want to start
arbitrarily blasting files by piping things through "rm -rf"


	The rest is pretty straight forward - I can just export the
"updates" directory via NFS/FTP and run "rpm -Fvh $(ls *.rpm | egrep -v
'^(kernel-)')" from local clients ("install"ing the kernels rather than
"freshen"ing)   If it's not obvious, trying to run a wild-carded RPM against
a directory that contains RPMs for both architectures will, in fact, cause
dep issues....


Don



More information about the wplug mailing list