summaryrefslogtreecommitdiff
path: root/setup_native/scripts/install_linux.sh
diff options
context:
space:
mode:
authorChristof Pintaske <cp@openoffice.org>2004-10-07 16:14:06 +0000
committerChristof Pintaske <cp@openoffice.org>2004-10-07 16:14:06 +0000
commit96991f4e34353109bbb90c1ae7cb39b2c9cd998f (patch)
treee485dec7def8732759ec130412342393407dcd2b /setup_native/scripts/install_linux.sh
parentd0bad40495359d625f9b917b085375e479207532 (diff)
#34894# don't delete a directory unconditionally, ask the user to do so
Diffstat (limited to 'setup_native/scripts/install_linux.sh')
-rw-r--r--setup_native/scripts/install_linux.sh171
1 files changed, 114 insertions, 57 deletions
diff --git a/setup_native/scripts/install_linux.sh b/setup_native/scripts/install_linux.sh
index 9ea797395f1a..1a540a995131 100644
--- a/setup_native/scripts/install_linux.sh
+++ b/setup_native/scripts/install_linux.sh
@@ -1,22 +1,56 @@
#!/bin/bash
-# First parameter: Path to the RPM packages
-# Second parameter: Path to the installation
-# MY_OFFICE=/home/abc/opt/staroffice8-ea
-# PACKAGE_PATH=/cws/instset_native/unxlngi5.pro/StarOffice/install/en-US/RPMS/
+error()
+{
+ echo
+ printf "ERROR:\t$1\n"
+ echo
+ echo "User Mode Installation script for developer and knowledgeable early access tester"
+ echo
+ echo "This installation method is not intended for use in a production environment!"
+ echo "Using this script is unsupported and completely at your own risk"
+ echo
+ echo "Usage:" $0 "<rpm-source-dir> <office-installation-dir> [-l]"
+ echo " <rpm-source-dir>: directory *only* containing the Linux rpm packages to be installed"
+ echo " <inst-destination-dir>: directory to where the office will get installed into"
+ echo " -l: optional parameter to create a link \"soffice\" in $HOME"
+ echo
+ exit 2
+}
+
+cannot_install()
+{
+ echo
+ printf "ERROR:\tCannot proceed with the installation\n"
+ printf "\t$1\n"
+ echo
+ exit 2
+}
+
+#
+# expect either two or three arguments
+#
if [ \( $# -ne 2 -a $# -ne 3 \) -o -z "$1" -o -z "$2" ]
then
- echo "Two (optional three) parameters required"
- echo "Usage:"
- echo "1. parameter: Path to the RPM packages"
- echo "2. parameter: Path to the installation"
- echo "3. parameter (optional): \"-l\" (Creates a link \"soffice\" in $HOME)"
- exit 2
+ error "Wrong number of arguments"
fi
+#
+# this script is for userland not for root
+#
+
+if [ $UID -eq 0 ]
+then
+ error "This script is for installation without administrative rights only\n\tPlease use rpm to install as root"
+fi
+
+#
+# Evaluate command line arguments
+#
+
PACKAGE_PATH=$1
-MY_OFFICE=$2
+INSTALLDIR=$2
LINK="nolink"
if [ $# -eq 3 ]
@@ -26,75 +60,98 @@ fi
if [ ! -d $PACKAGE_PATH ]
then
- echo "$PACKAGE_PATH is not a valid directory"
- echo "Usage:"
- echo "1. parameter: Path to the RPM packages"
- echo "2. parameter: Path to the installation"
- echo "3. parameter (optional): \"-l\" (Creates a link \"soffice\" in $HOME)"
- exit 2
+ error "Directory $PACKAGE_PATH does not exist"
+fi
+
+if [ ! "${INSTALLDIR:0:1}" = "/" ]
+then
+ error "Invalid installation directory $INSTALLDIR, has to be an absolute path"
+fi
+
+#
+# Check and get the list of packages to install
+#
+
+RPMLIST=`find $PACKAGE_PATH -type f -name "*.rpm" ! -name "*-core-*" ! -name "*-menus-*" ! -name "adabas*" ! -name "j2re*" -print`
+CORERPM=`find $PACKAGE_PATH -type f -name "*.rpm" -name "*-core-*" -print`
+PREFIX=`rpm -qlp $CORERPM | head -n1`
+
+if [ -z "$CORERPM" ]
+then
+ error "No core package found in directory $PACKAGE_PATH"
+fi
+
+echo "Packages found:"
+for i in $CORERPM $RPMLIST; do
+ echo `basename $i`
+done
+
+#
+# Check/Create installation directory
+#
+
+# We expect that $INSTALLDIR does not exist, however if it is empty we ignore it
+if [ -d $INSTALLDIR ]
+then
+ # if it is not empty we cannot rm it (might be a permission problem as well)
+ rmdir $INSTALLDIR
+fi
+if [ -d $INSTALLDIR ]
+then
+ cannot_install "Directory $INSTALLDIR exists and is not empty or cannot be removed"
fi
+# We expect that $RPM_DB_PATH does not exist, however if it is empty we ignore it
RPM_DB_PATH=$HOME/.RPM_OFFICEDATABASE
+if [ -d $RPM_DB_PATH ]
+then
+ rmdir $RPM_DB_PATH
+fi
+if [ -d $RPM_DB_PATH ]
+then
+ cannot_install "rpm database does already exist $RPM_DB_PATH"
+fi
-# Removing old directories
-rm -rf $MY_OFFICE
-rm -rf $RPM_DB_PATH
+#
+# Perform the installation
+#
-# Output ...
-clear
echo "####################################################################"
-echo "# Installation of StarOffice RPMs #"
+echo "# Installation of the found packages #"
echo "####################################################################"
echo
-echo "Path to the RPM database: " $RPM_DB_PATH
-echo "Path to the RPM packages: " $PACKAGE_PATH
-echo "Path to the installation: " $MY_OFFICE
+echo "Path to the database: " $RPM_DB_PATH
+echo "Path to the packages: " $PACKAGE_PATH
+echo "Path to the installation: " $INSTALLDIR
# Creating directories
mkdir $RPM_DB_PATH
+# XXX why ? XXX
chmod 700 $RPM_DB_PATH
-
-# Creating RPM database and initializing
-rpm --initdb --dbpath $RPM_DB_PATH
-
-RPMLIST=`find $PACKAGE_PATH -type f -name "*.rpm" ! -name "*-core-*" ! -name "*-menus-*" ! -name "adabas*" ! -name "j2re*" -print`
-CORERPM=`find $PACKAGE_PATH -type f -name "*.rpm" -name "*-core-*" -print`
-PREFIX=`rpm -qlp $CORERPM | head -n1`
-
-if [ -z "$CORERPM" ]
+if [ ! -d $RPM_DB_PATH ]
then
- echo "No core RPM found in $PACKAGE_PATH"
- echo "Usage:"
- echo "1. parameter: Path to the RPM packages"
- echo "2. parameter: Path to the installation"
- echo "3. parameter (optional): \"-l\" \(Creates a link \"soffice\" in $HOME\)"
- exit 2
+ cannot_install "Unable to create directory $RPM_DB_PATH"
fi
+# Creating RPM database and initializing
+rpm --initdb --dbpath $RPM_DB_PATH
echo "Installing the RPMs"
-for i in $CORERPM; do
- echo `basename $i`
-done
-for i in $RPMLIST; do
- echo `basename $i`
-done
-
-rpm --install --nodeps -vh --relocate $PREFIX=$MY_OFFICE --dbpath $RPM_DB_PATH $CORERPM
-rpm --install --nodeps -vh --relocate $PREFIX=$MY_OFFICE --dbpath $RPM_DB_PATH $RPMLIST
+rpm --install --nodeps -vh --relocate $PREFIX=$INSTALLDIR --dbpath $RPM_DB_PATH $CORERPM
+rpm --install --nodeps -vh --relocate $PREFIX=$INSTALLDIR --dbpath $RPM_DB_PATH $RPMLIST
-# creating a link into the user home directory
+#
+# Create a link into the users home directory
+#
-if [ $LINK = "-l" ]
+if [ "$LINK" = "-l" ]
then
echo
- echo rm -f $HOME/soffice
+ echo "Creating link from $INSTALLDIR/program/soffice to $HOME/soffice"
rm -f $HOME/soffice
- echo ln -s $MY_OFFICE/program/soffice $HOME/soffice
- ln -s $MY_OFFICE/program/soffice $HOME/soffice
+ ln -s $INSTALLDIR/program/soffice $HOME/soffice
fi
-#clear
echo
echo "Installation done ..."
-exit 0 \ No newline at end of file
+exit 0