7 USAGE
="Usage: $0 [-a,--add] [-l,--link] [-U,--update] [-h,--help] <rpm-source-dir> <office-installation-dir>"
12 echo "User Mode Installation script for developer and knowledgeable early access tester"
14 echo "This installation method is not intended for use in a production environment!"
15 echo "Using this script is unsupported and completely at your own risk"
17 echo "Usage:" $0 [-lU] "<rpm-source-dir> <office-installation-dir>"
18 echo " <rpm-source-dir>: directory *only* containing the Linux rpm packages to be installed"
19 echo " or language pack shell script containing the rpm packages"
20 echo " <office-installation-dir>: directory to where the office will get installed into"
22 echo "Optional Parameter:"
23 echo " -a,--add: add to an existing <office-installation-dir>"
24 echo " -l,--link: create a link \"soffice\" in $HOME"
25 echo " -U,--update: update without asking"
26 echo " -h,--help: output this help"
30 try_to_unpack_languagepack_file
()
32 FILENAME
=$PACKAGE_PATH
34 # Checking, if $FILENAME is a language pack.
35 # String "language package" has to exist in the shell script file.
36 # If this is no language pack, the installation is not supported
38 SEARCHSTRING
=`head --lines=10 $FILENAME | grep "language package"`
40 if [ ! -z "$SEARCHSTRING" ]
42 echo "First parameter $FILENAME is a language pack";
44 printf "\nERROR: First parameter $FILENAME is a file, but no language pack shell script.\n"
49 echo "Unpacking shell script $FILENAME"
50 TAILLINE
=`head --lines=20 $FILENAME | sed --quiet 's/linenum=//p'`
52 UNPACKDIR
=/var
/tmp
/install_$$
54 # UNPACKDIR=`mktemp -d`
55 tail -n +$TAILLINE $FILENAME | gunzip |
(cd $UNPACKDIR; tar xvf
-)
57 # Setting the new package path, in which the packages exist
58 PACKAGE_PATH
=$UNPACKDIR
60 # Setting variable UPDATE, because an Office installation has to exist, if a language pack shall be installed
65 # this script is for userland not for root
70 printf "\nThis script is for installation without administrative rights only\nPlease use rpm to install as root\n"
75 set -- `getopt -u -o 'alhU' -l 'add,link,help,update' -- $*`
86 -a|
--add) ADD
="yes"; shift;;
87 -h|
--help) help; exit 0;;
88 -l|
--link) LINK
="yes"; shift;;
89 -U|
--update) UPDATE
="yes"; shift;;
103 # If the first parameter is a shell script (download installation set), the packages have to
104 # be unpacked into temp directory
107 if [ -f "$PACKAGE_PATH" ]
109 try_to_unpack_languagepack_file
113 # Check and get the list of packages to install
116 RPMLIST
=`find $PACKAGE_PATH -maxdepth 2 -type f -name "*.rpm" ! -name "*-menus-*" ! -name "*-desktop-integration-*" ! -name "jre*" ! -name "*-userland-*" -print`
120 printf "\n$0: No packages found in $PACKAGE_PATH\n"
125 # Determine whether this should be an update or a fresh install
129 RPM_DB_PATH
=${INSTALLDIR}/var
/lib
/rpm
131 # Check for versionrc
132 if [ -f ${INSTALLDIR}/program
/versionrc
]; then VERSIONRC
=versionrc
; fi
134 if [ "$UPDATE" = "ask" ]
136 PRODUCT
=`sed --silent -e "
138 s/buildid=\(.*\)/ [\1]/
145 }" ${INSTALLDIR}/program/${VERSIONRC:-bootstraprc} 2>/dev/null | tr -d "\012"`
147 if [ ! -z "$PRODUCT" ]
150 echo "Found an installation of $PRODUCT in $INSTALLDIR"
152 while [ "$UPDATE" != "yes" ]
154 read -a UPDATE
-p "Do you want to update this installation (yes/no)? "
155 if [ "$UPDATE" = "no" ]
160 elif [ -d $RPM_DB_PATH -a "$ADD" = "no" ]
163 echo "The following packages are already installed in $INSTALLDIR"
165 rpm
--dbpath `cd $RPM_DB_PATH; pwd` --query --all
167 while [ "$UPDATE" != "yes" ]
169 read -a UPDATE
-p "Do you want to continue with this installation (yes/no)? "
170 if [ "$UPDATE" = "no" ]
181 # Check/Create installation directory
184 if [ "$UPDATE" = "yes" ]
186 # restore original bootstraprc
187 mv -f ${INSTALLDIR}/program
/bootstraprc.orig
${INSTALLDIR}/program
/bootstraprc
2>/dev
/null
189 # the RPM_DB_PATH must be absolute
190 if [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then
191 RPM_DB_PATH
=`cd ${RPM_DB_PATH}; pwd`
194 # we should use --freshen for updates to not add languages with patches, but this will break
195 # language packs, so leave it for now ..
199 rmdir ${INSTALLDIR} 2>/dev
/null
201 if [ -d ${INSTALLDIR} -a "$ADD" = "no" ]
203 printf "\n$0: ${INSTALLDIR} exists and is not empty.\n"
207 mkdir
-p $RPM_DB_PATH ||
exit 2
209 chmod 700 $RPM_DB_PATH
211 # the RPM_DB_PATH must be absolute
212 if [ ! "${RPM_DB_PATH:0:1}" = "/" ]; then
213 RPM_DB_PATH
=`cd ${RPM_DB_PATH}; pwd`
216 # Creating RPM database and initializing
217 if [ "$ADD" = "no" ]; then
218 rpm
--initdb --dbpath $RPM_DB_PATH
221 # Default install command
225 # populate the private rpm database with the dependencies needed
226 FAKEDBRPM
=/tmp
/fake-db-1.0
-$$.noarch.rpm
228 tail -n +$linenum $0 > $FAKEDBRPM
230 rpm
--upgrade --ignoresize --dbpath $RPM_DB_PATH $FAKEDBRPM
234 echo "Packages found:"
235 for i
in $RPMLIST ; do
240 # Perform the installation
244 echo "####################################################################"
245 echo "# Installation of the found packages #"
246 echo "####################################################################"
248 echo "Path to the database: " $RPM_DB_PATH
249 echo "Path to the packages: " $PACKAGE_PATH
250 echo "Path to the installation: " $INSTALLDIR
252 echo "Installing the RPMs"
254 ABSROOT
=`cd ${INSTALLDIR}; pwd`
255 RELOCATIONS
=`rpm -qp --qf "--relocate %{PREFIXES}=${ABSROOT}%{PREFIXES} \n" $RPMLIST | sort -u | tr -d "\012"`
256 UserInstallation
=\
$BRAND_BASE_DIR/..
/UserInstallation rpm
$RPMCMD --ignoresize -vh $RELOCATIONS --dbpath $RPM_DB_PATH $RPMLIST
259 # Create a link into the users home directory
262 if [ "$LINK" = "yes" ]
264 find `cd "$INSTALLDIR" && pwd` -name soffice
-type f
-perm /u
+x
-exec /bin
/bash
-ce 'ln -sf "$0" "$HOME/soffice" && echo "Creating link from $0 to $HOME/soffice"' {} \
;
267 if [ "$UPDATE" = "yes" -a ! -f $INSTALLDIR/program
/bootstraprc
]
270 echo "Update failed due to a bug in RPM, uninstalling .."
271 rpm
--erase -v --nodeps --dbpath $RPM_DB_PATH `rpm --query --queryformat "%{NAME} " --package $RPMLIST --dbpath $RPM_DB_PATH`
273 echo "Now re-installing new packages .."
275 rpm
--install --nodeps --ignoresize -vh $RELOCATIONS --dbpath $RPM_DB_PATH $RPMLIST
279 # patch the "bootstraprc" to create a self-containing installation
280 find "$INSTALLDIR" -type f
-name bootstraprc
-exec /bin
/bash
-ce 'test ! -e "$0".orig && mv "$0" "$0".orig && sed '\''s,^UserInstallation=$SYSUSERCONFIG.*,UserInstallation=$BRAND_BASE_DIR/../UserInstallation,'\'' "$0".orig > "$0"' {} \
;
282 # if an unpack directory exists, it can be removed now
283 if [ ! -z "$UNPACKDIR" ]
287 echo "Removed temporary directory $UNPACKDIR"
291 echo "Installation done ..."