2004-09-08 09:01:52 -05:00
#!/bin/bash
2005-06-17 08:12:04 -05:00
LINK = "no"
UPDATE = "ask"
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"
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
}
#
# 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
2004-10-07 11:14:06 -05:00
#
# Check and get the list of packages to install
#
2005-06-17 08:12:04 -05:00
RPMLIST = ` find $PACKAGE_PATH -maxdepth 2 -type f -name "*.rpm" ! -name "*-menus-*" ! -name "*-desktop-integration-*" ! -name "adabas*" ! -name "jre*" ! -name "*-gnome*" -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-01-21 04:34:09 -06:00
# Do not install gnome-integration package on systems without GNOME
2005-06-17 08:12:04 -05:00
# check for /bin/rpm first, otherwise the rpm database is most likely
# empty anyway
2005-01-21 04:34:09 -06:00
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-06-17 08:12:04 -05:00
/bin/rpm -q --whatprovides libgnomevfs-2.so.0 libgconf-2.so.4 >/dev/null || GNOMERPM = ""
2005-01-21 04:34:09 -06:00
fi
2004-10-07 11:14:06 -05:00
#
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
RPM_DB_PATH = ${ INSTALLDIR } /.RPM_OFFICEDATABASE
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
} " ${ INSTALLDIR } /program/bootstraprc 2>/dev/null | tr -d " \0 12" `
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
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
mv -f ${ INSTALLDIR } /program/bootstraprc.orig ${ INSTALLDIR } /program/bootstraprc
# the RPM_DB_PATH must be absolute
if [ ! " ${ RPM_DB_PATH : 0 : 1 } " = "/" ] ; then
RPM_DB_PATH = ` cd ${ RPM_DB_PATH } ; pwd `
fi
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
2004-09-08 09:01:52 -05:00
fi
2005-06-17 08:12:04 -05:00
echo "Packages found:"
for i in $RPMLIST $GNOMERPM ; do
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|' `
RELOCATIONS = ` rpm -qp --qf " --relocate %{PREFIXES}= ${ NEWPREFIX } \n " $RPMLIST $GNOMERPM | sort -u | tr -d "\012" `
rpm --upgrade --nodeps --ignoresize -vh $RELOCATIONS --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
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-01-21 04:34:09 -06:00
# patch the "bootstraprc" to create a self-containing installation
mv $INSTALLDIR /program/bootstraprc $INSTALLDIR /program/bootstraprc.orig
2005-08-18 06:50:16 -05:00
sed 's/UserInstallation=$SYSUSERCONFIG.*/UserInstallation=$ORIGIN\/..\/UserInstallation/g' $INSTALLDIR /program/bootstraprc.orig > $INSTALLDIR /program/bootstraprc
2005-01-21 04:34:09 -06:00
2004-09-08 09:01:52 -05:00
echo
echo "Installation done ..."
2004-10-07 11:14:06 -05:00
exit 0