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 first_rpm=$(find $NEWDIRS -name *.rpm | head -1)
34 dist=$(rpm -qp --nodigest --nosignature --qf "%{DISTRIBUTION}" $first_rpm | sed -r 's/(.*)\/.*/\1/')
36 if ! is_prerelease_project $dist; then
37 echo "This is a prerelease project. Do not check the existence of source rpm files."
40 num_new_pkgs=`find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' -and ! -name '*.src.rpm' | wc -l`
41 num_old_pkgs=`find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' -and ! -name '*.src.rpm' | wc -l`
42 if test $num_new_pkgs != $num_old_pkgs; then
43 echo "different number of subpackages"
44 find $OLDDIR $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm'
49 if test `find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l` != `find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l`; then
50 echo "different number of subpackages"
51 find $OLDDIR $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm'
55 osrpm=$(find "$OLDDIR" -name \*src.rpm)
56 nsrpm=$(find $NEWDIRS -name \*src.rpm)
58 if test ! -f "$osrpm"; then
59 echo no old source rpm in $OLDDIR
63 if test ! -f "$nsrpm"; then
64 echo no new source rpm in $NEWDIRS
68 echo "compare $osrpm $nsrpm"
69 bash $SCMPSCRIPT "$osrpm" "$nsrpm" || exit 1
72 # technically we should not all exclude all -32bit but filter for different archs,
74 # but it would be better if this script ran earlier in the build
75 # sort the rpms so that both lists have the same order
76 # problem: a package can contain both noarch and arch subpackages, so we have to
77 # take care of proper sorting of NEWRPMS, e.g. noarch/x.rpm and x86_64/w.rpm since OLDRPMS
78 # has all the packages in a single directory and would sort this as w.rpm, x.rpm.
79 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'))
80 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'))
82 # Get version-release from first RPM and keep for rpmlint check
83 # Remember to quote the "." for future regexes
84 ver_rel1=$(rpm -qp --nodigest --nosignature --qf "%{VERSION}-%{RELEASE}" "${OLDRPMS[0]}"|sed -e 's/\./\\./g')
85 ver_rel2=$(rpm -qp --nodigest --nosignature --qf "%{VERSION}-%{RELEASE}" "${NEWRPMS[0]}"|sed -e 's/\./\\./g')
88 rpmqp='rpm -qp --qf %{NAME} --nodigest --nosignature '
89 for opac in ${OLDRPMS[*]}; do
91 NEWRPMS=(${NEWRPMS[@]:1}) # shift
92 echo compare "$opac" "$npac"
95 if test "$oname" != "$nname"; then
96 echo "names differ: $oname $nname"
101 echo "skipping -debuginfo package"
104 bash $CMPSCRIPT "$opac" "$npac" || SUCCESS=0
105 if test $SUCCESS -eq 0 -a -z "$check_all"; then
106 echo "differences between $opac and $npac"
113 if [ -n "${NEWRPMS[0]}" ]; then
114 echo additional new package
118 # Compare rpmlint.log files
119 if test -d /home/abuild/rpmbuild/OTHER; then
120 OTHERDIR=/home/abuild/rpmbuild/OTHER
121 elif test -d /usr/src/packages/OTHER; then
122 OTHERDIR=/usr/src/packages/OTHER
128 if test -n "$OTHERDIR"; then
129 if [ $prerelease -eq 1 ] ; then
130 echo "do not compare rpmlint.log if it is a prerelease project!"
132 if test -e $OLDDIR/rpmlint.log -a -e $OTHERDIR/rpmlint.log; then
135 echo "comparing $OLDDIR/rpmlint.log and $OTHERDIR/rpmlint.log"
136 # Sort the files first since the order of messages is not deterministic
137 # Remove release from files
138 sort -u $OLDDIR/rpmlint.log|sed -e "s,$ver_rel1,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file1
139 sort -u $OTHERDIR/rpmlint.log|sed -e "s,$ver_rel2,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file2
140 if ! cmp -s $file1 $file2; then
141 echo "rpmlint.log files differ:"
142 diff -u $file1 $file2 |head -n 20
146 elif test -e $OTHERDIR/rpmlint.log; then
147 echo "rpmlint.log is new"
152 appdatas=`cd $OTHERDIR && find . -name *-appdata.xml`
153 for xml in $appdatas; do
154 # compare appstream data
155 if test -e $OLDDIR/$xml -a -e $OTHERDIR/$xml; then
158 if ! cmp -s $file1 $file2; then
159 echo "$xml files differ:"
160 diff -u0 $file1 $file2 |head -n 20
163 elif test -e $OTHERDIR/$xml; then
170 if test $SUCCESS -eq 0; then
173 echo 'compare validated built as identical !'
175 # vim: tw=666 ts=2 shiftwidth=2 et