1cdf0e10cSrcweir#!/bin/bash
2*9f22d7c2SAndrew Rist# *************************************************************
3*9f22d7c2SAndrew Rist#
4*9f22d7c2SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
5*9f22d7c2SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
6*9f22d7c2SAndrew Rist#  distributed with this work for additional information
7*9f22d7c2SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
8*9f22d7c2SAndrew Rist#  to you under the Apache License, Version 2.0 (the
9*9f22d7c2SAndrew Rist#  "License"); you may not use this file except in compliance
10*9f22d7c2SAndrew Rist#  with the License.  You may obtain a copy of the License at
11*9f22d7c2SAndrew Rist#
12*9f22d7c2SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
13*9f22d7c2SAndrew Rist#
14*9f22d7c2SAndrew Rist#  Unless required by applicable law or agreed to in writing,
15*9f22d7c2SAndrew Rist#  software distributed under the License is distributed on an
16*9f22d7c2SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17*9f22d7c2SAndrew Rist#  KIND, either express or implied.  See the License for the
18*9f22d7c2SAndrew Rist#  specific language governing permissions and limitations
19*9f22d7c2SAndrew Rist#  under the License.
20*9f22d7c2SAndrew Rist#
21*9f22d7c2SAndrew Rist# *************************************************************
22cdf0e10cSrcweir
23cdf0e10cSrcweir# Linux deinstallation
24cdf0e10cSrcweir# No parameter required, all RPMs listed in $HOME/.RPM_OFFICEDATABASE
25cdf0e10cSrcweir# will be removed.
26cdf0e10cSrcweir
27cdf0e10cSrcweirif [ $# -ne 1 ]
28cdf0e10cSrcweirthen
29cdf0e10cSrcweir  echo
30cdf0e10cSrcweir  echo "Usage:" $0 "<office-installation-dir>"
31cdf0e10cSrcweir  echo "    <inst-destination-dir>: directory where the office to be removed is installed"
32cdf0e10cSrcweir  echo
33cdf0e10cSrcweir  exit 2
34cdf0e10cSrcweirfi
35cdf0e10cSrcweir
36cdf0e10cSrcweirINSTALLDIR=$1
37cdf0e10cSrcweir
38cdf0e10cSrcweir# Check for old style .RPM_OFFICEDATABASE first
39cdf0e10cSrcweirif [ -d ${INSTALLDIR}/.RPM_OFFICEDATABASE ]; then
40cdf0e10cSrcweir  RPM_DB_PATH=${INSTALLDIR}/.RPM_OFFICEDATABASE
41cdf0e10cSrcweirelse
42cdf0e10cSrcweir  RPM_DB_PATH=${INSTALLDIR}/.RPM_DATABASE
43cdf0e10cSrcweirfi
44cdf0e10cSrcweir
45cdf0e10cSrcweir# the RPM_DB_PATH must be absolute
46cdf0e10cSrcweirif [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then
47cdf0e10cSrcweir  RPM_DB_PATH=`cd ${RPM_DB_PATH}; pwd`
48cdf0e10cSrcweirfi
49cdf0e10cSrcweir
50cdf0e10cSrcweirRPMLIST=`rpm --dbpath $RPM_DB_PATH --query --all`
51cdf0e10cSrcweir
52cdf0e10cSrcweir# Output ...
53cdf0e10cSrcweirclear
54cdf0e10cSrcweirecho "#########################################"
55cdf0e10cSrcweirecho "#     Deinstallation of Office RPMs     #"
56cdf0e10cSrcweirecho "#########################################"
57cdf0e10cSrcweirecho
58cdf0e10cSrcweirecho "Path to the RPM database: " $RPM_DB_PATH
59cdf0e10cSrcweirecho "RPMs to deinstall:"
60cdf0e10cSrcweirecho "$RPMLIST"
61cdf0e10cSrcweirecho "===================================================================="
62cdf0e10cSrcweirecho
63cdf0e10cSrcweir
64cdf0e10cSrcweir# Restore original bootstraprc
65cdf0e10cSrcweirmv -f $1/program/bootstraprc.orig $1/program/bootstraprc
66cdf0e10cSrcweir
67cdf0e10cSrcweirrpm --dbpath $RPM_DB_PATH --erase $RPMLIST || exit 2
68cdf0e10cSrcweir
69cdf0e10cSrcweirecho "Removing RPM database ..."
70cdf0e10cSrcweirrm -rf $RPM_DB_PATH
71cdf0e10cSrcweir
72cdf0e10cSrcweirecho
73cdf0e10cSrcweirecho "Deinstallation done."
74cdf0e10cSrcweir
75cdf0e10cSrcweirexit 0
76