3 # Copyright (c) 2009, 2010, 2012 SUSE Linux Product GmbH, Germany.
4 # Licensed under GPL v2, see COPYING file for details.
6 # Written by Adrian Schroeter <adrian@suse.de>
7 # Enhanced by Andreas Jaeger <aj@suse.de>
9 # The script decides if the new build differes from the former one,
11 # The script is called as part of the build process as:
12 # /usr/lib/build/same-build-result.sh /.build.oldpackages /usr/src/packages/RPMS /usr/src/packages/SRPMS
14 CMPSCRIPT=${0%/*}/pkg-diff.sh
15 SCMPSCRIPT=${0%/*}/srpm-check.sh
24 if [ ! -d "$OLDDIR" ]; then
25 echo "No valid directory with old build result given !"
28 if [ -z "$NEWDIRS" ]; then
29 echo "No valid directory with new build result given !"
33 if test `find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l` != `find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l`; then
34 echo "different number of subpackages"
35 find $OLDDIR $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm'
39 osrpm=$(find "$OLDDIR" -name \*src.rpm)
40 nsrpm=$(find $NEWDIRS -name \*src.rpm)
42 if test ! -f "$osrpm"; then
43 echo no old source rpm in $OLDDIR
47 if test ! -f "$nsrpm"; then
48 echo no new source rpm in $NEWDIRS
52 echo "compare $osrpm $nsrpm"
53 bash $SCMPSCRIPT "$osrpm" "$nsrpm" || exit 1
55 # technically we should not all exclude all -32bit but filter for different archs,
57 # but it would be better if this script ran earlier in the build
58 # sort the rpms so that both lists have the same order
59 # problem: a package can contain both noarch and arch subpackages, so we have to
60 # take care of proper sorting of NEWRPMS, e.g. noarch/x.rpm and x86_64/w.rpm since OLDRPMS
61 # has all the packages in a single directory and would sort this as w.rpm, x.rpm.
62 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'))
63 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'))
65 # Get version-release from first RPM and keep for rpmlint check
66 # Remember to quote the "." for future regexes
67 ver_rel1=$(rpm -qp --nodigest --nosignature --qf "%{VERSION}-%{RELEASE}" "${OLDRPMS[0]}"|sed -e 's/\./\\./g')
68 ver_rel2=$(rpm -qp --nodigest --nosignature --qf "%{VERSION}-%{RELEASE}" "${NEWRPMS[0]}"|sed -e 's/\./\\./g')
71 rpmqp='rpm -qp --qf %{NAME} --nodigest --nosignature '
72 for opac in ${OLDRPMS[*]}; do
74 NEWRPMS=(${NEWRPMS[@]:1}) # shift
75 echo compare "$opac" "$npac"
78 if test "$oname" != "$nname"; then
79 echo "names differ: $oname $nname"
84 echo "skipping -debuginfo package"
87 bash $CMPSCRIPT "$opac" "$npac" || SUCCESS=0
88 if test $SUCCESS -eq 0 -a -z "$check_all"; then
89 echo "differences between $opac and $npac"
96 if [ -n "${NEWRPMS[0]}" ]; then
97 echo additional new package
101 # Compare rpmlint.log files
102 if test -d /home/abuild/rpmbuild/OTHER; then
103 OTHERDIR=/home/abuild/rpmbuild/OTHER
104 elif test -d /usr/src/packages/OTHER; then
105 OTHERDIR=/usr/src/packages/OTHER
111 if test -n "$OTHERDIR"; then
112 if test -e $OLDDIR/rpmlint.log -a -e $OTHERDIR/rpmlint.log; then
115 echo "comparing $OLDDIR/rpmlint.log and $OTHERDIR/rpmlint.log"
116 # Sort the files first since the order of messages is not deterministic
117 # Remove release from files
118 sort -u $OLDDIR/rpmlint.log|sed -e "s,$ver_rel1,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file1
119 sort -u $OTHERDIR/rpmlint.log|sed -e "s,$ver_rel2,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file2
120 if ! cmp -s $file1 $file2; then
121 echo "rpmlint.log files differ:"
122 diff -u $file1 $file2 |head -n 20
126 elif test -e $OTHERDIR/rpmlint.log; then
127 echo "rpmlint.log is new"
131 appdatas=`cd $OTHERDIR && find . -name *-appdata.xml`
132 for xml in $appdatas; do
133 # compare appstream data
134 if test -e $OLDDIR/$xml -a -e $OTHERDIR/$xml; then
137 if ! cmp -s $file1 $file2; then
138 echo "$xml files differ:"
139 diff -u0 $file1 $file2 |head -n 20
142 elif test -e $OTHERDIR/$xml; then
149 if test $SUCCESS -eq 0; then
152 echo 'compare validated built as identical !'
154 # vim: tw=666 ts=2 shiftwidth=2 et