Update ooo320-m1
[ooovba.git] / setup_native / scripts / linuxpatchscript.sh
blob4c40db7d8f717149f1947e79ec9408a2a4df297d
1 #!/bin/sh
3 MYUID=`id | sed "s/(.*//g" | sed "s/.*=//"`
5 if [ $MYUID -ne 0 ]
6 then
7 echo You need to have super-user permissions to run this patch script
8 exit 1
9 fi
11 echo
12 echo "Searching for the PRODUCTNAMEPLACEHOLDER installation ..."
14 RPMNAME=`rpm -qa | grep SEARCHPACKAGENAMEPLACEHOLDER`
16 if [ "x$RPMNAME" != "x" ]
17 then
18 PRODUCTINSTALLLOCATION="`rpm --query --queryformat "%{INSTALLPREFIX}" $RPMNAME`"
19 FULLPRODUCTINSTALLLOCATION="${PRODUCTINSTALLLOCATION}/PRODUCTDIRECTORYNAME"
20 else
21 echo "PRODUCTNAMEPLACEHOLDER is not installed"
22 exit 1
25 # Last chance to exit ..
26 echo
27 read -p "Patching the installation in ${FULLPRODUCTINSTALLLOCATION}. Continue (y/n) ? " -n 1 reply leftover
28 echo
29 [ "$reply" == "y" ] || exit 1
31 echo
32 echo "About to update the following packages ..."
34 BASEDIR=`dirname $0`
36 RPMLIST=""
37 for i in `ls $BASEDIR/RPMS/*.rpm`
39 rpm --query `rpm --query --queryformat "%{NAME}\n" --package $i` && RPMLIST="$RPMLIST $i"
40 done
42 # Save UserInstallation value
43 BOOTSTRAPRC="${FULLPRODUCTINSTALLLOCATION}/program/bootstraprc"
44 USERINST=`grep UserInstallation ${BOOTSTRAPRC}`
46 # Check, if kde-integration rpm is available
47 KDERPM=`ls $BASEDIR/RPMS/*.rpm | grep kde-integration`
49 if [ "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}`
53 if [ "x$KDERPMINSTALLED" == "x" ]; then
54 # Install the kde integration rpm
55 RPMLIST="$RPMLIST $KDERPM"
59 echo
60 rpm --upgrade -v --hash --prefix $PRODUCTINSTALLLOCATION --notriggers $RPMLIST
61 echo
63 # Some RPM versions have problems with -U and --prefix
64 if [ ! -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
74 # Restore the UserInstallation key if necessary
75 DEFUSERINST=`grep UserInstallation ${BOOTSTRAPRC}`
76 if [ "${USERINST}" != "${DEFUSERINST}" ]; then
77 mv -f ${BOOTSTRAPRC} ${BOOTSTRAPRC}.$$
78 sed "s|UserInstallation.*|${USERINST}|" ${BOOTSTRAPRC}.$$ > ${BOOTSTRAPRC}
79 rm -f ${BOOTSTRAPRC}.$$
82 echo "Done."
84 exit 0