forked from openSUSE/build-compare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
same-build-result.sh
144 lines (127 loc) · 4.43 KB
/
same-build-result.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
#
# Copyright (c) 2009, 2010, 2012 SUSE Linux Product GmbH, Germany.
# Licensed under GPL v2, see COPYING file for details.
#
# Written by Adrian Schroeter <[email protected]>
# Enhanced by Andreas Jaeger <[email protected]>
#
# The script decides if the new build differes from the former one,
# using rpm-check.sh.
# The script is called as part of the build process as:
# /usr/lib/build/same-build-result.sh /.build.oldpackages /usr/src/packages/RPMS /usr/src/packages/SRPMS
CMPSCRIPT=${0%/*}/rpm-check.sh
SCMPSCRIPT=${0%/*}/srpm-check.sh
check_all=1
OLDDIR="$1"
shift
NEWDIRS="$*"
echo "$CMPSCRIPT"
if [ ! -d "$OLDDIR" ]; then
echo "No valid directory with old build result given !"
exit 1
fi
if [ -z "$NEWDIRS" ]; then
echo "No valid directory with new build result given !"
exit 1
fi
if test `find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l` != `find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l`; then
echo "different number of subpackages"
find $OLDDIR $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm'
exit 1
fi
osrpm=$(find "$OLDDIR" -name \*src.rpm)
nsrpm=$(find $NEWDIRS -name \*src.rpm)
if test ! -f "$osrpm"; then
echo no old source rpm in $OLDDIR
exit 1
fi
if test ! -f "$nsrpm"; then
echo no new source rpm in $NEWDIRS
exit 1
fi
echo "compare $osrpm $nsrpm"
bash $SCMPSCRIPT "$osrpm" "$nsrpm" || exit 1
# technically we should not all exclude all -32bit but filter for different archs,
# like done with -x86
# but it would be better if this script ran earlier in the build
# sort the rpms so that both lists have the same order
# problem: a package can contain both noarch and arch subpackages, so we have to
# take care of proper sorting of NEWRPMS, e.g. noarch/x.rpm and x86_64/w.rpm since OLDRPMS
# has all the packages in a single directory and would sort this as w.rpm, x.rpm.
OLDRPMS=($(find "$OLDDIR" -type f -name \*rpm -a ! -name \*src.rpm -a ! -name \*.delta.rpm|sort|grep -v -- -32bit-|grep -v -- -64bit-|grep -v -- '-x86-.*\.ia64\.rpm'))
NEWRPMS=($(find $NEWDIRS -type f -name \*rpm -a ! -name \*src.rpm -a ! -name \*.delta.rpm|sort --field-separator=/ --key=7|grep -v -- -32bit-|grep -v -- -64bit-|grep -v -- '-x86-.*\.ia64\.rpm'))
# Get version-release from first RPM and keep for rpmlint check
# Remember to quote the "." for future regexes
ver_rel1=$(rpm -qp --nodigest --nosignature --qf "%{VERSION}-%{RELEASE}" "${OLDRPMS[0]}"|sed -e 's/\./\\./g')
ver_rel2=$(rpm -qp --nodigest --nosignature --qf "%{VERSION}-%{RELEASE}" "${NEWRPMS[0]}"|sed -e 's/\./\\./g')
SUCCESS=1
rpmqp='rpm -qp --qf %{NAME} --nodigest --nosignature '
for opac in ${OLDRPMS[*]}; do
npac=${NEWRPMS[0]}
NEWRPMS=(${NEWRPMS[@]:1}) # shift
echo compare "$opac" "$npac"
oname=`$rpmqp $opac`
nname=`$rpmqp $npac`
if test "$oname" != "$nname"; then
echo "names differ: $oname $nname"
exit 1
fi
case "$opac" in
*debuginfo*)
echo "skipping -debuginfo package"
;;
*)
bash $CMPSCRIPT "$opac" "$npac" || SUCCESS=0
if test $SUCCESS -eq 0 -a -z "$check_all"; then
exit 1
fi
;;
esac
done
if [ -n "${NEWRPMS[0]}" ]; then
echo additional new package
exit 1
fi
# Compare rpmlint.log files
OTHERDIR=/home/abuild/rpmbuild/OTHER
if test -e $OLDDIR/rpmlint.log -a -e $OTHERDIR/rpmlint.log; then
file1=`mktemp`
file2=`mktemp`
echo "comparing $OLDDIR/rpmlint.log and $OTHERDIR/rpmlint.log"
# Sort the files first since the order of messages is not deterministic
# Remove release from files
sort -u $OLDDIR/rpmlint.log|sed -e "s,$ver_rel1,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file1
sort -u $OTHERDIR/rpmlint.log|sed -e "s,$ver_rel2,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file2
if ! cmp -s $file1 $file2; then
echo "rpmlint.log files differ:"
diff -u $file1 $file2 |head -n 20
SUCCESS=0
fi
rm $file1 $file2
elif test -e $OTHERDIR/rpmlint.log; then
echo "rpmlint.log is new"
SUCCESS=0
fi
appdatas=`cd $OTHERDIR && find . -name *-appdata.xml`
for xml in $appdatas; do
# compare appstream data
if test -e $OLDDIR/$xml -a -e $OTHERDIR/$xml; then
file1=$OLDDIR/$xml
file2=$OTHERDIR/$xml
if ! cmp -s $file1 $file2; then
echo "$xml files differ:"
diff -u0 $file1 $file2 |head -n 20
SUCCESS=0
fi
elif test -e $OTHERDIR/$xml; then
echo "$xml is new"
SUCCESS=0
fi
done
if test $SUCCESS -eq 0; then
exit 1
fi
echo 'compare validated built as identical !'
exit 0
# vim: tw=666 ts=2 et