Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / bin / symstore.sh
blobb368eb3e67153b1fd22fa37291bfa0e2a2f324de
1 #!/usr/bin/env bash
3 add_pdb()
5 extension=$1
6 type=$2
7 list=$3
8 for file in $(find "${INSTDIR}/" -name "*.${extension}"); do
9 # store dll/exe itself (needed for minidumps)
10 if [ -f "$file" ]; then
11 cygpath -w "$file" >> "$list"
13 # store pdb file
14 filename=$(basename "$file" ".${extension}")
15 pdb="${WORKDIR}/LinkTarget/${type}/${filename}.pdb"
16 if [ -f "$pdb" ]; then
17 cygpath -w "$pdb" >> "$list"
19 done
22 # check preconditions
23 if [ -z "${INSTDIR}" ] || [ -z "${WORKDIR}" ]; then
24 echo "INSTDIR or WORKDIR not set - script expects calling inside buildenv"
25 exit 1
27 if [ ! -d "${INSTDIR}" ] || [ ! -d "${WORKDIR}" ]; then
28 echo "INSTDIR or WORKDIR not present - script expects calling after full build"
29 exit 1
31 which symstore.exe > /dev/null 2>&1 || {
32 echo "symstore.exe is expected in the PATH"
33 exit 1
36 # defaults
37 MAX_KEEP=5
38 SYM_PATH=${WORKDIR}/symstore
40 USAGE="Usage: $0 [-h|-k <keep_num_versions>|-p <symbol_store_path>]
41 -h: this cruft
42 -k <int>: keep this number of old symbol versions around
43 (default: ${MAX_KEEP}. Set to 0 for unlimited)
44 -p <path>: specify full path to symbol store tree
45 If no path is specified, defaults to ${SYM_PATH}.
48 # process args
49 while :
51 case "$1" in
52 -k|--keep) MAX_KEEP="$2"; shift 2;;
53 -p|--path) SYM_PATH="$2"; shift 2;;
54 -h|--help) echo "${USAGE}"; exit 0; shift;;
55 -*) echo "${USAGE}" >&2; exit 1;;
56 *) break;;
57 esac
58 done
60 if [ $# -gt 0 ]; then
61 echo "${USAGE}" >&2
62 exit 1
65 # populate symbol store from here
66 TMPFILE=$(mktemp) || exit 1
67 trap '{ rm -f ${TMPFILE}; }' EXIT
69 # add dlls and executables
70 add_pdb dll Library "${TMPFILE}"
71 add_pdb exe Executable "${TMPFILE}"
73 # stick all of it into symbol store
74 symstore.exe add /compress /f "@$(cygpath -w "${TMPFILE}")" /s "$(cygpath -w "${SYM_PATH}")" /t "${PRODUCTNAME}" /v "${LIBO_VERSION_MAJOR}.${LIBO_VERSION_MINOR}.${LIBO_VERSION_MICRO}.${LIBO_VERSION_PATCH}${LIBO_VERSION_SUFFIX}${LIBO_VERSION_SUFFIX_SUFFIX}"
75 rm -f "${TMPFILE}"
77 # Cleanup symstore, older revisions will be removed. Unless the
78 # .dll/.exe changes, the .pdb should be shared, so with incremental
79 # tinderbox several revisions should not be that space-demanding.
80 if [ "${MAX_KEEP}" -gt 0 ] && [ -d "${SYM_PATH}/000Admin" ]; then
81 to_remove=$(ls -1 "${SYM_PATH}/000Admin" | grep -v '\.txt' | grep -v '\.deleted' | sort | head -n "-${MAX_KEEP}")
82 for revision in $to_remove; do
83 symstore.exe del /i "${revision}" /s "$(cygpath -w "${SYM_PATH}")"
84 done