Resolves tdf#142513 - Order of ZoomIn and ZoomOut at Print Preview
[LibreOffice.git] / bin / symstore.sh
blobc4e9870c9aa56981c86ccc9240c2d191362355dc
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 # EXCLUDE_LIST="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 EXCLUDE_LIST="python.exe"
13 # List files here where it's ok for this script to find more than one
14 # occurrence in the build tree. Files _not_ included here will generate
15 # an error, if duplicates are found.
17 # Same format as for EXCLUDE_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"
34 verbose_none()
36 do_none=
39 add_pdb()
41 extension=$1
42 pdbext=$2
43 list=$3
44 stats_notfound=0
45 stats_found=0
46 stats_morefound=0
47 declare -a pdball
48 echo "Collect $extension"
49 ret=$(find "${INSTDIR}/" -type f -name "*.${extension}" | grep -vF "$EXCLUDE_LIST")
50 while IFS= read -r file
52 ${VERBOSE} -n "Found: $file"
53 # store dll/exe itself (needed for minidumps)
54 if [ $WITHEXEC == 1 ] ; then
55 cygpath -w "$file" >> "$list"
56 ${VERBOSE} " insert"
57 else
58 ${VERBOSE} " "
61 # store pdb file
62 filename=$(basename "$file" ".${extension}")
63 pdball+=($(grep -i "/${filename}${pdbext}" <<< ${ALL_PDBS}))
64 if [ -n "${pdball[0]}" ]; then
65 cygpath -w "${pdball[0]}" >> "$list"
67 case ${#pdball[@]} in
68 0) ((++stats_notfound))
69 ${VERBOSE} " PDB not found"
71 1) ((++stats_found))
72 ${VERBOSE} " ${pdball[0]} insert"
74 *) ((++stats_morefound))
75 if [ -z "$(echo $file | grep -F "$MOREPDBS_OKLIST")" ]; then
76 echo "Error: found duplicate PDBs:"
77 for morepdbs in ${pdball[@]} ; do
78 echo " $morepdbs"
79 done
80 exit 1
81 else
82 ${VERBOSE} " ${pdball[0]} insert (is in more okay list)"
85 esac
86 unset pdball
87 done <<EOF
88 ${ret}
89 EOF
91 echo " Found PDBs : $stats_found"
92 echo " Missing PDBs : $stats_notfound"
93 echo " Multiple PDBs : $stats_morefound"
96 # check preconditions
97 if [ -z "${INSTDIR}" -o -z "${WORKDIR}" ]; then
98 echo "INSTDIR or WORKDIR not set - script expects calling inside buildenv"
99 exit 1
101 if [ ! -d "${INSTDIR}" -o ! -d "${WORKDIR}" ]; then
102 echo "INSTDIR or WORKDIR not present - script expects calling after full build"
103 exit 1
105 which symstore.exe > /dev/null 2>&1 || {
106 echo "symstore.exe is expected in the PATH"
107 exit 1
110 # defaults
111 MAX_KEEP=5
112 SYM_PATH=${WORKDIR}/symstore
113 COMMENT=""
114 COMCMD=""
115 WITHEXEC=1
116 VERBOSE=verbose_none
118 USAGE="Usage: $0 [-h|-k <keep_num_versions>|-p <symbol_store_path>|-c <comment>|-n|-v]
119 -h: this cruft
120 -c <comment> specifies a comment for the transaction
121 -n do not store exe/dll on the symbole server
122 -k <int>: keep this number of old symbol versions around
123 (default: ${MAX_KEEP}. Set to 0 for unlimited)
124 -v verbose mode, output detail report of files
125 -p <path>: specify full path to symbol store tree
126 If no path is specified, defaults to ${SYM_PATH}.
129 # process args
130 while :
132 case "$1" in
133 -k|--keep) MAX_KEEP="$2"; shift 2;;
134 -p|--path) SYM_PATH="$2"; shift 2;;
135 -c|--comment) COMCMD="/c"; COMMENT="$2"; shift 2;;
136 -n|--noexec) WITHEXEC=0; shift ;;
137 -v|--verbose) VERBOSE=echo; shift ;;
138 -h|--help) echo "${USAGE}"; exit 0;;
139 -*) echo "${USAGE}" >&2; exit 1;;
140 *) break;;
141 esac
142 done
144 if [ $# -gt 0 ]; then
145 echo "${USAGE}" >&2
146 exit 1
149 # populate symbol store from here
150 TMPFILE=$(mktemp) || exit 1
151 trap '{ rm -f ${TMPFILE}; }' EXIT
153 # collect all PDBs
154 ALL_PDBS=$(find "${WORKDIR}/" -type f -name "*.pdb")
156 # add dlls and executables
157 add_pdb dll .pdb "${TMPFILE}"
158 add_pdb exe .pdb "${TMPFILE}"
159 add_pdb bin .bin.pdb "${TMPFILE}"
161 # stick all of it into symbol store
162 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}"
163 rm -f "${TMPFILE}"
165 # Cleanup symstore, older revisions will be removed. Unless the
166 # .dll/.exe changes, the .pdb should be shared, so with incremental
167 # tinderbox several revisions should not be that space-demanding.
168 if [ "${MAX_KEEP}" -gt 0 -a -d "${SYM_PATH}/000Admin" ]; then
169 to_remove=$(ls -1 "${SYM_PATH}/000Admin" | grep -v '\.txt' | grep -v '\.deleted' | sort | head -n "-${MAX_KEEP}")
170 for revision in $to_remove; do
171 echo "Remove $revision from symstore"
172 symstore.exe del /i "${revision}" /s "$(cygpath -w "${SYM_PATH}")"
173 done