#!/bin/bash True=0 #As far as bash is concerned False=1 #"functions" not needed yet: #if [ ! -f ./functions ]; then # echo Missing ./functions, exiting. >/dev/stderr # exit 1 #fi #. ./functions CondMkdir () { while [ -n "$1" ]; do if [ -e "$1" ]; then if [ ! -d "$1" ]; then echo "$1" exists but is not a directory, exiting. exit 1 fi else mkdir --parents "$1" fi shift done } #Shows all rpm tags #( for OneFormat in `rpm --querytags | sort` ; do echo -en "$OneFormat\t" ; rpm -q --queryformat "%{$OneFormat}" -p iptables-1.1.2-1.i386.rpm ; echo ; done ) | less ChooseRpmToDelete () { #This takes two rpm filenames on the command line and echoes back to #stdout which, if either, to delete. A 1 is returned if rpm 1 is to #be nuked, 2 if rpm 2. Return code of True means there is a file to #delete. if [ "$#" != "2" ]; then echo Incorrect number of args to ChooseRpmToDelete: \""$*"\", exiting. >/dev/stderr exit 1 fi if [ ! -f "$1" ] || [ ! -f "$2" ]; then echo Either "$1" or "$2" is not a file, exiting. >/dev/stderr exit 1 fi Rpm1Name=`rpm -q --queryformat "%{NAME}" -p "$1"` Rpm2Name=`rpm -q --queryformat "%{NAME}" -p "$2"` if [ "$Rpm1Name" != "$Rpm2Name" ]; then #Not the same base package name, keep both. Future compares may delete one or the other. return $False fi Rpm1Arch=`rpm -q --queryformat "%{ARCH}" -p "$1"` Rpm2Arch=`rpm -q --queryformat "%{ARCH}" -p "$2"` if [ "$Rpm1Arch" != "$Rpm2Arch" ]; then #We have different architectures. Keep the higher, suggest deletion of the lower. if [ "$Rpm1Arch" = "i386" ]; then echo "1" ; return $True elif [ "$Rpm2Arch" = "i386" ]; then echo "2" ; return $True elif [ "$Rpm1Arch" = "i486" ]; then echo "1" ; return $True elif [ "$Rpm2Arch" = "i486" ]; then echo "2" ; return $True elif [ "$Rpm1Arch" = "i586" ]; then echo "1" ; return $True elif [ "$Rpm2Arch" = "i586" ]; then echo "2" ; return $True elif [ "$Rpm1Arch" = "athlon" ]; then echo "1" ; return $True elif [ "$Rpm2Arch" = "athlon" ]; then echo "2" ; return $True else echo "Unable to resolve preferred architecture between \"$1\" and \"$2\", exiting." >/dev/stderr exit 1 fi fi Rpm1Buildtime=`rpm -q --queryformat "%{BUILDTIME}" -p "$1"` Rpm2Buildtime=`rpm -q --queryformat "%{BUILDTIME}" -p "$2"` if [ $Rpm1Buildtime -gt $Rpm2Buildtime ]; then echo "2" ; return $True elif [ $Rpm1Buildtime -lt $Rpm2Buildtime ]; then echo "1" ; return $True else echo "Identical arch and buildstamps, how do I handle \"$1\" and \"$2\"? Exiting." >/dev/stderr exit 1 fi } CleanOldRpms () { #This function is designed to delete the older/less desirable versions #of two or more rpms that provide the same thing. The sole parameter #is the name of a directory holding the RPMs to be deleted. if [ $# != 1 ]; then echo "Too few/many args to CleanOldRpms: \"$*\", exiting." >/dev/stderr exit 1 fi if [ ! -d "$1" ]; then echo "\"$1\" is not a directory, exiting." >/dev/stderr exit 1 fi cd $1 if [ "`pwd`" != "$1" ]; then echo Not in the right directory, exiting. exit 1 fi LastFile='' for TestFile in *.rpm ; do if [ -z "$LastFile" ]; then LastFile="$TestFile" continue fi if SuggestDeleteFile=`ChooseRpmToDelete "$LastFile" "$TestFile"` ; then #Debug echo -n "Deciding between \"$LastFile\" and \"$TestFile\". " >>/mnt/mirrors/buildsource/debug case $SuggestDeleteFile in 1) echo "Deleting $LastFile" >>/mnt/mirrors/buildsource/debug rm -f "$LastFile" LastFile="$TestFile" ;; 2) echo "Deleting $TestFile" >>/mnt/mirrors/buildsource/debug rm -f "$TestFile" #DO NOT assign testfile to lastfile ;; *) echo "Umm, just what was I supposed to delete? \"$SuggestDeleteFile\". Exiting" >/dev/stderr exit 1 ;; esac else #Test function didn't suggest deleting either, just continue #echo -e "$LastFile\t$TestFile" LastFile="$TestFile" fi done cd - } LinkIn () { #Hardlinks all the files in the CL specified dirs and hardlinks them #into the current directory. while [ -n "$1" ]; do if [ -d "$1" ]; then find "$1" -type f -exec ln -f {} . \; elif [ -f "$1" ]; then ln -f "$1" . fi shift done } CondMkdir /mnt/mirrors/pub/uml/pristineroots /mnt/mirrors/buildsource \ /mnt/mirrors/buildsource/temp cd /mnt/mirrors/buildsource if [ "`pwd`" != "/mnt/mirrors/buildsource" ]; then echo Not in the right directory, exiting. exit 1 fi if [ -x mkswapfs ]; then ./mkswapfs chmod 644 swap cp -pf --sparse=always swap swap.pristine bzip2 -9 swap.pristine mv -f swap.pristine.bz2 /mnt/mirrors/pub/uml/pristineroots else echo 'Missing executable mkswapfs? Exiting' >/dev/stderr exit fi #Redhat 6.2 CondMkdir rh/6.2 if cd rh/6.2 ; then ( cd /usr/src ; rm -f rh62source ; ln -sf ../../mnt/mirrors/buildsource/rh/6.2 rh62source ) echo Linking `pwd` rm * LinkIn /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/linux/6.2/en/os/i386/RedHat/RPMS/ \ /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/linux/updates/6.2/en/os/i386/ \ /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/linux/updates/6.2/en/os/i686/ \ /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/linux/updates/6.2/en/os/noarch/ \ /mnt/mirrors/buildsource/addons/devfsd*.rpm \ /mnt/mirrors/buildsource/addons/iptables*.rpm \ /mnt/mirrors/buildsource/addons/ssh*.rpm #Delete old versions of updated files CleanOldRpms /mnt/mirrors/buildsource/rh/6.2 #Any manual deletions here #rm -f goober.... cd ../.. rm -f rh62.provides 2>/dev/null ./mkrootfs rh62 rm -f root_fs.rh62.pristine mv root_fs root_fs.rh62.pristine chmod 444 root_fs.rh62.pristine cp -pf --sparse=always root_fs.rh62.pristine temp bzip2 -9 temp/root_fs.rh62.pristine mv -f temp/root_fs.rh62.pristine.bz2 /mnt/mirrors/pub/uml/pristineroots fi #ZZZZ exit #Redhat 7.2 CondMkdir rh/7.2 if cd rh/7.2 ; then ( cd /usr/src ; rm -f rh72source ; ln -sf ../../mnt/mirrors/buildsource/rh/7.2 rh72source ) echo Linking `pwd` rm * LinkIn /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/linux/7.2/en/os/i386/RedHat/RPMS/ \ /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/linux/updates/7.2/en/os/i386/ \ /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/linux/updates/7.2/en/os/i686/ \ /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/linux/updates/7.2/en/os/noarch/ #Delete old versions of updated files CleanOldRpms /mnt/mirrors/buildsource/rh/7.2 #Any manual deletions here #rm -f goober.... cd ../.. rm -f rh72.provides 2>/dev/null ./mkrootfs rh72 rm -f root_fs.rh72.pristine mv root_fs root_fs.rh72.pristine chmod 444 root_fs.rh72.pristine cp -pf --sparse=always root_fs.rh72.pristine temp bzip2 -9 temp/root_fs.rh72.pristine mv -f temp/root_fs.rh72.pristine.bz2 /mnt/mirrors/pub/uml/pristineroots fi #Mandrake 8.1 #ZZZZ CondMkdir md/8.1 if cd md/8.1 ; then ( cd /usr/src ; rm -f md81source ; ln -sf ../../mnt/mirrors/buildsource/md/8.1 md81source ) echo Linking `pwd` rm * LinkIn /mnt/mirrors/pub/mirrors/ftp.mandrakesoft.com/pub/Mandrake/mandrake/8.1/i586/Mandrake/RPMS/ \ /mnt/mirrors/pub/mirrors/ftp.mandrakesoft.com/pub/Mandrake/mandrake/updates/8.1/RPMS/ CleanOldRpms /mnt/mirrors/buildsource/md/8.1 #Any manual deletions here #The following is not stricly necessary, but both it and the glibc- #package provide glibc. It shouldn't be necessary except in the #case of compiling for mandrake 7.2 rm -f compat-glibc-7.2-2.1.3.3mdk.i586.rpm cd ../.. rm -f md81.provides 2>/dev/null ./mkrootfs md81 rm -f root_fs.md81.pristine mv root_fs root_fs.md81.pristine chmod 444 root_fs.md81.pristine cp -pf --sparse=always root_fs.md81.pristine temp bzip2 -9 temp/root_fs.md81.pristine mv -f temp/root_fs.md81.pristine.bz2 /mnt/mirrors/pub/uml/pristineroots fi #Mandrake 8.0 #ZZZZ CondMkdir md/8.0 if cd md/8.0 ; then ( cd /usr/src ; rm -f md80source ; ln -sf ../../mnt/mirrors/buildsource/md/8.0 md80source ) echo Linking `pwd` rm * LinkIn /mnt/mirrors/pub/mirrors/ftp.mandrakesoft.com/pub/Mandrake/mandrake/8.0/i586/Mandrake/RPMS/ \ /mnt/mirrors/pub/mirrors/ftp.mandrakesoft.com/pub/Mandrake/mandrake/updates/8.0/RPMS/ CleanOldRpms /mnt/mirrors/buildsource/md/8.0 #Any manual deletions here #The following is not stricly necessary, but both it and the glibc- #package provide glibc. It shouldn't be necessary except in the #case of compiling for mandrake 7.2 rm -f compat-glibc-7.2-2.1.3.3mdk.i586.rpm cd ../.. rm -f md80.provides 2>/dev/null ./mkrootfs md80 rm -f root_fs.md80.pristine mv root_fs root_fs.md80.pristine chmod 444 root_fs.md80.pristine cp -pf --sparse=always root_fs.md80.pristine temp bzip2 -9 temp/root_fs.md80.pristine mv -f temp/root_fs.md80.pristine.bz2 /mnt/mirrors/pub/uml/pristineroots fi exit #------------------------------------------------------ #End of builds #------------------------------------------------------ #Hmmm, not working yet either. Pam doesn't provide cracklib. #Immunix 6.2 CondMkdir im/6.2 if cd im/6.2 ; then ( cd /usr/src ; rm -f im62source ; ln -sf ../../mnt/mirrors/buildsource/im/6.2 im62source ) echo Linking `pwd` rm * LinkIn /mnt/mirrors/pub/mirrors/www.immunix.org/ImmunixOS/6.2/i386/RedHat/RPMS/ \ /mnt/mirrors/pub/mirrors/www.immunix.org/ImmunixOS/6.2/updates/RPMS/ \ /mnt/mirrors/buildsource/addons/devfsd*.rpm \ /mnt/mirrors/buildsource/addons/iptables*.rpm \ /mnt/mirrors/buildsource/addons/ssh*.rpm #Delete old versions of updated files CleanOldRpms /mnt/mirrors/buildsource/im/6.2 #Any manual deletions here #rm -f goober.... cd ../.. rm -f im62.provides 2>/dev/null ./mkrootfs im62 rm -f root_fs.im62.pristine mv root_fs root_fs.im62.pristine chmod 444 root_fs.im62.pristine cp -pf --sparse=always root_fs.im62.pristine temp bzip2 -9 temp/root_fs.im62.pristine mv -f temp/root_fs.im62.pristine.bz2 /mnt/mirrors/pub/uml/pristineroots fi #Hmmm, not working yet #Conectiva 7.0 CondMkdir co/7.0 if cd co/7.0 ; then ( cd /usr/src ; rm -f co70source ; ln -sf ../../mnt/mirrors/buildsource/co/7.0 co70source ) echo Linking `pwd` rm * LinkIn /mnt/mirrors/pub/mirrors/conectiva-rsync/7.0/cd1/conectiva/RPMS/ \ /mnt/mirrors/pub/mirrors/conectiva-rsync/7.0/cd1/conectiva/RPMS.updates/ \ /mnt/mirrors/pub/mirrors/conectiva-rsync/7.0/cd2/conectiva/RPMS/ \ /mnt/mirrors/pub/mirrors/conectiva-rsync/updates/7.0/RPMS/ CleanOldRpms /mnt/mirrors/buildsource/co/7.0 #Any manual deletions here rm -f /usr/src/co70source/kernel-enterprise-2.2.19-25U70_2cl.i686.rpm \ /usr/src/co70source/kernel-smp-2.2.19-25U70_2cl.i686.rpm cd ../.. rm -f co70.provides 2>/dev/null ./mkrootfs co70 rm -f root_fs.co70.pristine mv root_fs root_fs.co70.pristine chmod 444 root_fs.co70.pristine cp -pf --sparse=always root_fs.co70.pristine temp bzip2 -9 temp/root_fs.co70.pristine mv -f temp/root_fs.co70.pristine.bz2 /mnt/mirrors/pub/uml/pristineroots fi ##Suse 8.0 ##ZZZZ - not done yet. #CondMkdir su/8.0 #if cd su/8.0 ; then # ( cd /usr/src ; rm -f su80source ; ln -sf ../../mnt/mirrors/buildsource/su/8.0 su80source ) # echo Linking `pwd` # rm * # # LinkIn /mnt/mirrors/pub/mirrors/ftp.mandrakesoft.com/pub/Mandrake/mandrake/8.0/i586/Mandrake/RPMS/ \ # /mnt/mirrors/pub/mirrors/ftp.mandrakesoft.com/pub/Mandrake/mandrake/updates/8.0/RPMS/ # # #rm -f \ # # cd ../.. # # rm -f md80.provides 2>/dev/null # ./mkrootfs md80 # rm -f root_fs.md80.pristine # mv root_fs root_fs.md80.pristine # chmod 444 root_fs.md80.pristine # # cp -pf --sparse=always root_fs.md80.pristine temp # bzip2 -9 temp/root_fs.md80.pristine # mv -f temp/root_fs.md80.pristine.bz2 /mnt/mirrors/pub/uml/pristineroots #fi ##Skip rh7.1, no longer built ##Redhat 7.1 #CondMkdir rh/7.1 #if cd rh/7.1 ; then # ( cd /usr/src ; rm -f rh71source ; ln -sf ../../mnt/mirrors/buildsource/rh/7.1 rh71source ) # echo Linking `pwd` # rm * # LinkIn /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/redhat-7.1-en/os/i386/RedHat/RPMS/ \ # /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/updates/7.1/en/os/i386/ \ # /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/updates/7.1/en/os/i686/ \ # /mnt/mirrors/pub/mirrors/redhat-rsync/pub/redhat/updates/7.1/en/os/noarch/ # # #Delete old versions of updated files # CleanOldRpms /mnt/mirrors/buildsource/rh/7.1 # #Any manual deletions here # #rm -f goober.... # # cd ../.. # # rm -f rh71.provides 2>/dev/null # ./mkrootfs rh71 # rm -f root_fs.rh71.pristine # mv root_fs root_fs.rh71.pristine # chmod 444 root_fs.rh71.pristine # # cp -pf --sparse=always root_fs.rh71.pristine temp # bzip2 -9 temp/root_fs.rh71.pristine # mv -f temp/root_fs.rh71.pristine.bz2 /mnt/mirrors/pub/uml/pristineroots #fi ##No longer built ##Conectiva 6.0 #CondMkdir co/6.0 #if cd co/6.0 ; then # ( cd /usr/src ; rm -f co60source ; ln -sf ../../mnt/mirrors/buildsource/co/6.0 co60source ) # echo Linking `pwd` # rm * # LinkIn /mnt/mirrors/pub/mirrors/ftp.conectiva.com/pub/conectiva/6.0/cd1/conectiva/RPMS/ \ # /mnt/mirrors/pub/mirrors/ftp.conectiva.com/pub/conectiva/6.0/cd2/RPMS/ \ # /mnt/mirrors/pub/mirrors/ftp.conectiva.com/pub/conectiva/updates/6.0/RPMS/ # # CleanOldRpms /mnt/mirrors/buildsource/co/6.0 # #Any manual deletions here # #rm -f goober.... # # cd ../.. # # rm -f co60.provides 2>/dev/null # ./mkrootfs co60 # rm -f root_fs.co60.pristine # mv root_fs root_fs.co60.pristine # chmod 444 root_fs.co60.pristine # # cp -pf --sparse=always root_fs.co60.pristine temp # bzip2 -9 temp/root_fs.co60.pristine # mv -f temp/root_fs.co60.pristine.bz2 /mnt/mirrors/pub/uml/pristineroots #fi