2009-02-04 04:29:06 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2012-01-10 14:19:57 +01:00
|
|
|
# Copyright (c) 2009, 2010, 2012 SUSE Linux Product GmbH, Germany.
|
2009-02-04 04:29:06 +01:00
|
|
|
# Licensed under GPL v2, see COPYING file for details.
|
|
|
|
#
|
|
|
|
# Written by Adrian Schroeter <adrian@suse.de>
|
2010-10-28 11:50:21 +02:00
|
|
|
# Enhanced by Andreas Jaeger <aj@suse.de>
|
2009-02-04 04:29:06 +01:00
|
|
|
#
|
|
|
|
# The script decides if the new build differes from the former one,
|
2015-02-12 12:10:09 +01:00
|
|
|
# using pkg-diff.sh.
|
2009-10-08 04:01:40 +02:00
|
|
|
# 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
|
2009-02-04 04:29:06 +01:00
|
|
|
|
2015-02-12 12:10:09 +01:00
|
|
|
CMPSCRIPT=${0%/*}/pkg-diff.sh
|
2010-09-21 13:12:14 +02:00
|
|
|
SCMPSCRIPT=${0%/*}/srpm-check.sh
|
2009-02-04 04:29:06 +01:00
|
|
|
|
2022-03-07 11:57:31 +01:00
|
|
|
declare -a exit_code
|
|
|
|
# exit_code[0]='' # binaries_differ
|
|
|
|
# exit_code[1]='' # rpmlint_differs
|
|
|
|
# exit_code[2]='' # appdata_differs
|
|
|
|
# exit_code[3]='' # srcrpm_differs
|
2016-03-07 12:58:30 +01:00
|
|
|
file1=`mktemp`
|
|
|
|
file2=`mktemp`
|
|
|
|
_x() {
|
|
|
|
rm -f ${file1} ${file2}
|
|
|
|
}
|
|
|
|
trap _x EXIT
|
|
|
|
#
|
2022-03-05 00:16:27 +01:00
|
|
|
remove_check_time_report() {
|
|
|
|
local f=$1
|
|
|
|
awk '
|
|
|
|
BEGIN {
|
|
|
|
ctr_seen=0;
|
|
|
|
}
|
|
|
|
/Check time report .*:$/ {
|
|
|
|
ctr_seen=1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
/TOTAL[[:blank:]]+[0-9]/ {
|
|
|
|
if (ctr_seen == 1) {
|
|
|
|
ctr_seen=0;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
if (ctr_seen == 1) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
print $0;
|
|
|
|
}
|
|
|
|
' < "${f}"
|
|
|
|
}
|
|
|
|
#
|
2016-03-08 13:48:20 +01:00
|
|
|
check_all=
|
2016-03-07 12:58:30 +01:00
|
|
|
if test "$1" = "-a"
|
|
|
|
then
|
|
|
|
check_all="-a"
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
#
|
2009-02-04 04:29:06 +01:00
|
|
|
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
|
|
|
|
|
2010-09-21 13:12:14 +02:00
|
|
|
if test `find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l` != `find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' | wc -l`; then
|
2009-02-06 15:22:35 +01:00
|
|
|
echo "different number of subpackages"
|
2016-03-07 12:58:30 +01:00
|
|
|
find $OLDDIR -name '*.rpm' -and ! -name '*.delta.rpm' -print0 | xargs -0 rpm -qp --qf '%{NAME}\n' | sort > ${file1}
|
|
|
|
find $NEWDIRS -name '*.rpm' -and ! -name '*.delta.rpm' -print0 | xargs -0 rpm -qp --qf '%{NAME}\n' | sort > ${file2}
|
|
|
|
diff -u ${file1} ${file2}
|
2009-02-06 15:22:35 +01:00
|
|
|
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"
|
2022-03-07 11:57:31 +01:00
|
|
|
if bash $SCMPSCRIPT "$osrpm" "$nsrpm"
|
|
|
|
then
|
|
|
|
: src.rpm identical
|
|
|
|
else
|
|
|
|
test -z "${check_all}" && exit 1
|
|
|
|
exit_code[3]='srcrpm_differs'
|
|
|
|
fi
|
2009-02-06 15:22:35 +01:00
|
|
|
|
2010-05-21 23:30:12 +02:00
|
|
|
# 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
|
2009-10-08 04:01:40 +02:00
|
|
|
# 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.
|
2016-03-08 12:55:22 +01:00
|
|
|
find $OLDDIR -type f -name '*.rpm' \
|
2016-03-07 12:58:30 +01:00
|
|
|
-a ! -name '*src.rpm' \
|
|
|
|
-a ! -name '*.delta.rpm' \
|
|
|
|
-a ! -name '*-32bit-*' \
|
|
|
|
-a ! -name '*-64bit-*' \
|
|
|
|
-a ! -name '*-x86-*.ia64.rpm' \
|
|
|
|
> ${file1}
|
2016-03-08 12:55:22 +01:00
|
|
|
find $NEWDIRS -type f -name '*.rpm' \
|
2016-03-07 12:58:30 +01:00
|
|
|
-a ! -name '*src.rpm' \
|
|
|
|
-a ! -name '*.delta.rpm' \
|
|
|
|
-a ! -name '*-32bit-*' \
|
|
|
|
-a ! -name '*-64bit-*' \
|
|
|
|
-a ! -name '*-x86-*.ia64.rpm' \
|
|
|
|
> ${file2}
|
|
|
|
OLDRPMS=($( sort --field-separator=/ --key=` sed -n '1s@[^/]@@gp' ${file1} | wc -c ` ${file1} ))
|
|
|
|
NEWRPMS=($( sort --field-separator=/ --key=` sed -n '1s@[^/]@@gp' ${file2} | wc -c ` ${file2} ))
|
2009-02-04 04:29:06 +01:00
|
|
|
|
2015-02-02 12:33:28 +01:00
|
|
|
# Get version-release from first RPM and keep for rpmlint check
|
2012-02-22 08:49:21 +01:00
|
|
|
# Remember to quote the "." for future regexes
|
2015-02-02 12:33:28 +01:00
|
|
|
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')
|
2012-01-26 19:52:20 +01:00
|
|
|
|
2009-02-07 15:39:47 +01:00
|
|
|
rpmqp='rpm -qp --qf %{NAME} --nodigest --nosignature '
|
2009-02-06 15:22:35 +01:00
|
|
|
for opac in ${OLDRPMS[*]}; do
|
2009-02-04 04:29:06 +01:00
|
|
|
npac=${NEWRPMS[0]}
|
|
|
|
NEWRPMS=(${NEWRPMS[@]:1}) # shift
|
|
|
|
echo compare "$opac" "$npac"
|
2009-02-06 15:22:35 +01:00
|
|
|
oname=`$rpmqp $opac`
|
|
|
|
nname=`$rpmqp $npac`
|
|
|
|
if test "$oname" != "$nname"; then
|
2015-04-13 10:56:50 +02:00
|
|
|
echo "names differ: $oname $nname"
|
|
|
|
exit 1
|
2009-02-06 15:22:35 +01:00
|
|
|
fi
|
2014-11-24 13:18:21 +01:00
|
|
|
case "$opac" in
|
|
|
|
*debuginfo*)
|
2015-04-13 10:56:50 +02:00
|
|
|
echo "skipping -debuginfo package"
|
2014-11-24 13:18:21 +01:00
|
|
|
;;
|
|
|
|
*)
|
2022-03-07 11:57:31 +01:00
|
|
|
bash $CMPSCRIPT $check_all "$opac" "$npac" || exit_code[0]='binaries_differ'
|
2014-11-24 13:18:21 +01:00
|
|
|
;;
|
|
|
|
esac
|
2009-02-04 04:29:06 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
if [ -n "${NEWRPMS[0]}" ]; then
|
|
|
|
echo additional new package
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-03-07 11:57:31 +01:00
|
|
|
OTHERDIR=
|
2012-01-10 14:19:57 +01:00
|
|
|
# Compare rpmlint.log files
|
2015-04-13 10:56:50 +02:00
|
|
|
if test -d /home/abuild/rpmbuild/OTHER; then
|
|
|
|
OTHERDIR=/home/abuild/rpmbuild/OTHER
|
2015-04-13 12:44:17 +02:00
|
|
|
elif test -d /usr/src/packages/OTHER; then
|
2015-04-13 10:56:50 +02:00
|
|
|
OTHERDIR=/usr/src/packages/OTHER
|
|
|
|
else
|
2022-03-07 11:57:31 +01:00
|
|
|
for newdir in $NEWDIRS
|
|
|
|
do
|
|
|
|
test -f "${newdir}/rpmlint.log" || continue
|
|
|
|
OTHERDIR="${newdir}"
|
|
|
|
break
|
|
|
|
done
|
|
|
|
test -n "$OTHERDIR" || echo "no OTHERDIR"
|
2012-02-16 15:18:23 +01:00
|
|
|
fi
|
|
|
|
|
2015-04-13 10:56:50 +02:00
|
|
|
if test -n "$OTHERDIR"; then
|
2022-03-05 00:16:27 +01:00
|
|
|
old_log=$OLDDIR/rpmlint.log
|
|
|
|
new_log=$OTHERDIR/rpmlint.log
|
|
|
|
if test -e ${old_log} && test -e ${new_log} ; then
|
|
|
|
echo "comparing ${old_log} and ${new_log}"
|
|
|
|
# Remove --time-report from rpmlint
|
2015-04-13 10:56:50 +02:00
|
|
|
# Sort the files first since the order of messages is not deterministic
|
|
|
|
# Remove release from files
|
2022-03-05 00:16:27 +01:00
|
|
|
remove_check_time_report ${old_log}|sort -u|sed -e "s,$ver_rel1,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file1
|
|
|
|
remove_check_time_report ${new_log}|sort -u|sed -e "s,$ver_rel2,@VERSION@-@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file2
|
2017-10-20 08:57:22 +02:00
|
|
|
# Remove odd warning about not-hardlinked files
|
2017-02-12 09:44:59 +01:00
|
|
|
# Remove odd warning about data and time, it comes and goes
|
2016-12-14 09:45:39 +01:00
|
|
|
# Remove warning about python mtime mismatch, a republish will not help
|
2015-10-22 08:42:20 +02:00
|
|
|
# Remove odd warning about filenames, they contain VERSION-RELEASE
|
|
|
|
# Remove durations from progress reports
|
2022-03-06 23:02:46 +01:00
|
|
|
# Remove odd output about number of checks and packages
|
2015-10-22 08:42:20 +02:00
|
|
|
sed -i -e "
|
2017-10-20 08:57:22 +02:00
|
|
|
/: W: files-duplicate /d
|
2017-02-12 09:44:59 +01:00
|
|
|
/: W: file-contains-date-and-time /d
|
2016-12-14 09:45:39 +01:00
|
|
|
/: W: python-bytecode-inconsistent-mtime /d
|
2015-10-22 08:42:20 +02:00
|
|
|
/: W: filename-too-long-for-joliet /d
|
|
|
|
/: I: \(filelist-initialization\|check-completed\) /s| [0-9]\+\.[0-9] s| x.x s|
|
2021-09-20 13:03:29 +02:00
|
|
|
s/; has taken [0-9]\+\.[0-9] s/; has taken x.x s/
|
2022-03-06 23:02:46 +01:00
|
|
|
/^checks: [0-9]\+, packages: [0-9]\+/d
|
2015-10-22 08:42:20 +02:00
|
|
|
" $file1 $file2
|
2012-02-22 12:12:05 +01:00
|
|
|
if ! cmp -s $file1 $file2; then
|
2015-04-13 10:56:50 +02:00
|
|
|
echo "rpmlint.log files differ:"
|
|
|
|
diff -u $file1 $file2 |head -n 20
|
2022-03-07 11:57:31 +01:00
|
|
|
exit_code[1]='rpmlint_differs'
|
2012-02-22 12:12:05 +01:00
|
|
|
fi
|
2015-04-13 10:56:50 +02:00
|
|
|
rm $file1 $file2
|
2022-03-07 11:57:31 +01:00
|
|
|
else
|
|
|
|
if test -e "${new_log}"
|
|
|
|
then
|
|
|
|
exit_code[1]='rpmlint_new'
|
|
|
|
echo "rpmlint.log is new"
|
|
|
|
elif test -e "${old_log}"
|
|
|
|
then
|
|
|
|
exit_code[1]='rpmlint_old'
|
|
|
|
echo "rpmlint.log disappeared"
|
|
|
|
else
|
|
|
|
echo "No rpmlint.log available"
|
|
|
|
fi
|
2012-02-16 15:18:23 +01:00
|
|
|
fi
|
2015-04-13 10:56:50 +02:00
|
|
|
|
2016-01-04 10:41:00 +01:00
|
|
|
appdatas=$(cd $OTHERDIR && find . -name "*-appdata.xml")
|
2015-04-13 10:56:50 +02:00
|
|
|
for xml in $appdatas; do
|
|
|
|
# compare appstream data
|
2022-03-07 11:57:31 +01:00
|
|
|
if test -e $OLDDIR/$xml && test -e $OTHERDIR/$xml; then
|
2015-04-13 10:56:50 +02:00
|
|
|
file1=$OLDDIR/$xml
|
|
|
|
file2=$OTHERDIR/$xml
|
|
|
|
if ! cmp -s $file1 $file2; then
|
|
|
|
echo "$xml files differ:"
|
|
|
|
diff -u0 $file1 $file2 |head -n 20
|
2022-03-07 11:57:31 +01:00
|
|
|
exit_code[2]='appdata_differs'
|
2015-04-13 10:56:50 +02:00
|
|
|
fi
|
|
|
|
elif test -e $OTHERDIR/$xml; then
|
|
|
|
echo "$xml is new"
|
2022-03-07 11:57:31 +01:00
|
|
|
exit_code[2]='appdata_new'
|
2015-04-13 10:56:50 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2022-03-07 11:57:31 +01:00
|
|
|
if test -n "${exit_code[*]}"; then
|
2010-10-28 11:50:21 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2019-02-19 10:32:50 +01:00
|
|
|
echo 'compare validated build as identical !'
|
2009-02-04 04:29:06 +01:00
|
|
|
exit 0
|
2015-03-20 20:33:05 +01:00
|
|
|
# vim: tw=666 ts=2 shiftwidth=2 et
|