1*cdf0e10cSrcweir#!/bin/sh 2*cdf0e10cSrcweir 3*cdf0e10cSrcweirMYUID=`id | sed "s/(.*//g" | sed "s/.*=//"` 4*cdf0e10cSrcweir 5*cdf0e10cSrcweirif [ $MYUID -ne 0 ] 6*cdf0e10cSrcweirthen 7*cdf0e10cSrcweir echo You need to have super-user permissions to run this patch script 8*cdf0e10cSrcweir exit 1 9*cdf0e10cSrcweirfi 10*cdf0e10cSrcweir 11*cdf0e10cSrcweirecho 12*cdf0e10cSrcweirecho "Searching for the PRODUCTNAMEPLACEHOLDER installation ..." 13*cdf0e10cSrcweir 14*cdf0e10cSrcweirRPMNAME=`rpm -qa | grep SEARCHPACKAGENAMEPLACEHOLDER` 15*cdf0e10cSrcweir 16*cdf0e10cSrcweirif [ "x$RPMNAME" != "x" ] 17*cdf0e10cSrcweirthen 18*cdf0e10cSrcweir PRODUCTINSTALLLOCATION="`rpm --query --queryformat "%{INSTALLPREFIX}" $RPMNAME`" 19*cdf0e10cSrcweir FULLPRODUCTINSTALLLOCATION="${PRODUCTINSTALLLOCATION}/PRODUCTDIRECTORYNAME" 20*cdf0e10cSrcweirelse 21*cdf0e10cSrcweir echo "PRODUCTNAMEPLACEHOLDER is not installed" 22*cdf0e10cSrcweir exit 1 23*cdf0e10cSrcweirfi 24*cdf0e10cSrcweir 25*cdf0e10cSrcweir# Last chance to exit .. 26*cdf0e10cSrcweirecho 27*cdf0e10cSrcweirread -p "Patching the installation in ${FULLPRODUCTINSTALLLOCATION}. Continue (y/n) ? " -n 1 reply leftover 28*cdf0e10cSrcweirecho 29*cdf0e10cSrcweir[ "$reply" == "y" ] || exit 1 30*cdf0e10cSrcweir 31*cdf0e10cSrcweirecho 32*cdf0e10cSrcweirecho "About to update the following packages ..." 33*cdf0e10cSrcweir 34*cdf0e10cSrcweirBASEDIR=`dirname $0` 35*cdf0e10cSrcweir 36*cdf0e10cSrcweirRPMLIST="" 37*cdf0e10cSrcweirfor i in `ls $BASEDIR/RPMS/*.rpm` 38*cdf0e10cSrcweirdo 39*cdf0e10cSrcweir rpm --query `rpm --query --queryformat "%{NAME}\n" --package $i` && RPMLIST="$RPMLIST $i" 40*cdf0e10cSrcweirdone 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir# Save UserInstallation value 43*cdf0e10cSrcweirBOOTSTRAPRC="${FULLPRODUCTINSTALLLOCATION}/program/bootstraprc" 44*cdf0e10cSrcweirUSERINST=`grep UserInstallation ${BOOTSTRAPRC}` 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir# Check, if kde-integration rpm is available 47*cdf0e10cSrcweirKDERPM=`ls $BASEDIR/RPMS/*.rpm | grep kde-integration` 48*cdf0e10cSrcweir 49*cdf0e10cSrcweirif [ "x$KDERPM" != "x" ]; then 50*cdf0e10cSrcweir # Check, that $RPMLIST does not contain kde integration rpm (then it is already installed) 51*cdf0e10cSrcweir KDERPMINSTALLED=`grep kde-integration ${RPMLIST}` 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir if [ "x$KDERPMINSTALLED" == "x" ]; then 54*cdf0e10cSrcweir # Install the kde integration rpm 55*cdf0e10cSrcweir RPMLIST="$RPMLIST $KDERPM" 56*cdf0e10cSrcweir fi 57*cdf0e10cSrcweirfi 58*cdf0e10cSrcweir 59*cdf0e10cSrcweirecho 60*cdf0e10cSrcweirrpm --upgrade -v --hash --prefix $PRODUCTINSTALLLOCATION --notriggers $RPMLIST 61*cdf0e10cSrcweirecho 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir# Some RPM versions have problems with -U and --prefix 64*cdf0e10cSrcweirif [ ! -f ${BOOTSTRAPRC} ]; then 65*cdf0e10cSrcweir echo Update failed due to a bug in RPM, uninstalling .. 66*cdf0e10cSrcweir rpm --erase -v --nodeps --notriggers `rpm --query --queryformat "%{NAME} " --package $RPMLIST` 67*cdf0e10cSrcweir echo 68*cdf0e10cSrcweir echo Now re-installing new packages .. 69*cdf0e10cSrcweir echo 70*cdf0e10cSrcweir rpm --install -v --hash --prefix $PRODUCTINSTALLLOCATION --notriggers $RPMLIST 71*cdf0e10cSrcweir echo 72*cdf0e10cSrcweirfi 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir# Restore the UserInstallation key if necessary 75*cdf0e10cSrcweirDEFUSERINST=`grep UserInstallation ${BOOTSTRAPRC}` 76*cdf0e10cSrcweirif [ "${USERINST}" != "${DEFUSERINST}" ]; then 77*cdf0e10cSrcweir mv -f ${BOOTSTRAPRC} ${BOOTSTRAPRC}.$$ 78*cdf0e10cSrcweir sed "s|UserInstallation.*|${USERINST}|" ${BOOTSTRAPRC}.$$ > ${BOOTSTRAPRC} 79*cdf0e10cSrcweir rm -f ${BOOTSTRAPRC}.$$ 80*cdf0e10cSrcweirfi 81*cdf0e10cSrcweir 82*cdf0e10cSrcweirecho "Done." 83*cdf0e10cSrcweir 84*cdf0e10cSrcweirexit 0 85