| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# This file is part of the LibreOffice project. |
| 4 |
# |
| 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/. |
| 8 |
# |
| 9 |
|
| 10 |
# simple wrapper script to run non-installed executables from workdir |
| 11 |
|
| 12 |
print_usage() |
| 13 |
{ |
| 14 |
echo "This utility can be used to run the executables in this folder:" |
| 15 |
echo |
| 16 |
echo " workdir/LinkTarget/Executable" |
| 17 |
echo |
| 18 |
echo "Usage:" |
| 19 |
echo |
| 20 |
echo " ./bin/run application [parameters]|--list|--help" |
| 21 |
echo |
| 22 |
echo "Use --list (same as -list or -l) to get the list of executables" |
| 23 |
echo "Use --help (same as -help or -h) to get this help" |
| 24 |
} |
| 25 |
|
| 26 |
list_executables() |
| 27 |
{ |
| 28 |
echo "Listing executables inside workdir/LinkTarget/Executable folder:" |
| 29 |
if uname | grep -i CYGWIN >/dev/null |
| 30 |
then |
| 31 |
echo |
| 32 |
find workdir/LinkTarget/Executable -iname "*.bat" -printf "%P\n" |
| 33 |
find workdir/LinkTarget/Executable -iname "*.exe" -printf "%P\n" |
| 34 |
else |
| 35 |
find workdir/LinkTarget/Executable -executable -printf "%P\n" |
| 36 |
fi |
| 37 |
} |
| 38 |
|
| 39 |
print_executable_name() |
| 40 |
{ |
| 41 |
echo "Setting env variables and running workdir/LinkTarget/Executable/$1" |
| 42 |
} |
| 43 |
|
| 44 |
setdefaults() |
| 45 |
{ |
| 46 |
dir=$(realpath "$(pwd)") |
| 47 |
|
| 48 |
while test ! -d "${dir}/instdir/program" ; do |
| 49 |
if test "${dir}" = "/"; then |
| 50 |
echo "error: cannot find \"program\" dir from \"$(pwd)\"" |
| 51 |
exit 1 |
| 52 |
fi |
| 53 |
dir=$(realpath "${dir}/..") |
| 54 |
done |
| 55 |
|
| 56 |
exedir="${dir}"/workdir/LinkTarget/Executable |
| 57 |
export URE_BOOTSTRAP=file://"${dir}"/instdir/program/fundamentalrc |
| 58 |
} |
| 59 |
|
| 60 |
case "$1" in |
| 61 |
""|"-h"|"-help"|"--help") |
| 62 |
print_usage; exit 1;; |
| 63 |
"-l"|"-list"|"--list") |
| 64 |
list_executables; exit 0;; |
| 65 |
*) print_executable_name $1;; |
| 66 |
esac |
| 67 |
|
| 68 |
if uname | grep -i CYGWIN >/dev/null; then |
| 69 |
|
| 70 |
setdefaults |
| 71 |
|
| 72 |
exedir=$(cygpath -m "${dir}"/workdir/LinkTarget/Executable) |
| 73 |
export URE_BOOTSTRAP=file:///$(cygpath -m "${dir}")/instdir/program/fundamental.ini |
| 74 |
export PATH="${dir}/instdir/program${PATH:+:$PATH}" |
| 75 |
SEARCH_PATH="${PATH}" |
| 76 |
|
| 77 |
elif [ $(uname) = Darwin ]; then |
| 78 |
|
| 79 |
dir=$(pwd) |
| 80 |
|
| 81 |
# Get PRODUCTNAME from config_host.mk, LibreOffice or LibreOfficeDev |
| 82 |
eval `grep 'export PRODUCTNAME=' config_host.mk` |
| 83 |
|
| 84 |
if [ ! -d "${dir}/instdir/$PRODUCTNAME.app" ]; then |
| 85 |
echo "error: cannot find \"instdir/$PRODUCTNAME.app\" dir in \"$(pwd)\"" |
| 86 |
exit 1 |
| 87 |
fi |
| 88 |
|
| 89 |
exedir="$dir"/workdir/LinkTarget/Executable |
| 90 |
export URE_BOOTSTRAP=file://"${dir}"/instdir/$PRODUCTNAME.app/Contents/Resources/fundamentalrc |
| 91 |
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH:+$DYLD_LIBRARY_PATH:}"${dir}"/instdir/$PRODUCTNAME.app/Contents/Frameworks |
| 92 |
SEARCH_PATH="${DYLD_LIBRARY_PATH}" |
| 93 |
|
| 94 |
elif [ $(uname) = Haiku ]; then |
| 95 |
|
| 96 |
setdefaults |
| 97 |
|
| 98 |
export LIBRARY_PATH=${LIBRARY_PATH:+$LIBRARY_PATH:}"${dir}"/instdir/program |
| 99 |
SEARCH_PATH="${LIBRARY_PATH}" |
| 100 |
|
| 101 |
else |
| 102 |
|
| 103 |
setdefaults |
| 104 |
|
| 105 |
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}"${dir}"/instdir/program |
| 106 |
SEARCH_PATH="${LD_LIBRARY_PATH}" |
| 107 |
|
| 108 |
fi |
| 109 |
|
| 110 |
# echo "setting URE_BOOTSTRAP to: ${URE_BOOTSTRAP}" |
| 111 |
# echo "setting search path to: ${SEARCH_PATH}" |
| 112 |
# echo "execing: ${exedir}/$1" |
| 113 |
|
| 114 |
exec ${LO_TRACE} "${exedir}/$@" |
| 115 |
|
| 116 |
# vi:set shiftwidth=4 expandtab: |