delay, collect and compress LOK invalidations for Writer views
[LibreOffice.git] / bin / symstore.sh
blob2734f1b22a585d8e68073eb2c72b19f070cd920c
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 libcrypto-1_1.dll
20 libssl-1_1.dll
21 freebl3.dll
22 libeay32.dll
23 nspr4.dll
24 nss3.dll
25 nssckbi.dll
26 nssdbm3.dll
27 nssutil3.dll
28 plc4.dll
29 plds4.dll
30 smime3.dll
31 softokn3.dll
32 sqlite3.dll
33 ssl3.dll
34 ssleay32.dll"
36 verbose_none()
38 do_none=
41 add_pdb()
43 extension=$1
44 pdbext=$2
45 list=$3
46 stats_notfound=0
47 stats_found=0
48 stats_morefound=0
49 declare -a pdball
50 echo "Collect $extension"
51 ret=$(find "${INSTDIR}/" -type f -name "*.${extension}" | grep -vF "$EXCLUDE_LIST")
52 while IFS= read -r file
54 ${VERBOSE} -n "Found: $file"
55 # store dll/exe itself (needed for minidumps)
56 if [ $WITHEXEC == 1 ] ; then
57 cygpath -w "$file" >> "$list"
58 ${VERBOSE} " insert"
59 else
60 ${VERBOSE} " "
63 # store pdb file
64 filename=$(basename "$file" ".${extension}")
65 pdball+=($(grep -i "/${filename}${pdbext}" <<< ${ALL_PDBS}))
66 if [ -n "${pdball[0]}" ]; then
67 cygpath -w "${pdball[0]}" >> "$list"
69 case ${#pdball[@]} in
70 0) ((++stats_notfound))
71 ${VERBOSE} " PDB not found"
73 1) ((++stats_found))
74 ${VERBOSE} " ${pdball[0]} insert"
76 *) ((++stats_morefound))
77 if [ -z "$(echo $file | grep -F "$MOREPDBS_OKLIST")" ]; then
78 echo "Error: found duplicate PDBs:"
79 for morepdbs in ${pdball[@]} ; do
80 echo " $morepdbs"
81 done
82 exit 1
83 else
84 ${VERBOSE} " ${pdball[0]} insert (is in more okay list)"
87 esac
88 unset pdball
89 done <<EOF
90 ${ret}
91 EOF
93 echo " Found PDBs : $stats_found"
94 echo " Missing PDBs : $stats_notfound"
95 echo " Multiple PDBs : $stats_morefound"
98 # check preconditions
99 if [ -z "${INSTDIR}" -o -z "${WORKDIR}" ]; then
100 echo "INSTDIR or WORKDIR not set - script expects calling inside buildenv"
101 exit 1
103 if [ ! -d "${INSTDIR}" -o ! -d "${WORKDIR}" ]; then
104 echo "INSTDIR or WORKDIR not present - script expects calling after full build"
105 exit 1
107 which symstore.exe > /dev/null 2>&1 || {
108 echo "symstore.exe is expected in the PATH"
109 exit 1
112 # defaults
113 MAX_KEEP=5
114 SYM_PATH=${WORKDIR}/symstore
115 COMMENT=""
116 COMCMD=""
117 WITHEXEC=1
118 VERBOSE=verbose_none
120 USAGE="Usage: $0 [-h|-k <keep_num_versions>|-p <symbol_store_path>|-c <comment>|-n|-v]
121 -h: this cruft
122 -c <comment> specifies a comment for the transaction
123 -n do not store exe/dll on the symbole server
124 -k <int>: keep this number of old symbol versions around
125 (default: ${MAX_KEEP}. Set to 0 for unlimited)
126 -v verbose mode, output detail report of files
127 -p <path>: specify full path to symbol store tree
128 If no path is specified, defaults to ${SYM_PATH}.
131 # process args
132 while :
134 case "$1" in
135 -k|--keep) MAX_KEEP="$2"; shift 2;;
136 -p|--path) SYM_PATH="$2"; shift 2;;
137 -c|--comment) COMCMD="/c"; COMMENT="$2"; shift 2;;
138 -n|--noexec) WITHEXEC=0; shift ;;
139 -v|--verbose) VERBOSE=echo; shift ;;
140 -h|--help) echo "${USAGE}"; exit 0;;
141 -*) echo "${USAGE}" >&2; exit 1;;
142 *) break;;
143 esac
144 done
146 if [ $# -gt 0 ]; then
147 echo "${USAGE}" >&2
148 exit 1
151 # populate symbol store from here
152 TMPFILE=$(mktemp) || exit 1
153 trap '{ rm -f ${TMPFILE}; }' EXIT
155 # collect all PDBs
156 ALL_PDBS=$(find "${WORKDIR}/" -type f -name "*.pdb")
158 # add dlls and executables
159 add_pdb dll .pdb "${TMPFILE}"
160 add_pdb exe .pdb "${TMPFILE}"
161 add_pdb bin .bin.pdb "${TMPFILE}"
163 # stick all of it into symbol store
164 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}"
165 rm -f "${TMPFILE}"
167 # Cleanup symstore, older revisions will be removed. Unless the
168 # .dll/.exe changes, the .pdb should be shared, so with incremental
169 # tinderbox several revisions should not be that space-demanding.
170 if [ "${MAX_KEEP}" -gt 0 -a -d "${SYM_PATH}/000Admin" ]; then
171 to_remove=$(ls -1 "${SYM_PATH}/000Admin" | grep -v '\.txt' | grep -v '\.deleted' | sort | head -n "-${MAX_KEEP}")
172 for revision in $to_remove; do
173 echo "Remove $revision from symstore"
174 symstore.exe del /i "${revision}" /s "$(cygpath -w "${SYM_PATH}")"
175 done