Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / bin / symstore.sh
blob564739a0279fa5190050a2c2058a22aeb27c61fc
1 #!/usr/bin/env bash
3 # Files listed here would not be store in the symbolestore-server.
4 # The format is a string with files e.g.
5 # BLACKLIST="python.exe
6 # file.dll
7 # next_file.exe"
9 # It removes "python.exe", "file.dll", and "next_file.exe" from what's
10 # added to the symstore. Separator is the newline
11 BLACK_LIST="python.exe"
13 # List files here where it's ok for this script to find more than one
14 # occurence in the build tree. Files _not_ included here will generate
15 # an error, if duplicates are found.
17 # Same format as for BLACK_LIST above above
18 MOREPDBS_OKLIST="libcurl.dll"
21 add_pdb()
23 extension=$1
24 pdbext=$2
25 list=$3
26 stats_notfound=0
27 stats_found=0
28 stats_morefound=0
29 declare -a pdball
30 echo "Collect $extension"
31 ret=$(find "${INSTDIR}/" -type f -name "*.${extension}" | grep -vF "$BLACK_LIST")
32 while IFS= read -r file
34 # store dll/exe itself (needed for minidumps)
35 if [ $WITHEXEC == 1 ] ; then
36 cygpath -w "$file" >> "$list"
38 # store pdb file
39 filename=$(basename "$file" ".${extension}")
40 pdball+=($(grep -i "/${filename}${pdbext}" <<< ${ALL_PDBS}))
41 if [ -n "${pdball[0]}" ]; then
42 cygpath -w "${pdball[0]}" >> "$list"
44 case ${#pdball[@]} in
45 0) ((++stats_notfound)) ;;
46 1) ((++stats_found)) ;;
47 *) ((++stats_morefound))
48 if [ -z "$(echo $file | grep -F "$MOREPDBS_OKLIST")" ]; then
49 echo "Error: found duplicate PDBs:"
50 for morepdbs in ${pdball[@]} ; do
51 echo " $morepdbs"
52 done
53 exit 1
56 esac
57 unset pdball
58 done <<EOF
59 ${ret}
60 EOF
62 echo " Found PDBs : $stats_found"
63 echo " Missing PDBs : $stats_notfound"
64 echo " Multiple PDBs : $stats_morefound"
67 # check preconditions
68 if [ -z "${INSTDIR}" -o -z "${WORKDIR}" ]; then
69 echo "INSTDIR or WORKDIR not set - script expects calling inside buildenv"
70 exit 1
72 if [ ! -d "${INSTDIR}" -o ! -d "${WORKDIR}" ]; then
73 echo "INSTDIR or WORKDIR not present - script expects calling after full build"
74 exit 1
76 which symstore.exe > /dev/null 2>&1 || {
77 echo "symstore.exe is expected in the PATH"
78 exit 1
81 # defaults
82 MAX_KEEP=5
83 SYM_PATH=${WORKDIR}/symstore
84 COMMENT=""
85 COMCMD=""
86 WITHEXEC=1
88 USAGE="Usage: $0 [-h|-k <keep_num_versions>|-p <symbol_store_path>]
89 -h: this cruft
90 -c <comment> specifies a comment for the transaction
91 -n do not store exe/dll on the symbole server
92 -k <int>: keep this number of old symbol versions around
93 (default: ${MAX_KEEP}. Set to 0 for unlimited)
94 -p <path>: specify full path to symbol store tree
95 If no path is specified, defaults to ${SYM_PATH}.
98 # process args
99 while :
101 case "$1" in
102 -k|--keep) MAX_KEEP="$2"; shift 2;;
103 -p|--path) SYM_PATH="$2"; shift 2;;
104 -c|--comment) COMCMD="/c"; COMMENT="$2"; shift 2;;
105 -n|--noexec) WITHEXEC=0; shift ;;
106 -h|--help) echo "${USAGE}"; exit 0;;
107 -*) echo "${USAGE}" >&2; exit 1;;
108 *) break;;
109 esac
110 done
112 if [ $# -gt 0 ]; then
113 echo "${USAGE}" >&2
114 exit 1
117 # populate symbol store from here
118 TMPFILE=$(mktemp) || exit 1
119 trap '{ rm -f ${TMPFILE}; }' EXIT
121 # collect all PDBs
122 ALL_PDBS=$(find "${WORKDIR}/" -type f -name "*.pdb")
124 # add dlls and executables
125 add_pdb dll .pdb "${TMPFILE}"
126 add_pdb exe .pdb "${TMPFILE}"
127 add_pdb bin .bin.pdb "${TMPFILE}"
129 # stick all of it into symbol store
130 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}" "${COMCMD}" "${COMMENT}"
131 rm -f "${TMPFILE}"
133 # Cleanup symstore, older revisions will be removed. Unless the
134 # .dll/.exe changes, the .pdb should be shared, so with incremental
135 # tinderbox several revisions should not be that space-demanding.
136 if [ "${MAX_KEEP}" -gt 0 -a -d "${SYM_PATH}/000Admin" ]; then
137 to_remove=$(ls -1 "${SYM_PATH}/000Admin" | grep -v '\.txt' | grep -v '\.deleted' | sort | head -n "-${MAX_KEEP}")
138 for revision in $to_remove; do
139 echo "Remove $revision from symstore"
140 symstore.exe del /i "${revision}" /s "$(cygpath -w "${SYM_PATH}")"
141 done