1#!/bin/sh 2# ************************************************************* 3# 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the 9# "License"); you may not use this file except in compliance 10# with the License. You may obtain a copy of the License at 11# 12# http://www.apache.org/licenses/LICENSE-2.0 13# 14# Unless required by applicable law or agreed to in writing, 15# software distributed under the License is distributed on an 16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17# KIND, either express or implied. See the License for the 18# specific language governing permissions and limitations 19# under the License. 20# 21# ************************************************************* 22 23MYUID=`id | sed "s/(.*//g" | sed "s/.*=//"` 24 25if [ $MYUID -ne 0 ] 26then 27 echo You need to have super-user permissions to run this patch script 28 exit 1 29fi 30 31echo 32echo "Searching for the PRODUCTNAMEPLACEHOLDER installation ..." 33 34RPMNAME=`rpm -qa | grep SEARCHPACKAGENAMEPLACEHOLDER` 35 36if [ "x$RPMNAME" != "x" ] 37then 38 PRODUCTINSTALLLOCATION="`rpm --query --queryformat "%{INSTALLPREFIX}" $RPMNAME`" 39 FULLPRODUCTINSTALLLOCATION="${PRODUCTINSTALLLOCATION}/PRODUCTDIRECTORYNAME" 40else 41 echo "PRODUCTNAMEPLACEHOLDER is not installed" 42 exit 1 43fi 44 45# Last chance to exit .. 46echo 47read -p "Patching the installation in ${FULLPRODUCTINSTALLLOCATION}. Continue (y/n) ? " -n 1 reply leftover 48echo 49[ "$reply" == "y" ] || exit 1 50 51echo 52echo "About to update the following packages ..." 53 54BASEDIR=`dirname $0` 55 56RPMLIST="" 57for i in `ls $BASEDIR/RPMS/*.rpm` 58do 59 rpm --query `rpm --query --queryformat "%{NAME}\n" --package $i` && RPMLIST="$RPMLIST $i" 60done 61 62# Save UserInstallation value 63BOOTSTRAPRC="${FULLPRODUCTINSTALLLOCATION}/program/bootstraprc" 64USERINST=`grep UserInstallation ${BOOTSTRAPRC}` 65 66# Check, if kde-integration rpm is available 67KDERPM=`ls $BASEDIR/RPMS/*.rpm | grep kde-integration` 68 69if [ "x$KDERPM" != "x" ]; then 70 # Check, that $RPMLIST does not contain kde integration rpm (then it is already installed) 71 KDERPMINSTALLED=`grep kde-integration ${RPMLIST}` 72 73 if [ "x$KDERPMINSTALLED" == "x" ]; then 74 # Install the kde integration rpm 75 RPMLIST="$RPMLIST $KDERPM" 76 fi 77fi 78 79echo 80rpm --upgrade -v --hash --prefix $PRODUCTINSTALLLOCATION --notriggers $RPMLIST 81echo 82 83# Some RPM versions have problems with -U and --prefix 84if [ ! -f ${BOOTSTRAPRC} ]; then 85 echo Update failed due to a bug in RPM, uninstalling .. 86 rpm --erase -v --nodeps --notriggers `rpm --query --queryformat "%{NAME} " --package $RPMLIST` 87 echo 88 echo Now re-installing new packages .. 89 echo 90 rpm --install -v --hash --prefix $PRODUCTINSTALLLOCATION --notriggers $RPMLIST 91 echo 92fi 93 94# Restore the UserInstallation key if necessary 95DEFUSERINST=`grep UserInstallation ${BOOTSTRAPRC}` 96if [ "${USERINST}" != "${DEFUSERINST}" ]; then 97 mv -f ${BOOTSTRAPRC} ${BOOTSTRAPRC}.$$ 98 sed "s|UserInstallation.*|${USERINST}|" ${BOOTSTRAPRC}.$$ > ${BOOTSTRAPRC} 99 rm -f ${BOOTSTRAPRC}.$$ 100fi 101 102echo "Done." 103 104exit 0 105