Автор: Крошечный Козел, 1 день назад, написана на языке Plain Text.
Эта заметка будет удалена через 5 дня.
Встраивание на сайт
  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. # This file incorporates work covered by the following license notice:
  10. #
  11. #   Licensed to the Apache Software Foundation (ASF) under one or more
  12. #   contributor license agreements. See the NOTICE file distributed
  13. #   with this work for additional information regarding copyright
  14. #   ownership. The ASF licenses this file to you under the Apache
  15. #   License, Version 2.0 (the "License"); you may not use this file
  16. #   except in compliance with the License. You may obtain a copy of
  17. #   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  18. #
  19.  
  20. # use POSIX locale for well-defined tool output
  21. LO_SAVE_LC_ALL="$LC_ALL"
  22. LC_ALL=C
  23. export LC_ALL
  24.  
  25. #
  26. test -r /etc/sysconfig/libreoffice5 && . /etc/sysconfig/libreoffice5 ||:
  27.  
  28. # resolve installation directory
  29. sd_cwd=$(pwd)
  30. sd_res="$0"
  31. while [ -h "$sd_res" ] ; do
  32.     sd_dirname=$(dirname "$sd_res")
  33.     cd "$sd_dirname" || exit $?
  34.     sd_basename=$(basename "$sd_res")
  35.     sd_res=$(ls -l "$sd_basename" | sed "s/.*$sd_basename -> //g")
  36. done
  37. sd_dirname=$(dirname "$sd_res")
  38. cd "$sd_dirname" || exit $?
  39. sd_prog=$(pwd)
  40. cd "$sd_cwd" || exit $?
  41.  
  42. # linked build needs additional settings
  43. if [ -e "${sd_prog}/ooenv" ] ; then
  44.     # shellcheck source=../../instsetoo_native/ooenv
  45.     . "${sd_prog}/ooenv"
  46. fi
  47.  
  48. # try to get some debug output?
  49. GDBTRACECHECK=
  50. STRACECHECK=
  51. VALGRINDCHECK=
  52. RRCHECK=
  53.  
  54. # count number of selected checks; only one is allowed
  55. checks=
  56. EXTRAOPT=
  57. # force the --valgrind option if the VALGRIND variable is set
  58. test -n "$VALGRIND" && EXTRAOPT="--valgrind"
  59.  
  60. # force the --record option if the RR variable is set
  61. test -n "$RR" && EXTRAOPT="--record"
  62.  
  63. for arg in "$@" $EXTRAOPT ; do
  64.     case "$arg" in
  65.         --record)
  66.             if command -v rr >/dev/null ; then
  67.                 # smoketest may already be recorded => ignore nested
  68.                 RRCHECK="rr record --nested=ignore"
  69.                 checks="c$checks"
  70.             else
  71.                 echo "Error: Can't find the tool \"rr\", --record option will be ignored."
  72.                 exit 1
  73.             fi
  74.             ;;
  75.         --backtrace)
  76.             if command -v gdb >/dev/null ; then
  77.                 GDBTRACECHECK="gdb -nx --command=$sd_prog/gdbtrace --args"
  78.                 checks="c$checks"
  79.             else
  80.                 echo "Error: Can't find the tool \"gdb\", --backtrace option will be ignored."
  81.                 exit 1
  82.             fi
  83.             ;;
  84.         --strace)
  85.             if command -v strace >/dev/null ; then
  86.                 STRACECHECK="strace -o strace.log -f -tt -s 256"
  87.                 checks="c$checks"
  88.             else
  89.                 echo "Error: Can't find the tool \"strace\", --strace option will be ignored."
  90.                 exit 1;
  91.             fi
  92.             ;;
  93.          --valgrind)
  94.             test -n "$VALGRINDCHECK" && continue;
  95.             if command -v valgrind >/dev/null ; then
  96.                 # another valgrind tool might be forced via the environment variable
  97.                 test -z "$VALGRIND" && VALGRIND="memcheck"
  98.                 # --trace-children-skip is pretty useful but supported only with valgrind >= 3.6.0
  99.                 valgrind_ver=$(valgrind --version | sed -e "s/valgrind-//")
  100.                 valgrind_ver_maj=$(echo "$valgrind_ver" | awk -F. '{ print $1 }')
  101.                 valgrind_ver_min=$(echo "$valgrind_ver" | awk -F. '{ print $2 }')
  102.                 valgrind_skip=
  103.                 if [ "$valgrind_ver_maj" -gt 3 ] || ( [ "$valgrind_ver_maj" -eq 3 ] && [ "$valgrind_ver_min" -ge 6 ] ) ; then
  104.                     valgrind_skip='--trace-children-skip=*/java,*/gij'
  105.                 fi
  106.                 # finally set the valgrind check
  107.                 VALGRINDCHECK="valgrind --tool=$VALGRIND --trace-children=yes $valgrind_skip --num-callers=50 --error-limit=no"
  108.                 echo "use kill -SIGUSR2 pid to dump traces of active allocations"
  109.                 checks="c$checks"
  110.                 case "$VALGRIND" in
  111.                 helgrind|memcheck|massif|exp-dhat)
  112.                     export G_SLICE=always-malloc
  113.                     export GLIBCXX_FORCE_NEW=1
  114.                     ;;
  115.                 callgrind)
  116.                     unset MALLOC_CHECK_ MALLOC_PERTURB_ G_SLICE
  117.                     export SAL_DISABLE_FLOATGRAB=1
  118.                     export OOO_DISABLE_RECOVERY=1
  119.                     export SAL_DISABLE_WATCHDOG=1
  120.                     export LD_BIND_NOW=1
  121.                     ;;
  122.                 esac
  123.             else
  124.                 echo "Error: Can't find the tool \"valgrind\", --valgrind option will be ignored"
  125.                 exit 1
  126.             fi
  127.             ;;
  128.     esac
  129. done
  130.  
  131. if echo "$checks" | grep -q "cc" ; then
  132.     echo "Error: The debug options --record, --backtrace, --strace, and --valgrind cannot be used together."
  133.     echo "       Please, use them one by one."
  134.     exit 1;
  135. fi
  136.  
  137. case "$(uname -s)" in
  138. OpenBSD)
  139. # this is a temporary hack until we can live with the default search paths
  140.     LD_LIBRARY_PATH="$sd_prog${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
  141.     JAVA_HOME=$(javaPathHelper -h libreoffice-java 2> /dev/null)
  142.     export LD_LIBRARY_PATH
  143.     if [ -n "${JAVA_HOME}" ]; then
  144.         export JAVA_HOME
  145.     fi
  146.     ;;
  147. NetBSD|DragonFly)
  148. # this is a temporary hack until we can live with the default search paths
  149.     LD_LIBRARY_PATH="$sd_prog${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
  150.     export LD_LIBRARY_PATH
  151.     ;;
  152. esac
  153.  
  154. # restore locale setting, avoiding to export empty LC_ALL, s. tdf#130080
  155. if [ -n "$LO_SAVE_LC_ALL" ]; then
  156.     LC_ALL="$LO_SAVE_LC_ALL"
  157. else
  158.     unset LC_ALL
  159. fi
  160.  
  161. # run soffice.bin directly when you want to get the backtrace
  162. if [ -n "$GDBTRACECHECK" ] ; then
  163.     exec $GDBTRACECHECK "$sd_prog/soffice.bin" "$@"
  164. fi
  165.  
  166. # valgrind --log-file=valgrind.log does not work well with --trace-children=yes
  167. if [ -n "$VALGRINDCHECK" ] && [ -z "$VALGRIND" ] ; then
  168.     echo "redirecting the standard and the error output to valgrind.log"
  169.     exec > valgrind.log 2>&1
  170. fi
  171.  
  172. # ALT: find certificates database folder
  173. _find_cert_dir() { # path [mindepth [maxdepth [name [variable_name]]]]
  174.         local md="${2:-1}"
  175.         local Md="${3:-10}"
  176.         local N="${4:-cert8.db}"
  177.         local var="${5:-MOZILLA_CERTIFICATE_FOLDER}"
  178.         local cert8
  179.         test -d "$1" || return
  180.         cert8="$(find "$1" -mindepth "$md" -maxdepth "$Md" -name "$N" -print -quit)"
  181.         test -n "$cert8" || return
  182.         eval "export $var='$(dirname $cert8)'"
  183. }
  184.  
  185. test -n "$MOZILLA_CERTIFICATE_FOLDER" || _find_cert_dir $HOME/.mozilla/firefox 2 2
  186. test -n "$MOZILLA_CERTIFICATE_FOLDER" || _find_cert_dir $HOME/.mozilla 3 3
  187. test -n "$MOZILLA_CERTIFICATE_FOLDER" || _find_cert_dir $HOME/.local
  188.  
  189. # oosplash does the rest: forcing pages in, javaldx etc. are
  190. exec $RRCHECK $VALGRINDCHECK $STRACECHECK "$sd_prog/oosplash" "$@"