diff options
author | Martin Jansa <martin.jansa@gmail.com> | 2014-06-25 19:06:36 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-06-29 09:04:22 +0100 |
commit | 4e2656dc103e598aa6ce833705dce612692a6461 (patch) | |
tree | 15b252d4ac64fb6d8f5cccae02364b089fcfed1a /scripts | |
parent | 442efc3959a65fc9da73f79b3afda95d1cffadf3 (diff) | |
download | poky-4e2656dc103e598aa6ce833705dce612692a6461.tar.gz |
sstate-diff-machines.sh: Return non-zero return code when there was some failure detected
* add --analyze option, which is useful when using from jenkins job
where you don't want to read output just to dectect how bad it was
* I was always using something like this inside jenkins job, but better
to share it in original script
(From OE-Core rev: e73e1261879d9154d89cec35669ba22b499d8331)
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/sstate-diff-machines.sh | 85 |
1 files changed, 75 insertions, 10 deletions
diff --git a/scripts/sstate-diff-machines.sh b/scripts/sstate-diff-machines.sh index 860be73679..056aa0a04c 100755 --- a/scripts/sstate-diff-machines.sh +++ b/scripts/sstate-diff-machines.sh | |||
@@ -1,7 +1,8 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/bash |
2 | 2 | ||
3 | # Used to compare sstate checksums between MACHINES | 3 | # Used to compare sstate checksums between MACHINES. |
4 | # Execute script and compare generated list.M files | 4 | # Execute script and compare generated list.M files. |
5 | # Using bash to have PIPESTATUS variable. | ||
5 | 6 | ||
6 | # It's also usefull to keep older sstate checksums | 7 | # It's also usefull to keep older sstate checksums |
7 | # to be able to find out why something is rebuilding | 8 | # to be able to find out why something is rebuilding |
@@ -27,6 +28,7 @@ machines= | |||
27 | targets= | 28 | targets= |
28 | default_machines="qemuarm qemux86 qemux86-64" | 29 | default_machines="qemuarm qemux86 qemux86-64" |
29 | default_targets="core-image-base" | 30 | default_targets="core-image-base" |
31 | analyze="N" | ||
30 | 32 | ||
31 | usage () { | 33 | usage () { |
32 | cat << EOF | 34 | cat << EOF |
@@ -48,6 +50,12 @@ Options: | |||
48 | --targets=<targets> | 50 | --targets=<targets> |
49 | List of targets separated by space, will use the environment variable TARGETS if it is not specified. | 51 | List of targets separated by space, will use the environment variable TARGETS if it is not specified. |
50 | Default value is "core-image-base". | 52 | Default value is "core-image-base". |
53 | |||
54 | --analyze | ||
55 | Show the differences between MACHINEs. It assumes: | ||
56 | * First 2 MACHINEs in --machines parameter have the same TUNE_PKGARCH | ||
57 | * Third optional MACHINE has different TUNE_PKGARCH - only native and allarch recipes are compared). | ||
58 | * Next MACHINEs are ignored | ||
51 | EOF | 59 | EOF |
52 | } | 60 | } |
53 | 61 | ||
@@ -72,6 +80,10 @@ while [ -n "$1" ]; do | |||
72 | targets=`echo $1 | sed -e 's#^--targets="*\([^"]*\)"*#\1#'` | 80 | targets=`echo $1 | sed -e 's#^--targets="*\([^"]*\)"*#\1#'` |
73 | shift | 81 | shift |
74 | ;; | 82 | ;; |
83 | --analyze) | ||
84 | analyze="Y" | ||
85 | shift | ||
86 | ;; | ||
75 | --help|-h) | 87 | --help|-h) |
76 | usage | 88 | usage |
77 | exit 0 | 89 | exit 0 |
@@ -94,14 +106,67 @@ done | |||
94 | [ -n "$targets" ] || targets=$default_targets | 106 | [ -n "$targets" ] || targets=$default_targets |
95 | 107 | ||
96 | OUTPUT=${tmpdir}/sstate-diff/`date "+%s"` | 108 | OUTPUT=${tmpdir}/sstate-diff/`date "+%s"` |
109 | declare -i RESULT=0 | ||
97 | 110 | ||
98 | for M in ${machines}; do | 111 | for M in ${machines}; do |
99 | find ${tmpdir}/stamps/ -name \*sigdata\* | xargs rm -f | 112 | [ -d ${tmpdir}/stamps/ ] && find ${tmpdir}/stamps/ -name \*sigdata\* | xargs rm -f |
100 | mkdir -p ${OUTPUT}/${M} | 113 | mkdir -p ${OUTPUT}/${M} |
101 | export MACHINE=${M}; bitbake -S none ${targets} | tee -a ${OUTPUT}/${M}/log; | 114 | export MACHINE=${M} |
102 | cp -ra ${tmpdir}/stamps/* ${OUTPUT}/${M} | 115 | bitbake -S none ${targets} 2>&1 | tee -a ${OUTPUT}/${M}/log; |
103 | find ${OUTPUT}/${M} -name \*sigdata\* | sed "s#${OUTPUT}/${M}/##g" | sort > ${OUTPUT}/${M}/list | 116 | RESULT+=${PIPESTATUS[0]} |
104 | M_UNDERSCORE=`echo ${M} | sed 's/-/_/g'` | 117 | if ls ${tmpdir}/stamps/* >/dev/null 2>/dev/null ; then |
105 | sed "s/${M_UNDERSCORE}/MACHINE/g; s/${M}/MACHINE/g" ${OUTPUT}/${M}/list | sort > ${OUTPUT}/${M}/list.M | 118 | cp -ra ${tmpdir}/stamps/* ${OUTPUT}/${M} |
106 | find ${tmpdir}/stamps/ -name \*sigdata\* | xargs rm -f | 119 | find ${OUTPUT}/${M} -name \*sigdata\* | sed "s#${OUTPUT}/${M}/##g" | sort > ${OUTPUT}/${M}/list |
120 | M_UNDERSCORE=`echo ${M} | sed 's/-/_/g'` | ||
121 | sed "s/${M_UNDERSCORE}/MACHINE/g; s/${M}/MACHINE/g" ${OUTPUT}/${M}/list | sort > ${OUTPUT}/${M}/list.M | ||
122 | find ${tmpdir}/stamps/ -name \*sigdata\* | xargs rm -f | ||
123 | else | ||
124 | printf "ERROR: no sigdata files were generated for MACHINE $M in ${tmpdir}/stamps\n"; | ||
125 | fi | ||
107 | done | 126 | done |
127 | |||
128 | function compareSignatures() { | ||
129 | MACHINE1=$1 | ||
130 | MACHINE2=$2 | ||
131 | PATTERN="$3" | ||
132 | PRE_PATTERN="" | ||
133 | [ -n "${PATTERN}" ] || PRE_PATTERN="-v" | ||
134 | [ -n "${PATTERN}" ] || PATTERN="MACHINE" | ||
135 | for TASK in do_configure.sigdata do_populate_sysroot.sigdata do_package_write_ipk.sigdata; do | ||
136 | printf "\n\n === Comparing signatures for task ${TASK} between ${MACHINE1} and ${MACHINE2} ===\n" | tee -a ${OUTPUT}/signatures.${MACHINE2}.${TASK}.log | ||
137 | diff ${OUTPUT}/${MACHINE1}/list.M ${OUTPUT}/${MACHINE2}/list.M | grep ${PRE_PATTERN} "${PATTERN}" | grep ${TASK} > ${OUTPUT}/signatures.${MACHINE2}.${TASK} | ||
138 | for i in `cat ${OUTPUT}/signatures.${MACHINE2}.${TASK} | sed 's#[^/]*/\([^/]*\)/.*#\1#g' | sort -u | xargs`; do | ||
139 | [ -e ${OUTPUT}/${MACHINE1}/*/$i/*${TASK}* ] || echo "INFO: ${i} task ${TASK} doesn't exist in ${MACHINE1}" >&2 | ||
140 | [ -e ${OUTPUT}/${MACHINE1}/*/$i/*${TASK}* ] || continue | ||
141 | [ -e ${OUTPUT}/${MACHINE2}/*/$i/*${TASK}* ] || echo "INFO: ${i} task ${TASK} doesn't exist in ${MACHINE2}" >&2 | ||
142 | [ -e ${OUTPUT}/${MACHINE2}/*/$i/*${TASK}* ] || continue | ||
143 | printf "ERROR: $i different signature for task ${TASK} between ${MACHINE1} and ${MACHINE2}\n"; | ||
144 | bitbake-diffsigs ${OUTPUT}/${MACHINE1}/*/$i/*${TASK}* ${OUTPUT}/${MACHINE2}/*/$i/*${TASK}*; | ||
145 | echo "$i" >> ${OUTPUT}/failed-recipes.log | ||
146 | echo | ||
147 | done | tee -a ${OUTPUT}/signatures.${MACHINE2}.${TASK}.log | ||
148 | # don't create empty files | ||
149 | ERRORS=`grep "^ERROR.*" ${OUTPUT}/signatures.${MACHINE2}.${TASK}.log | wc -l` | ||
150 | if [ "${ERRORS}" != "0" ] ; then | ||
151 | echo "ERROR: ${ERRORS} errors found in ${OUTPUT}/signatures.${MACHINE2}.${TASK}.log" | ||
152 | RESULT+=${ERRORS} | ||
153 | fi | ||
154 | done | ||
155 | } | ||
156 | |||
157 | function compareMachines() { | ||
158 | [ "$#" -ge 2 ] && compareSignatures $1 $2 | ||
159 | [ "$#" -ge 3 ] && compareSignatures $1 $3 "\(^< all\)\|\(^< x86_64-linux\)\|\(^< i586-linux\)" | ||
160 | } | ||
161 | |||
162 | if [ "${analyze}" = "Y" ] ; then | ||
163 | compareMachines ${machines} | ||
164 | fi | ||
165 | |||
166 | if [ "${RESULT}" != "0" -a -f ${OUTPUT}/failed-recipes.log ] ; then | ||
167 | cat ${OUTPUT}/failed-recipes.log | sort -u >${OUTPUT}/failed-recipes.log.u && mv ${OUTPUT}/failed-recipes.log.u ${OUTPUT}/failed-recipes.log | ||
168 | echo "ERROR: ${RESULT} issues were found in these recipes: `cat ${OUTPUT}/failed-recipes.log | xargs`" | ||
169 | fi | ||
170 | |||
171 | echo "INFO: Output written in: ${OUTPUT}" | ||
172 | exit ${RESULT} | ||