Voici un petit script de mon cru pour voir si un patch est installé ou si il est obsolété par un autre. C’est sûrement plein de fôte comme c’est moi qui l’ai fé… :-D


#!/usr/bin/ksh
#
# Test if patch $1 is installed or if it's obsoleted by another one
#
#export DEBUG=1
[ -z $1 ] && echo "Please provide a patch (123456-78)" && exit 10

patch=$(echo $1 | awk -F- '{print $1}')
rev=$(echo $1 | awk -F- '{print $2}')

[ ! -z $DEBUG ] &&  echo "patch is $patch and rev is $rev"

tmpfile=/tmp/tempatch.$$

showrev -p > $tmpfile

grep $patch $tmpfile | while read a b c d
do
        mpatch=$(echo $b | awk -F- '{print $1}')
        mrev=$(echo $b | awk -F- '{print $2}')
        if [ "$mpatch" -eq "$patch" -a "$mrev" -ge "$rev" ]
        then
                echo "patch ${mpatch}-${mrev} is installed and is equal or higher that requested patch"
        fi
        req=0
        for i in $(echo $d)
        do
                i=$(echo $i | sed -e 's/,//g')
                [ "$i" == "Requires:" ] && req=1
                if [ $req -eq 0 ]
                then
                        npatch=$(echo $i | awk -F- '{print $1}')
                        nrev=$(echo $i | awk -F- '{print $2}')
                        if [ "$npatch" -eq "$patch" -a "$nrev" -ge "$rev" ]
                        then
                                echo "patch ${mpatch}-${mrev} is installed and obsolete requested patch"
                        fi
                fi
        done
done
rm $tmpfile

Tagged with:
 

Comments are closed.

Set your Twitter account name in your settings to use the TwitterBar Section.