2004-09-08 09:01:52 -05:00
#!/bin/bash
2004-10-07 11:14:06 -05:00
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
#
2004-09-08 09:01:52 -05:00
if [ \( $# -ne 2 -a $# -ne 3 \) -o -z " $1 " -o -z " $2 " ]
then
2004-10-07 11:14:06 -05:00
error "Wrong number of arguments"
2004-09-08 09:01:52 -05:00
fi
2004-10-07 11:14:06 -05:00
#
# 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
#
2004-09-08 09:01:52 -05:00
PACKAGE_PATH = $1
2004-10-07 11:14:06 -05:00
INSTALLDIR = $2
2004-09-08 09:01:52 -05:00
LINK = "nolink"
if [ $# -eq 3 ]
then
LINK = $3
fi
if [ ! -d $PACKAGE_PATH ]
then
2004-10-07 11:14:06 -05:00
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
#
2005-04-27 02:52:34 -05:00
RPMLIST = ` find $PACKAGE_PATH -type f -name "*.rpm" ! -name "*-core*" ! -name "*-menus-*" ! -name "*-desktop-integration-*" ! -name "adabas*" ! -name "jre*" ! -name "*-gnome*" -print`
2005-02-24 09:17:05 -06:00
CORERPMLIST = ` find $PACKAGE_PATH -type f -name "*.rpm" -name "*-core*" -print`
CORERPM01 = ` find $PACKAGE_PATH -type f -name "*.rpm" -name "*-core01-*" -print`
PREFIX = ` rpm -qlp $CORERPM01 | head -n1`
2004-10-07 11:14:06 -05:00
2005-02-24 09:17:05 -06:00
if [ -z " $CORERPM01 " ]
2004-10-07 11:14:06 -05:00
then
error " No core package found in directory $PACKAGE_PATH "
fi
2005-01-21 04:34:09 -06:00
# Do not install gnome-integration package on systems without GNOME
# check for /bin/rpm first, otherwise the rpm database is most likly empty anyway
if [ -x /bin/rpm ]
then
2005-03-08 08:48:37 -06:00
GNOMERPM = ` find $PACKAGE_PATH -type f -name "*.rpm" -name "*-gnome*" -print`
2005-03-23 02:40:43 -06:00
/bin/rpm -i --test $GNOMERPM $CORERPM01 2>/dev/null || GNOMERPM = ""
2005-01-21 04:34:09 -06:00
fi
2004-10-07 11:14:06 -05:00
echo "Packages found:"
2005-02-24 09:17:05 -06:00
for i in $CORERPMLIST $RPMLIST $GNOMERPM ; do
2004-10-07 11:14:06 -05:00
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 "
2004-09-08 09:01:52 -05:00
fi
2005-01-21 04:34:09 -06:00
# We expect that rpm_DB_PATH does not exist, however if it is empty we ignore it
#RPM_DB_PATH=$HOME/.RPM_OFFICEDATABASE
RPM_DB_PATH = $INSTALLDIR /.RPM_OFFICEDATABASE
2004-09-08 09:01:52 -05:00
2004-10-07 11:14:06 -05:00
#
# Perform the installation
#
2004-09-08 09:01:52 -05:00
echo "####################################################################"
2004-10-07 11:14:06 -05:00
echo "# Installation of the found packages #"
2004-09-08 09:01:52 -05:00
echo "####################################################################"
echo
2004-10-07 11:14:06 -05:00
echo "Path to the database: " $RPM_DB_PATH
echo "Path to the packages: " $PACKAGE_PATH
echo "Path to the installation: " $INSTALLDIR
2004-09-08 09:01:52 -05:00
# Creating directories
2005-01-21 04:34:09 -06:00
mkdir -p $RPM_DB_PATH
2004-10-07 11:14:06 -05:00
# XXX why ? XXX
2004-09-08 09:01:52 -05:00
chmod 700 $RPM_DB_PATH
2004-10-07 11:14:06 -05:00
if [ ! -d $RPM_DB_PATH ]
2004-09-08 09:01:52 -05:00
then
2004-10-07 11:14:06 -05:00
cannot_install " Unable to create directory $RPM_DB_PATH "
2004-09-08 09:01:52 -05:00
fi
2004-10-07 11:14:06 -05:00
# Creating RPM database and initializing
rpm --initdb --dbpath $RPM_DB_PATH
2004-09-08 09:01:52 -05:00
echo "Installing the RPMs"
2005-01-21 04:34:09 -06:00
# inject a second slash to the last path segment to avoid rpm 3 concatination bug
NEWPREFIX = ` echo $INSTALLDIR | sed -e 's|\(.*\)\/\(.*\)|\1\/\/\2|' `
2005-02-24 09:17:05 -06:00
rpm --install --nodeps -vh --relocate $PREFIX = $NEWPREFIX --dbpath $RPM_DB_PATH $CORERPMLIST
2005-01-21 04:34:09 -06:00
rpm --install --nodeps -vh --relocate $PREFIX = $NEWPREFIX --dbpath $RPM_DB_PATH $RPMLIST $GNOMERPM
2004-09-08 09:01:52 -05:00
2004-10-07 11:14:06 -05:00
#
# Create a link into the users home directory
#
2004-09-08 09:01:52 -05:00
2004-10-07 11:14:06 -05:00
if [ " $LINK " = "-l" ]
2004-09-08 09:01:52 -05:00
then
echo
2004-10-07 11:14:06 -05:00
echo " Creating link from $INSTALLDIR /program/soffice to $HOME /soffice "
2004-09-08 09:01:52 -05:00
rm -f $HOME /soffice
2004-10-07 11:14:06 -05:00
ln -s $INSTALLDIR /program/soffice $HOME /soffice
2004-09-08 09:01:52 -05:00
fi
2005-01-21 04:34:09 -06:00
# patch the "bootstraprc" to create a self-containing installation
mv $INSTALLDIR /program/bootstraprc $INSTALLDIR /program/bootstraprc.orig
sed 's/UserInstallation=$SYSUSERCONFIG\/.staroffice8/UserInstallation=$ORIGIN\/..\/UserInstallation/g' $INSTALLDIR /program/bootstraprc.orig > $INSTALLDIR /program/bootstraprc
2004-09-08 09:01:52 -05:00
echo
echo "Installation done ..."
2004-10-07 11:14:06 -05:00
exit 0