RHEL 4 RPMs update manually
For those who have an account but do not register any server on the RHN, or you have a dozen of Penguin OSes with only 1 license. And for those who don't bother to use yum. This script might help you a bit hopefully. I download all the latest RPMs (into /var/ftp/pub/RHEL4/RedHat/rhn-packages) based on the General Advisories into an NFS mount point, from the NFS client, run this script (save it under /rhn-packages) and it will tell you what RPMs you need to update. It is not something fancy though... and I don't mind people think it is cramp...
#!/bin/sh
Result() {
echo "$i-${INST_VER[$x]}-${INST_REL[$x]} -- $a-${AVAL_VER[$y]}-${AVAL_REL[$y]}"
z=$((z+1))
}
# Collect all installed RPMs
CheckInstalledRPM() {
INST_RPM=(`rpm -qa | sort`)
x=$((0))
for i in ${INST_RPM[@]}; do
INST_REL[$x]=`echo $i | sed 's/^.*-//'`
INST_VER[$x]=`echo $i | sed "s/-${INST_REL[$x]}$//" | sed 's/^.*-//'`
INST_NAME[$x]=`echo $i | sed "s/-${INST_REL[$x]}$//" | sed "s/-${INST_VER[$x]}$//"`
x=$((x+1))
done
INST_RPM_IDX=$((x-1))
#----------------------------------------
# DEBUG
#echo $INST_RPM_IDX
#echo "${INST_NAME[0]}--${INST_VER[0]}--${INST_REL[0]}"
#echo "${INST_NAME[$INST_RPM_IDX]}--${INST_VER[$INST_RPM_IDX]}--${INST_REL[$INST_RPM_IDX]}"
#----------------------------------------
}
CheckAvailableRPM() {
# Collect all available updated RPMs
AVAL_RPM=(`ls *.rpm | sed 's/\.i.86.rpm//'`)
x=$((0))
for i in ${AVAL_RPM[@]}; do
AVAL_REL[$x]=`echo $i | sed 's/^.*-//'`
AVAL_VER[$x]=`echo $i | sed "s/-${AVAL_REL[$x]}$//" | sed 's/^.*-//'`
AVAL_NAME[$x]=`echo $i | sed "s/-${AVAL_REL[$x]}$//" | sed "s/-${AVAL_VER[$x]}$//"`
x=$((x+1))
done
AVAL_RPM_IDX=$((x-1))
#----------------------------------------
# DEBUG
#echo $AVAL_RPM_IDX
#echo "${AVAL_NAME[0]}--${AVAL_VER[0]}--${AVAL_REL[0]}"
#echo "${AVAL_NAME[$AVAL_RPM_IDX]}--${AVAL_VER[$AVAL_RPM_IDX]}--${AVAL_REL[$AVAL_RPM_IDX]}"
#----------------------------------------
}
CompareRPM() {
# Compare installed RPMs against available updated RPMs
x=$((0))
z=$((0))
for i in ${INST_NAME[@]}; do
y=$((0))
for a in ${AVAL_NAME[@]}; do
if [ $i = $a ]; then
if [ ${INST_VER[$x]} = ${AVAL_VER[$y]} ]; then
if [ ${INST_REL[$x]} != ${AVAL_REL[$y]} ]; then
Result
fi
else
Result
fi
fi
y=$((y+1))
done
x=$((x+1))
done
}
End() {
echo
if [ $z -eq 0 ]; then
echo "System is up to date."
else
echo "$z update RPMs are available."
fi
echo
}
CheckInstalledRPM
CheckAvailableRPM
CompareRPM
End
|