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
16 FUNCTIONS=${0%/*}/functions.sh
25 if [ ! -d "$OLDDIR" ]; then
26 echo "No valid directory with old build result given !"
29 if [ -z "$NEWDIRS" ]; then
30 echo "No valid directory with new build result given !"
36 first_rpm=$(find $NEWDIRS -name *.rpm | head -1)
37 dist=$(rpm -qp --nodigest --nosignature --qf "%{DISTRIBUTION}" $first_rpm | sed -r 's/(.*)\/.*/\1/')
39 if ! is_prerelease_project $dist; then
40 echo "This is a prerelease project. Do not check the existence of source rpm files."
43 num_new_pkgs=`find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' -and ! -name '*.src.rpm' | wc -l`
44 num_old_pkgs=`find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' -and ! -name '*.src.rpm' | wc -l`
45 if test $num_new_pkgs != $num_old_pkgs; then
46 echo "different number of subpackages"
47 find $OLDDIR $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' -and ! -name '*.src.rpm'
52 if test `find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l` != `find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l`; then
53 echo "different number of subpackages"
54 find $OLDDIR $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm'
58 osrpm=$(find "$OLDDIR" -name \*src.rpm)
59 nsrpm=$(find $NEWDIRS -name \*src.rpm)
61 if test ! -f "$osrpm"; then
62 echo no old source rpm in $OLDDIR
66 if test ! -f "$nsrpm"; then
67 echo no new source rpm in $NEWDIRS
71 echo "compare $osrpm $nsrpm"
72 bash $SCMPSCRIPT "$osrpm" "$nsrpm" || exit 1
75 # technically we should not all exclude all -32bit but filter for different archs,
77 # but it would be better if this script ran earlier in the build
78 # sort the rpms so that both lists have the same order
79 # problem: a package can contain both noarch and arch subpackages, so we have to
80 # take care of proper sorting of NEWRPMS, e.g. noarch/x.rpm and x86_64/w.rpm since OLDRPMS
81 # has all the packages in a single directory and would sort this as w.rpm, x.rpm.
82 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'))
83 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'))
85 # Get version-release from first RPM and keep for rpmlint check
86 # Remember to quote the "." for future regexes
87 ver_rel1=$(rpm -qp --nodigest --nosignature --qf "%{VERSION}-%{RELEASE}" "${OLDRPMS[0]}"|sed -e 's/\./\\./g')
88 ver_rel2=$(rpm -qp --nodigest --nosignature --qf "%{VERSION}-%{RELEASE}" "${NEWRPMS[0]}"|sed -e 's/\./\\./g')
91 rpmqp='rpm -qp --qf %{NAME} --nodigest --nosignature '
92 for opac in ${OLDRPMS[*]}; do
94 NEWRPMS=(${NEWRPMS[@]:1}) # shift
95 echo compare "$opac" "$npac"
98 if test "$oname" != "$nname"; then
99 echo "names differ: $oname $nname"
104 echo "skipping -debuginfo package"
107 bash $CMPSCRIPT "$opac" "$npac" || SUCCESS=0
108 if test $SUCCESS -eq 0 -a -z "$check_all"; then
109 echo "differences between $opac and $npac"
116 if [ -n "${NEWRPMS[0]}" ]; then
117 echo additional new package
121 # Compare rpmlint.log files
122 if test -d /home/abuild/rpmbuild/OTHER; then
123 OTHERDIR=/home/abuild/rpmbuild/OTHER
124 elif test -d /usr/src/packages/OTHER; then
125 OTHERDIR=/usr/src/packages/OTHER
131 if test -n "$OTHERDIR"; then
132 if [ $prerelease -eq 1 ] ; then
133 echo "do not compare rpmlint.log if it is a prerelease project!"
135 if test -e $OLDDIR/rpmlint.log -a -e $OTHERDIR/rpmlint.log; then
138 echo "comparing $OLDDIR/rpmlint.log and $OTHERDIR/rpmlint.log"
139 # Sort the files first since the order of messages is not deterministic
140 # Remove release from files
141 sort -u $OLDDIR/rpmlint.log|sed -e "s,$ver_rel1,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file1
142 sort -u $OTHERDIR/rpmlint.log|sed -e "s,$ver_rel2,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file2
143 if ! cmp -s $file1 $file2; then
144 echo "rpmlint.log files differ:"
145 diff -u $file1 $file2 |head -n 20
149 elif test -e $OTHERDIR/rpmlint.log; then
150 echo "rpmlint.log is new"
155 appdatas=`cd $OTHERDIR && find . -name *-appdata.xml`
156 for xml in $appdatas; do
157 # compare appstream data
158 if test -e $OLDDIR/$xml -a -e $OTHERDIR/$xml; then
161 if ! cmp -s $file1 $file2; then
162 echo "$xml files differ:"
163 diff -u0 $file1 $file2 |head -n 20
166 elif test -e $OTHERDIR/$xml; then
173 if test $SUCCESS -eq 0; then
176 echo 'compare validated built as identical !'
178 # vim: tw=666 ts=2 shiftwidth=2 et