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