Avoid potential negative array index access to cached text.
[LibreOffice.git] / setup_native / scripts / uninstall_linux.sh
blobd0f062c50fdf6103f1ae195dec732499d7e5df45
1 #!/usr/bin/env bash
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # Linux deinstallation
21 # No parameter required, all RPMs listed in $HOME/.RPM_OFFICEDATABASE
22 # will be removed.
24 if [ $# -ne 1 ]
25 then
26 echo
27 echo "Usage:" $0 "<office-installation-dir>"
28 echo " <inst-destination-dir>: directory where the office to be removed is installed"
29 echo
30 exit 2
33 INSTALLDIR=$1
35 # Check for old style .RPM_OFFICEDATABASE first
36 if [ -d ${INSTALLDIR}/.RPM_OFFICEDATABASE ]; then
37 RPM_DB_PATH=${INSTALLDIR}/.RPM_OFFICEDATABASE
38 else
39 RPM_DB_PATH=${INSTALLDIR}/.RPM_DATABASE
42 # the RPM_DB_PATH must be absolute
43 if [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then
44 RPM_DB_PATH=`cd ${RPM_DB_PATH}; pwd`
47 RPMLIST=`rpm --dbpath $RPM_DB_PATH --query --all`
49 # Output ...
50 clear
51 echo "#########################################"
52 echo "# Deinstallation of Office RPMs #"
53 echo "#########################################"
54 echo
55 echo "Path to the RPM database: " $RPM_DB_PATH
56 echo "RPMs to deinstall:"
57 echo "$RPMLIST"
58 echo "===================================================================="
59 echo
61 # Restore original bootstraprc
62 mv -f $1/program/bootstraprc.orig $1/program/bootstraprc
64 rpm --dbpath $RPM_DB_PATH --erase $RPMLIST || exit 2
66 echo "Removing RPM database ..."
67 rm -rf $RPM_DB_PATH
69 echo
70 echo "Deinstallation done."
72 exit 0