bump product version to 5.0.4.1
[LibreOffice.git] / solenv / bin / install-gdb-printers
blob0362a5c04a06f6ae4d20a11296f6c8c7ab721736
1 #!/usr/bin/env bash
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 GDBDIR="${SRCDIR}/solenv/gdb"
11 INSTALLDIR="${TESTINSTALLDIR}"
12 DYLIB=so
13 if [ "$(uname)" = Darwin ]; then
14 INSTALLDIR=$INSTALLDIR/LibreOffice.app/Contents
15 DYLIB=dylib
18 die() {
19 echo "$1" >&2
20 exit 1
23 usage() {
24 cat <<EOT
25 Install gdb pretty printers and autoloaders for them.
27 Usage:
28 install-gdb-printers [ -a dir ] [ -i dir ] [ -p dir ] [ -c ]
29 install-gdb-printers -h
31 Options:
32 -a dir The dir where autoloaders will be placed. Defaults to whatever -i
33 is.
34 -c Create the autoloader's dir if it does not exist. This option only
35 makes sense if both -a and -i are used.
36 -h Show this help text.
37 -i dir The dir where libreoffice is installed. Defaults to whatever -a is.
38 -p dir The dir where pretty printers are placed.
40 Env. variables:
41 DESTDIR If set, it is prepended to all dir arguments.
43 Examples:
44 1) Install pretty printers into /usr/share/libreoffice/gdb, with
45 autoloaders in /usr/share/gdb/auto-load (run
46 "info gdb 'Extending GDB' Python Auto-loading" to learn more) and
47 installation in /usr/lib64/libreoffice (this is what Fedora does):
49 install-gdb-printers -a /usr/share/gdb/auto-load/usr/lib64/libreoffice -c \\
50 -i /usr/lib64/libreoffice -p /usr/share/libreoffice/gdb
51 EOT
54 make_autoload() {
55 local lib="${DESTDIR}${autoloaddir}/$2/$3"
56 local merged="$4"
58 local resolved="$(readlink "${DESTDIR}${installdir}/$2/$3")"
59 [ -n "$resolved" ] && lib=$resolved
60 local dir="${lib%/*}"
62 if ${create}; then
63 mkdir -p "${dir}" || die "cannot create dir '${dir}'"
66 [[ -f ${lib}-gdb.py ]] && rm -f "${lib}-gdb.py"
67 if [[ -n "${merged}" ]]; then
68 sed -e "s!%PYTHONDIR%!${pythondir}!" -e "s!%MODULES%!${*:5}!" \
69 "${GDBDIR}/autoload.template" > "${lib}-gdb.py"
70 else
71 sed -e "s!%PYTHONDIR%!${pythondir}!" -e "s!%MODULES%!$1!" \
72 "${GDBDIR}/autoload.template" > "${lib}-gdb.py"
76 # dir where the autoloaders will be placed
77 autoloaddir=
78 # The installation dir. If only one of these is set, the other is set to
79 # the same value.
80 installdir=
81 # dir where the pretty printers will be placed
82 pythondir="${GDBDIR}"
83 # Create autoload dir if it does not exist. This only makes sense when
84 # installing into system gdb dir, so $autoloaddir must be absolute path.
85 create=false
87 # b de g jklmno qrstuvwxyzABCDEFGHIJK MNOPQRSTUVWXYZ0123456789
88 while getopts :a:cfhi:p:L opt; do
89 case ${opt} in
90 a) autoloaddir="${OPTARG}" ;;
91 c) create=true ;;
92 h) usage; exit ;;
93 i) installdir="${OPTARG}" ;;
94 p) pythondir="${OPTARG}" ;;
95 *) die "unknown option ${OPTARG}" ;;
96 esac
97 done
99 if [[ -z ${autoloaddir} && -z ${installdir} ]]; then
100 autoloaddir="${INSTALLDIR}"
101 installdir="${INSTALLDIR}"
102 elif [[ -n ${autoloaddir} && -z ${installdir} ]]; then
103 installdir="${autoloaddir}"
104 elif [[ -z ${autoloaddir} && -n ${installdir} ]]; then
105 autoloaddir="${installdir}"
108 if [[ -n ${DESTDIR} ]]; then
109 [[ ${autoloaddir:0:1} = / ]] || die 'the arg to -a must be an absolute path'
110 [[ ${pythondir:0:1} = / ]] || die 'the arg to -p must be an absolute path'
112 if ${create}; then
113 [[ ${autoloaddir:0:1} = / ]] || die 'the arg to -a must be an absolute path'
114 else
115 [[ ! -d ${DESTDIR}${autoloaddir} ]] && die "directory '${DESTDIR}${autoloaddir}' does not exist"
117 [[ ! -d ${DESTDIR}${installdir} ]] && die "directory '${DESTDIR}${installdir}' does not exist"
118 [[ ! -d ${GDBDIR} ]] && die "directory '${GDBDIR}' does not exist"
120 if [[ ${DESTDIR}${pythondir} != ${GDBDIR} ]]; then
121 mkdir -p "${DESTDIR}${pythondir}" || die "cannot create dir '${DESTDIR}${pythondir}'"
122 cp -pr "${GDBDIR}/libreoffice" "${DESTDIR}${pythondir}"
125 if [[ -n "${MERGELIBS}" ]]; then
126 make_autoload merged program libmergedlo."$DYLIB" merge svl tl basegfx
127 make_autoload cppu program libuno_cppu."$DYLIB".3
128 make_autoload sal program libuno_sal."$DYLIB".3
129 make_autoload sw program libswlo."$DYLIB"
130 else
131 make_autoload basegfx program libbasegfxlo."$DYLIB"
132 make_autoload cppu program libuno_cppu."$DYLIB".3
133 make_autoload sal program libuno_sal."$DYLIB".3
134 make_autoload svl program libsvllo."$DYLIB"
135 make_autoload sw program libswlo."$DYLIB"
136 make_autoload tl program libtllo."$DYLIB"
138 make_autoload writerfilter program libwriterfilterlo."$DYLIB"
140 # vim:set shiftwidth=4 softtabstop=4 expandtab: