update credits
[LibreOffice.git] / bin / java-set-classpath.in
blob507264a3dcff95986b76d98b4219a4fdeaaa66c9
1 #!/bin/sh
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # java-set-classpath - Utility to update the default
11 # CLASSPATH for LibreOffice
13 if test "z$1" = "z" ; then
14 echo "Update the default CLASSPATH for LibreOffice"
15 echo ""
16 echo "Usage: $0 [dir|jar]..."
17 echo ""
18 echo "The utility updates the LibreOffice system setting. It adds or removes"
19 echo "the given directories and jar-files to or from the default CLASSPATH"
20 echo "depending on if they are available on the system or not."
21 echo ""
22 echo "Parameters:"
23 echo " dir - absolute path to a directory"
24 echo " jar - absolute path to a jar-file"
25 exit 0;
28 JVM_CONFIG_FILE=@INSTALLDIR@/program/fundamentalrc
30 for path in $@ ; do
31 if test "z${path%%/*}" != "z" ; then
32 echo "Warning: the path "$path" is not absolute and will be ignored"
33 continue
35 if test -e $path ; then
36 # the file exist
37 grep "URE_MORE_JAVA_CLASSPATH_URLS.*file:/*$path\([[:space:]].*\)\?$" $JVM_CONFIG_FILE >/dev/null && continue
38 # it is not registered
39 TMP_FILE=`mktemp /tmp/ooset-java-class.XXXXXXXXXX` || exit 1
40 sed -e "s|^\(.*URE_MORE_JAVA_CLASSPATH_URLS.*\)$|\1 file://$path|" $JVM_CONFIG_FILE >$TMP_FILE
41 mv -f $TMP_FILE $JVM_CONFIG_FILE
42 chmod 644 $JVM_CONFIG_FILE
43 else
44 # the file does not exist, remove it from the configuration
45 TMP_FILE=`mktemp /tmp/ooset-java-class.XXXXXXXXXX` || exit 1;
46 sed -e "s|^\(.*URE_MORE_JAVA_CLASSPATH_URLS.*\)file:/*$path\([[:space:]].*\)\?$|\1\2|" \
47 -e "s/\(URE_MORE_JAVA_CLASSPATH_URLS=\)[[:space:]]\+/\1/" \
48 -e "/^.*URE_MORE_JAVA_CLASSPATH_URLS/s/[[:space:]]\+/ /g" \
49 -e "/^.*URE_MORE_JAVA_CLASSPATH_URLS/s/[[:space:]]*$//" $JVM_CONFIG_FILE >$TMP_FILE
50 mv -f $TMP_FILE $JVM_CONFIG_FILE
51 chmod 644 $JVM_CONFIG_FILE
53 done