2004-09-08 09:01:52 -05:00
#!/bin/bash
2005-06-17 08:12:04 -05:00
LINK = "no"
UPDATE = "ask"
2006-10-05 03:20:11 -05:00
UNPACKDIR = ""
2005-06-17 08:12:04 -05:00
USAGE = " Usage: $0 [-l,--link] [-U,--update] [-h,--help] <rpm-source-dir> <office-installation-dir> "
2004-10-07 11:14:06 -05:00
2005-06-17 08:12:04 -05:00
help( )
2004-10-07 11:14:06 -05:00
{
2005-06-17 08:12:04 -05:00
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 [ -lU] "<rpm-source-dir> <office-installation-dir>"
echo " <rpm-source-dir>: directory *only* containing the Linux rpm packages to be installed"
2006-10-05 03:20:11 -05:00
echo " or language pack shell script containing the rpm packages"
2005-06-17 08:12:04 -05:00
echo " <office-installation-dir>: directory to where the office will get installed into"
echo
echo "Optional Parameter:"
echo " -l,--link: create a link \"soffice\" in $HOME "
echo " -U,--update: update without asking"
echo " -h,--help: output this help"
echo
2004-10-07 11:14:06 -05:00
}
2006-10-05 03:20:11 -05:00
try_to_unpack_languagepack_file( )
{
FILENAME = $PACKAGE_PATH
# Checking, if $FILENAME is a language pack.
# String "language package" has to exist in the shell script file.
# If this is no language pack, the installation is not supported
SEARCHSTRING = ` head --lines= 10 $FILENAME | grep "language package" `
if [ ! -z " $SEARCHSTRING " ]
then
echo " First parameter $FILENAME is a language pack " ;
else
printf " \nERROR: First parameter $FILENAME is a file, but no language pack shell script.\n "
echo $USAGE
exit 2
fi
echo " Unpacking shell script $FILENAME "
TAILLINE = ` head --lines= 20 $FILENAME | sed --quiet 's/linenum=//p' `
UNPACKDIR = /var/tmp/install_$$
mkdir $UNPACKDIR
# UNPACKDIR=`mktemp -d`
tail -n +$TAILLINE $FILENAME | gunzip | ( cd $UNPACKDIR ; tar xvf -)
# Setting the new package path, in which the packages exist
PACKAGE_PATH = $UNPACKDIR
# Setting variable UPDATE, because an Office installation has to exist, if a language pack shall be installed
UPDATE = "yes"
}
2004-10-07 11:14:06 -05:00
#
# this script is for userland not for root
#
if [ $UID -eq 0 ]
then
2005-06-17 08:12:04 -05:00
printf "\nThis script is for installation without administrative rights only\nPlease use rpm to install as root\n"
help
exit 2
2004-10-07 11:14:06 -05:00
fi
2005-07-01 06:18:11 -05:00
set -- ` getopt -u -o 'lhU' -l 'link,help,update' -- $* `
2004-09-08 09:01:52 -05:00
2005-06-17 08:12:04 -05:00
if [ $? != 0 ]
2004-09-08 09:01:52 -05:00
then
2005-06-17 08:12:04 -05:00
echo $USAGE
exit 2
2004-09-08 09:01:52 -05:00
fi
2005-06-17 08:12:04 -05:00
for i in $*
do
case $i in
-h| --help) help; exit 0; ;
-l| --link) LINK = "yes" ; shift; ;
-U| --update) UPDATE = "yes" ; shift; ;
--) shift; break; ;
esac
done
2004-10-07 11:14:06 -05:00
2005-06-17 08:12:04 -05:00
if [ $# != 2 ]
2004-10-07 11:14:06 -05:00
then
2005-06-17 08:12:04 -05:00
echo $USAGE
exit 2
2004-10-07 11:14:06 -05:00
fi
2005-06-17 08:12:04 -05:00
PACKAGE_PATH = $1
2006-10-05 03:20:11 -05:00
#
# If the first parameter is a shell script (download installation set), the packages have to
# be unpacked into temp directory
#
if [ -f " $PACKAGE_PATH " ]
then
try_to_unpack_languagepack_file
fi
2004-10-07 11:14:06 -05:00
#
# Check and get the list of packages to install
#
2007-07-19 01:17:26 -05:00
RPMLIST = ` find $PACKAGE_PATH -maxdepth 2 -type f -name "*.rpm" ! -name "*-menus-*" ! -name "*-desktop-integration-*" ! -name "adabas*" ! -name "jre*" -print`
2004-10-07 11:14:06 -05:00
2005-06-17 08:12:04 -05:00
if [ -z " $RPMLIST " ]
2004-10-07 11:14:06 -05:00
then
2005-06-17 08:12:04 -05:00
printf " \n $0 : No packages found in $PACKAGE_PATH \n "
exit 2
2004-10-07 11:14:06 -05:00
fi
#
2005-06-17 08:12:04 -05:00
# Determine whether this should be an update or a fresh install
2004-10-07 11:14:06 -05:00
#
2005-06-17 08:12:04 -05:00
INSTALLDIR = $2
2005-11-09 02:26:42 -06:00
# Check for old style .RPM_OFFICEDATABASE first
if [ -d ${ INSTALLDIR } /.RPM_OFFICEDATABASE ] ; then
RPM_DB_PATH = ${ INSTALLDIR } /.RPM_OFFICEDATABASE
else
RPM_DB_PATH = ${ INSTALLDIR } /.RPM_DATABASE
fi
2005-06-17 08:12:04 -05:00
2005-09-28 07:05:01 -05:00
# Check for versionrc
if [ -f ${ INSTALLDIR } /program/versionrc ] ; then VERSIONRC = versionrc; fi
2005-06-17 08:12:04 -05:00
if [ " $UPDATE " = "ask" ]
2004-10-07 11:14:06 -05:00
then
2005-06-17 08:12:04 -05:00
PRODUCT = ` sed --silent -e "
/^buildid= / {
s/buildid= \( .*\) / [ \1 ] /
h
}
/^ProductKey= / {
s/ProductKey= //
G
p
2005-09-28 07:05:01 -05:00
} " ${ INSTALLDIR } /program/ ${ VERSIONRC :- bootstraprc } 2>/dev/null | tr -d " \0 12" `
2005-06-17 08:12:04 -05:00
if [ ! -z " $PRODUCT " ]
then
echo
echo " Found an installation of $PRODUCT in $INSTALLDIR "
echo
while [ " $UPDATE " != "yes" ]
do
read -a UPDATE -p "Do you want to update this installation (yes/no)? "
if [ " $UPDATE " = "no" ]
then
exit 2
fi
done
2005-11-09 02:26:42 -06:00
elif [ -d $RPM_DB_PATH ]
then
echo
echo " The following packages are already installed in $INSTALLDIR "
echo
rpm --dbpath ` cd $RPM_DB_PATH ; pwd ` --query --all
echo
while [ " $UPDATE " != "yes" ]
do
read -a UPDATE -p "Do you want to continue with this installation (yes/no)? "
if [ " $UPDATE " = "no" ]
then
exit 2
fi
done
2005-06-17 08:12:04 -05:00
else
UPDATE = "no"
fi
2004-10-07 11:14:06 -05:00
fi
2005-06-17 08:12:04 -05:00
#
# Check/Create installation directory
#
if [ " $UPDATE " = "yes" ]
2004-10-07 11:14:06 -05:00
then
2005-06-17 08:12:04 -05:00
# restore original bootstraprc
2005-11-09 02:26:42 -06:00
mv -f ${ INSTALLDIR } /program/bootstraprc.orig ${ INSTALLDIR } /program/bootstraprc 2>/dev/null
2005-06-17 08:12:04 -05:00
# the RPM_DB_PATH must be absolute
if [ ! " ${ RPM_DB_PATH : 0 : 1 } " = "/" ] ; then
RPM_DB_PATH = ` cd ${ RPM_DB_PATH } ; pwd `
fi
2007-07-19 01:17:26 -05:00
# we should use --freshen for updates to not add languages with patches, but this will break
# language packs, so leave it for now ..
# RPMCMD="--freshen"
RPMCMD = "--upgrade"
2005-06-17 08:12:04 -05:00
else
rmdir ${ INSTALLDIR } 2>/dev/null
if [ -d ${ INSTALLDIR } ]
then
printf " \n $0 : ${ INSTALLDIR } exists and is not empty.\n "
exit 2
fi
mkdir -p $RPM_DB_PATH || exit 2
# XXX why ? XXX
chmod 700 $RPM_DB_PATH
# the RPM_DB_PATH must be absolute
if [ ! " ${ RPM_DB_PATH : 0 : 1 } " = "/" ] ; then
RPM_DB_PATH = ` cd ${ RPM_DB_PATH } ; pwd `
fi
# Creating RPM database and initializing
rpm --initdb --dbpath $RPM_DB_PATH
2007-07-19 01:17:26 -05:00
# Default install command
RPMCMD = "--install"
2004-09-08 09:01:52 -05:00
fi
2007-07-19 01:17:26 -05:00
# populate the private rpm database with the dependencies needed
FAKEDBRPM = /tmp/fake-db-1.0-$$ .noarch.rpm
linenum = ???
2008-01-18 07:55:04 -06:00
tail -n +$linenum $0 > $FAKEDBRPM
2007-07-19 01:17:26 -05:00
2007-08-03 07:10:22 -05:00
rpm --upgrade --ignoresize --dbpath $RPM_DB_PATH $FAKEDBRPM
2007-07-19 01:17:26 -05:00
rm -f $FAKEDBRPM
2005-06-17 08:12:04 -05:00
echo "Packages found:"
2007-07-19 01:17:26 -05:00
for i in $RPMLIST ; do
2005-06-17 08:12:04 -05:00
echo ` basename $i `
done
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
2005-06-17 08:12:04 -05:00
echo
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
2005-06-17 08:12:04 -05:00
echo
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
2005-06-17 08:12:04 -05:00
NEWPREFIX = ` cd ${ INSTALLDIR } ; pwd | sed -e 's|\(.*\)\/\(.*\)|\1\/\/\2|' `
2007-07-19 01:17:26 -05:00
RELOCATIONS = ` rpm -qp --qf " --relocate %{PREFIXES}= ${ NEWPREFIX } \n " $RPMLIST | sort -u | tr -d "\012" `
UserInstallation = \$ ORIGIN/../UserInstallation rpm $RPMCMD --ignoresize -vh $RELOCATIONS --dbpath $RPM_DB_PATH $RPMLIST
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
2005-06-17 08:12:04 -05:00
if [ " $LINK " = "yes" ]
2004-09-08 09:01:52 -05:00
then
echo
2005-06-17 08:12:04 -05:00
echo " Creating link from ${ INSTALLDIR } /program/soffice to $HOME /soffice "
ln -sf $INSTALLDIR /program/soffice $HOME /soffice
2004-09-08 09:01:52 -05:00
fi
2005-11-09 02:26:42 -06:00
if [ " $UPDATE " = "yes" -a ! -f $INSTALLDIR /program/bootstraprc ]
then
echo
echo "Update failed due to a bug in RPM, uninstalling .."
2007-07-19 01:17:26 -05:00
rpm --erase -v --nodeps --dbpath $RPM_DB_PATH ` rpm --query --queryformat "%{NAME} " --package $RPMLIST --dbpath $RPM_DB_PATH `
2005-11-09 02:26:42 -06:00
echo
echo "Now re-installing new packages .."
echo
2007-07-19 01:17:26 -05:00
rpm --install --nodeps --ignoresize -vh $RELOCATIONS --dbpath $RPM_DB_PATH $RPMLIST
2005-11-09 02:26:42 -06:00
echo
fi
2005-01-21 04:34:09 -06:00
# patch the "bootstraprc" to create a self-containing installation
2005-11-09 02:26:42 -06:00
if [ -f $INSTALLDIR /program/bootstraprc ] ; then
mv $INSTALLDIR /program/bootstraprc $INSTALLDIR /program/bootstraprc.orig
sed 's/UserInstallation=$SYSUSERCONFIG.*/UserInstallation=$ORIGIN\/..\/UserInstallation/g' $INSTALLDIR /program/bootstraprc.orig > $INSTALLDIR /program/bootstraprc
fi
2005-01-21 04:34:09 -06:00
2006-10-05 03:20:11 -05:00
# if an unpack directory exists, it can be removed now
if [ ! -z " $UNPACKDIR " ]
then
rm $UNPACKDIR /*.rpm
rmdir $UNPACKDIR
echo " Removed temporary directory $UNPACKDIR "
fi
2004-09-08 09:01:52 -05:00
echo
echo "Installation done ..."
2004-10-07 11:14:06 -05:00
exit 0