update credits
[LibreOffice.git] / bin / symstore.sh
blobf4b0a5d139439081cd552f3497b0c9f36ab6ba9b
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
18 MOREPDBS_OKLIST="libcurl.dll
19 freebl3.dll
20 libeay32.dll
21 nspr4.dll
22 nss3.dll
23 nssckbi.dll
24 nssdbm3.dll
25 nssutil3.dll
26 plc4.dll
27 plds4.dll
28 smime3.dll
29 softokn3.dll
30 sqlite3.dll
31 ssl3.dll
32 ssleay32.dll"
35 add_pdb()
37 extension=$1
38 pdbext=$2
39 list=$3
40 stats_notfound=0
41 stats_found=0
42 stats_morefound=0
43 declare -a pdball
44 echo "Collect $extension"
45 ret=$(find "${INSTDIR}/" -type f -name "*.${extension}" | grep -vF "$BLACK_LIST")
46 while IFS= read -r file
48 # store dll/exe itself (needed for minidumps)
49 if [ $WITHEXEC == 1 ] ; then
50 cygpath -w "$file" >> "$list"
52 # store pdb file
53 filename=$(basename "$file" ".${extension}")
54 pdball+=($(grep -i "/${filename}${pdbext}" <<< ${ALL_PDBS}))
55 if [ -n "${pdball[0]}" ]; then
56 cygpath -w "${pdball[0]}" >> "$list"
58 case ${#pdball[@]} in
59 0) ((++stats_notfound)) ;;
60 1) ((++stats_found)) ;;
61 *) ((++stats_morefound))
62 if [ -z "$(echo $file | grep -F "$MOREPDBS_OKLIST")" ]; then
63 echo "Error: found duplicate PDBs:"
64 for morepdbs in ${pdball[@]} ; do
65 echo " $morepdbs"
66 done
67 exit 1
70 esac
71 unset pdball
72 done <<EOF
73 ${ret}
74 EOF
76 echo " Found PDBs : $stats_found"
77 echo " Missing PDBs : $stats_notfound"
78 echo " Multiple PDBs : $stats_morefound"
81 # check preconditions
82 if [ -z "${INSTDIR}" -o -z "${WORKDIR}" ]; then
83 echo "INSTDIR or WORKDIR not set - script expects calling inside buildenv"
84 exit 1
86 if [ ! -d "${INSTDIR}" -o ! -d "${WORKDIR}" ]; then
87 echo "INSTDIR or WORKDIR not present - script expects calling after full build"
88 exit 1
90 which symstore.exe > /dev/null 2>&1 || {
91 echo "symstore.exe is expected in the PATH"
92 exit 1
95 # defaults
96 MAX_KEEP=5
97 SYM_PATH=${WORKDIR}/symstore
98 COMMENT=""
99 COMCMD=""
100 WITHEXEC=1
102 USAGE="Usage: $0 [-h|-k <keep_num_versions>|-p <symbol_store_path>]
103 -h: this cruft
104 -c <comment> specifies a comment for the transaction
105 -n do not store exe/dll on the symbole server
106 -k <int>: keep this number of old symbol versions around
107 (default: ${MAX_KEEP}. Set to 0 for unlimited)
108 -p <path>: specify full path to symbol store tree
109 If no path is specified, defaults to ${SYM_PATH}.
112 # process args
113 while :
115 case "$1" in
116 -k|--keep) MAX_KEEP="$2"; shift 2;;
117 -p|--path) SYM_PATH="$2"; shift 2;;
118 -c|--comment) COMCMD="/c"; COMMENT="$2"; shift 2;;
119 -n|--noexec) WITHEXEC=0; shift ;;
120 -h|--help) echo "${USAGE}"; exit 0;;
121 -*) echo "${USAGE}" >&2; exit 1;;
122 *) break;;
123 esac
124 done
126 if [ $# -gt 0 ]; then
127 echo "${USAGE}" >&2
128 exit 1
131 # populate symbol store from here
132 TMPFILE=$(mktemp) || exit 1
133 trap '{ rm -f ${TMPFILE}; }' EXIT
135 # collect all PDBs
136 ALL_PDBS=$(find "${WORKDIR}/" -type f -name "*.pdb")
138 # add dlls and executables
139 add_pdb dll .pdb "${TMPFILE}"
140 add_pdb exe .pdb "${TMPFILE}"
141 add_pdb bin .bin.pdb "${TMPFILE}"
143 # stick all of it into symbol store
144 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}"
145 rm -f "${TMPFILE}"
147 # Cleanup symstore, older revisions will be removed. Unless the
148 # .dll/.exe changes, the .pdb should be shared, so with incremental
149 # tinderbox several revisions should not be that space-demanding.
150 if [ "${MAX_KEEP}" -gt 0 -a -d "${SYM_PATH}/000Admin" ]; then
151 to_remove=$(ls -1 "${SYM_PATH}/000Admin" | grep -v '\.txt' | grep -v '\.deleted' | sort | head -n "-${MAX_KEEP}")
152 for revision in $to_remove; do
153 echo "Remove $revision from symstore"
154 symstore.exe del /i "${revision}" /s "$(cygpath -w "${SYM_PATH}")"
155 done