Accepting request 263196 from openSUSE:Tools

1

OBS-URL: https://build.opensuse.org/request/show/263196
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/build-compare?expand=0&rev=83
This commit is contained in:
Dominique Leuenberger 2014-12-01 13:00:26 +00:00 committed by Git OBS Bridge
commit 8da37c64e1
6 changed files with 199 additions and 41 deletions

View File

@ -1,3 +1,21 @@
-------------------------------------------------------------------
Wed Nov 26 08:58:45 UTC 2014 - ohering@suse.de
- 2014.11.25
- correctly handle cmp_spec return code if file checksum differs
- handle also bz2 and xz compressed files with odd name
-------------------------------------------------------------------
Tue Nov 18 11:58:51 UTC 2014 - ohering@suse.de
- 2014.11.15
- show sorted differences of rpmlint log (bnc#904092)
- handle kernel and kmp packages, but support for kernel* is disabled
- minor style fixes
- handle cpio archives
- handle absolute symlinks correctly
- handle all ELF sections, not only the ones starting with dot
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Nov 12 09:29:24 UTC 2014 - schwab@suse.de Wed Nov 12 09:29:24 UTC 2014 - schwab@suse.de

View File

@ -20,7 +20,7 @@ Name: build-compare
Summary: Build Result Compare Script Summary: Build Result Compare Script
License: GPL-2.0+ License: GPL-2.0+
Group: Development/Tools/Building Group: Development/Tools/Building
Version: 2014.07.15 Version: 2014.11.25
Release: 0 Release: 0
Source1: COPYING Source1: COPYING
Source2: same-build-result.sh Source2: same-build-result.sh
@ -36,8 +36,7 @@ to a former build.
%prep %prep
mkdir $RPM_BUILD_DIR/%name-%version %setup -q -c -T
%setup -T 0 -D
%build %build

View File

@ -15,16 +15,38 @@ check_header()
$RPM --qf "$QF" "$1" $RPM --qf "$QF" "$1"
} }
# Trim release string:
# - it is used as direntry below certain paths
# - it is assigned to some variable in scripts, at the end of a line
# - it is used in PROVIDES, at the end of a line
function trim_release_old()
{
sed -e "/\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$release_old\$\)/{s,-$release_old_regex_l,-@RELEASE_LONG@,g;s,-$release_old_regex_s,-@RELEASE_SHORT@,g}"
}
function trim_release_new()
{
sed -e "/\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$release_new\$\)/{s,-$release_new_regex_l,-@RELEASE_LONG@,g;s,-$release_new_regex_s,-@RELEASE_SHORT@,g}"
}
# Get single directory or filename with long or short release string
function grep_release_old()
{
grep -E "(/boot|/lib/modules|/lib/firmware|/usr/src)/[^/]+(-${release_old_regex_l}(\$|[^/]+\$)|-${release_old_regex_s}(\$|[^/]+\$))"
}
function grep_release_new()
{
grep -E "(/boot|/lib/modules|/lib/firmware|/usr/src)/[^/]+(-${release_new_regex_l}(\$|[^/]+\$)|-${release_new_regex_s}(\$|[^/]+\$))"
}
function check_provides() function check_provides()
{ {
local pkg=$1
# provides destroy this because at least the self-provide includes the # provides destroy this because at least the self-provide includes the
# -buildnumber :-( # -buildnumber :-(
QF="[%{PROVIDENAME} %{PROVIDEFLAGS} %{PROVIDEVERSION}\\n]\\n" QF="[%{PROVIDENAME} %{PROVIDEFLAGS} %{PROVIDEVERSION}\\n]\\n"
QF="$QF [%{REQUIRENAME} %{REQUIREFLAGS} %{REQUIREVERSION}\\n]\\n" QF="$QF [%{REQUIRENAME} %{REQUIREFLAGS} %{REQUIREVERSION}\\n]\\n"
QF="$QF [%{CONFLICTNAME} %{CONFLICTFLAGS} %{CONFLICTVERSION}\\n]\\n" QF="$QF [%{CONFLICTNAME} %{CONFLICTFLAGS} %{CONFLICTVERSION}\\n]\\n"
QF="$QF [%{OBSOLETENAME} %{OBSOLETEFLAGS} %{OBSOLETEVERSION}\\n]\\n" QF="$QF [%{OBSOLETENAME} %{OBSOLETEFLAGS} %{OBSOLETEVERSION}\\n]\\n"
check_header "$1" | sed -e "s,-$2$,-@RELEASE@," check_header "$pkg"
} }
#usage unrpm <file> $dir #usage unrpm <file> $dir
@ -51,6 +73,11 @@ function unrpm()
# Sets $files with list of files that need further investigation # Sets $files with list of files that need further investigation
function cmp_spec () function cmp_spec ()
{ {
local RES
local file1 file2
local f
local sh=$1
QF="%{NAME}" QF="%{NAME}"
# don't look at RELEASE, it contains our build number # don't look at RELEASE, it contains our build number
@ -81,6 +108,7 @@ function cmp_spec ()
# the DISTURL tag can be used as checkin ID # the DISTURL tag can be used as checkin ID
#echo "$QF" #echo "$QF"
echo "comparing rpmtags"
if ! diff -au $file1 $file2; then if ! diff -au $file1 $file2; then
if test -z "$check_all"; then if test -z "$check_all"; then
rm $file1 $file2 rm $file1 $file2
@ -89,19 +117,36 @@ function cmp_spec ()
fi fi
# Remember to quote the . which is in release # Remember to quote the . which is in release
release1=$($RPM --qf "%{RELEASE}" "$oldrpm"|sed -e 's/\./\\./g') release_old=$($RPM --qf "%{RELEASE}" "$oldrpm")
release2=$($RPM --qf "%{RELEASE}" "$newrpm"|sed -e 's/\./\\./g') release_new=$($RPM --qf "%{RELEASE}" "$newrpm")
# This might happen with a forced rebuild of factory # Short version without B_CNT
if [ "${release1%.*}" != "${release2%.*}" ] ; then release_old_regex_s=${release_old%.*}
echo "release prefix mismatch" release_old_regex_s=${release_old_regex_s//./\\.}
if test -z "$check_all"; then release_new_regex_s=${release_new%.*}
return 1 release_new_regex_s=${release_new_regex_s//./\\.}
fi # Long version with B_CNT
release_old_regex_l=${release_old//./\\.}
release_new_regex_l=${release_new//./\\.}
# This might happen when?!
echo "comparing RELEASE"
if [ "${release_old%.*}" != "${release_new%.*}" ] ; then
case $($RPM --qf '%{NAME}' "$newrpm") in
kernel-*)
# Make sure all kernel packages have the same %RELEASE
echo "release prefix mismatch"
if test -z "$check_all"; then
return 1
fi
;;
# Every other package is allowed to have a different RELEASE
*) ;;
esac
fi fi
check_provides $oldrpm $release1 > $file1 check_provides $oldrpm | trim_release_old | sort > $file1
check_provides $newrpm $release2 > $file2 check_provides $newrpm | trim_release_new | sort > $file2
echo "comparing PROVIDES"
if ! diff -au $file1 $file2; then if ! diff -au $file1 $file2; then
if test -z "$check_all"; then if test -z "$check_all"; then
rm $file1 $file2 rm $file1 $file2
@ -111,9 +156,10 @@ function cmp_spec ()
# scripts, might contain release number # scripts, might contain release number
QF="[%{PREINPROG} %{PREIN}\\n]\\n[%{POSTINPROG} %{POSTIN}\\n]\\n[%{PREUNPROG} %{PREUN}\\n]\\n[%{POSTUNPROG} %{POSTUN}\\n]\\n" QF="[%{PREINPROG} %{PREIN}\\n]\\n[%{POSTINPROG} %{POSTIN}\\n]\\n[%{PREUNPROG} %{PREUN}\\n]\\n[%{POSTUNPROG} %{POSTUN}\\n]\\n"
check_header $oldrpm | sed -e "s,-$release1$,-@RELEASE@," > $file1 check_header $oldrpm | trim_release_old > $file1
check_header $newrpm | sed -e "s,-$release2$,-@RELEASE@," > $file2 check_header $newrpm | trim_release_new > $file2
echo "comparing scripts"
if ! diff -au $file1 $file2; then if ! diff -au $file1 $file2; then
if test -z "$check_all"; then if test -z "$check_all"; then
rm $file1 $file2 rm $file1 $file2
@ -134,9 +180,10 @@ function cmp_spec ()
QF="[%{FILENAMES} %{FILEFLAGS} %{FILESTATES} %{FILEMODES:octal} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILERDEVS} %{FILEVERIFYFLAGS} %{FILELINKTOS}\n]\\n" QF="[%{FILENAMES} %{FILEFLAGS} %{FILESTATES} %{FILEMODES:octal} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILERDEVS} %{FILEVERIFYFLAGS} %{FILELINKTOS}\n]\\n"
# ??? what to do with FILEPROVIDE and FILEREQUIRE? # ??? what to do with FILEPROVIDE and FILEREQUIRE?
check_header $oldrpm | sed -e "s,-$release1,-@RELEASE@," > $file1 check_header $oldrpm | trim_release_old > $file1
check_header $newrpm | sed -e "s,-$release2,-@RELEASE@," > $file2 check_header $newrpm | trim_release_new > $file2
echo "comparing filelist"
if ! diff -au $file1 $file2; then if ! diff -au $file1 $file2; then
if test -z "$check_all"; then if test -z "$check_all"; then
rm $file1 $file2 rm $file1 $file2
@ -148,11 +195,12 @@ function cmp_spec ()
# if there are different filenames, we will already have aborted before # if there are different filenames, we will already have aborted before
# file flag 64 means "ghost", filter those out. # file flag 64 means "ghost", filter those out.
QF="[%{FILENAMES} %{FILEMD5S} %{FILEFLAGS}\n]\\n" QF="[%{FILENAMES} %{FILEMD5S} %{FILEFLAGS}\n]\\n"
check_header $oldrpm |grep -v " 64$"> $file1 check_header $oldrpm |grep -v " 64$"| trim_release_old > $file1
check_header $newrpm |grep -v " 64$"> $file2 check_header $newrpm |grep -v " 64$"| trim_release_new > $file2
RES=2 RES=2
# done if the same # done if the same
echo "comparing file checksum"
if cmp -s $file1 $file2; then if cmp -s $file1 $file2; then
RES=0 RES=0
fi fi
@ -160,6 +208,20 @@ function cmp_spec ()
# Get only files with different MD5sums # Get only files with different MD5sums
files=`diff -U0 $file1 $file2 | fgrep -v +++ | grep ^+ | cut -b2- | awk '{print $1}'` files=`diff -U0 $file1 $file2 | fgrep -v +++ | grep ^+ | cut -b2- | awk '{print $1}'`
if test -f "$sh"; then
echo "creating rename script"
# Create a temporary helper script to rename files/dirs with release in it
for f in `$RPM --qf '[%{FILENAMES} %{FILEFLAGS}\n]\n' "$oldrpm" | grep_release_old | grep -vw 64$ | awk '{ print $1}'`
do
echo mv -v \"old/${f}\" \"old/`echo ${f} | trim_release_old`\"
done >> "${sh}"
#
for f in `$RPM --qf '[%{FILENAMES} %{FILEFLAGS}\n]\n' "$newrpm" | grep_release_new | grep -vw 64$ | awk '{ print $1}'`
do
echo mv -v \"new/${f}\" \"new/`echo ${f} | trim_release_new`\"
done >> "${sh}"
fi
#
rm $file1 $file2 rm $file1 $file2
return $RES return $RES
} }

View File

@ -24,6 +24,7 @@ source $FUNCTIONS
oldrpm=`readlink -f $1` oldrpm=`readlink -f $1`
newrpm=`readlink -f $2` newrpm=`readlink -f $2`
rename_script=`mktemp`
if test ! -f $oldrpm; then if test ! -f $oldrpm; then
echo "can't open $oldrpm" echo "can't open $oldrpm"
@ -96,11 +97,14 @@ filter_disasm()
sed -e 's/^ *[0-9a-f]\+://' -e 's/\$0x[0-9a-f]\+/$something/' -e 's/callq *[0-9a-f]\+/callq /' -e 's/# *[0-9a-f]\+/# /' -e 's/\(0x\)\?[0-9a-f]\+(/offset(/' -e 's/[0-9a-f]\+ </</' -e 's/^<\(.*\)>:/\1:/' -e 's/<\(.*\)+0x[0-9a-f]\+>/<\1 + ofs>/' sed -e 's/^ *[0-9a-f]\+://' -e 's/\$0x[0-9a-f]\+/$something/' -e 's/callq *[0-9a-f]\+/callq /' -e 's/# *[0-9a-f]\+/# /' -e 's/\(0x\)\?[0-9a-f]\+(/offset(/' -e 's/[0-9a-f]\+ </</' -e 's/^<\(.*\)>:/\1:/' -e 's/<\(.*\)+0x[0-9a-f]\+>/<\1 + ofs>/'
} }
cmp_spec $1 $2 cmp_spec $rename_script
RES=$? RES=$?
case $RES in case $RES in
0) 0)
exit 0 echo "RPM meta information is identical"
if test -z "$check_all"; then
exit 0
fi
;; ;;
1) 1)
echo "RPM meta information is different" echo "RPM meta information is different"
@ -109,6 +113,8 @@ case $RES in
fi fi
;; ;;
2) 2)
echo "RPM file checksum differs."
RES=0
;; ;;
*) *)
echo "Wrong exit code!" echo "Wrong exit code!"
@ -120,9 +126,11 @@ file1=`mktemp`
file2=`mktemp` file2=`mktemp`
dir=`mktemp -d` dir=`mktemp -d`
echo "Extracting packages"
unrpm $oldrpm $dir/old unrpm $oldrpm $dir/old
unrpm $newrpm $dir/new unrpm $newrpm $dir/new
cd $dir cd $dir
bash $rename_script
dfile=`mktemp` dfile=`mktemp`
@ -152,33 +160,59 @@ strip_numbered_anchors()
} }
check_gzip_file() check_compressed_file()
{ {
local file=$1 local file=$1
local ext=$2
local tmpdir=`mktemp -d` local tmpdir=`mktemp -d`
local ftype local ftype
local ret=0 local ret=0
echo "$ext file with odd filename: $file"
if test -n "$tmpdir"; then if test -n "$tmpdir"; then
mkdir $tmpdir/{old,new} mkdir $tmpdir/{old,new}
cp --parents --dereference old/$file $tmpdir/ cp --parents --dereference old/$file $tmpdir/
cp --parents --dereference new/$file $tmpdir/ cp --parents --dereference new/$file $tmpdir/
if pushd $tmpdir > /dev/null ; then if pushd $tmpdir > /dev/null ; then
mv old/$file{,.gz} case "$ext" in
mv new/$file{,.gz} bz2)
gunzip old/$file.gz mv old/$file{,.bz2}
gunzip new/$file.gz mv new/$file{,.bz2}
bzip2 -d old/$file.bz2
bzip2 -d new/$file.bz2
;;
gzip)
mv old/$file{,.gz}
mv new/$file{,.gz}
gzip -d old/$file.gz
gzip -d new/$file.gz
;;
xz)
mv old/$file{,.xz}
mv new/$file{,.xz}
xz -d old/$file.xz
xz -d new/$file.xz
;;
esac
ftype=`/usr/bin/file old/$file | cut -d: -f2-` ftype=`/usr/bin/file old/$file | cut -d: -f2-`
case $ftype in case $ftype in
*POSIX\ tar\ archive) *POSIX\ tar\ archive)
echo "gzip content is: $ftype" echo "$ext content is: $ftype"
mv old/$file{,.tar} mv old/$file{,.tar}
mv new/$file{,.tar} mv new/$file{,.tar}
if ! check_single_file ${file}.tar; then if ! check_single_file ${file}.tar; then
ret=1 ret=1
fi fi
;; ;;
*ASCII\ cpio\ archive\ *)
echo "$ext content is: $ftype"
mv old/$file{,.cpio}
mv new/$file{,.cpio}
if ! check_single_file ${file}.cpio; then
ret=1
fi
;;
*) *)
echo "unhandled gzip content: $ftype" echo "unhandled $ext content: $ftype"
if ! diff_two_files; then if ! diff_two_files; then
ret=1 ret=1
fi fi
@ -220,6 +254,26 @@ check_single_file()
done done
return 0 return 0
;; ;;
*.cpio)
flist=`cpio --quiet --list --force-local < "new/$file"`
pwd=$PWD
fdir=`dirname $file`
cd old/$fdir
cpio --quiet --extract --force-local < "${file##*/}"
cd $pwd/new/$fdir
cpio --quiet --extract --force-local < "${file##*/}"
cd $pwd
local ret=0
for f in $flist; do
if ! check_single_file $fdir/$f; then
ret=1
if test -z "$check_all"; then
break
fi
fi
done
return $ret
;;
*.tar|*.tar.bz2|*.tar.gz|*.tgz|*.tbz2) *.tar|*.tar.bz2|*.tar.gz|*.tgz|*.tbz2)
flist=`tar tf new/$file` flist=`tar tf new/$file`
pwd=$PWD pwd=$PWD
@ -530,7 +584,8 @@ check_single_file()
echo "" >$file1 echo "" >$file1
echo "" >$file2 echo "" >$file2
# Don't compare .build-id and .gnu_debuglink sections # Don't compare .build-id and .gnu_debuglink sections
for section in $(objdump -s new/$file | grep "Contents of section .*:" | sed -r "s,.* (\..*):,\1,g" | grep -v -e "\.build-id" -e "\.gnu_debuglink" | tr "\n" " "); do sections="$(objdump -s new/$file | grep "Contents of section .*:" | sed -r "s,.* (.*):,\1,g" | grep -v -e "\.build-id" -e "\.gnu_debuglink" | tr "\n" " ")"
for section in $sections; do
objdump -s -j $section old/$file | sed "s,old/,," >> $file1 objdump -s -j $section old/$file | sed "s,old/,," >> $file1
objdump -s -j $section new/$file | sed "s,new/,," >> $file2 objdump -s -j $section new/$file | sed "s,new/,," >> $file2
done done
@ -554,12 +609,29 @@ check_single_file()
# tar might package directories - ignore them here # tar might package directories - ignore them here
return 0 return 0
;; ;;
*gzip\ compressed\ data*) *bzip2\ compressed\ data*)
echo "gzipped file with odd filename: $file" if ! check_compressed_file "$file" "bz2"; then
if ! check_gzip_file "$file"; then
return 1 return 1
fi fi
;; ;;
*gzip\ compressed\ data*)
if ! check_compressed_file "$file" "gzip"; then
return 1
fi
;;
*XZ\ compressed\ data*)
if ! check_compressed_file "$file" "xz"; then
return 1
fi
;;
*symbolic\ link\ to\ *)
readlink "old/$file" > $file1
readlink "new/$file" > $file2
if ! diff -u $file1 $file2; then
echo "symlink target for $file differs"
return 1
fi
;;
*) *)
if ! diff_two_files; then if ! diff_two_files; then
return 1 return 1
@ -578,7 +650,8 @@ if [ ! -d /proc/self/ ]; then
PROC_MOUNTED=1 PROC_MOUNTED=1
fi fi
ret=0 # preserve cmp_spec result for check_all runs
ret=$RES
for file in $files; do for file in $files; do
if ! check_single_file $file; then if ! check_single_file $file; then
ret=1 ret=1
@ -593,6 +666,9 @@ if [ "$PROC_MOUNTED" -eq "1" ]; then
umount /proc umount /proc
fi fi
rm $file1 $file2 $dfile rm $file1 $file2 $dfile $rename_script
rm -r $dir rm -r $dir
if test "$ret" = 0; then
echo "RPM content is identical"
fi
exit $ret exit $ret

View File

@ -79,14 +79,17 @@ for opac in ${OLDRPMS[*]}; do
echo "names differ: $oname $nname" echo "names differ: $oname $nname"
exit 1 exit 1
fi fi
if [ $(echo "$opac" | grep -e "debuginfo") ]; then case "$opac" in
*debuginfo*)
echo "skipping -debuginfo package" echo "skipping -debuginfo package"
else ;;
*)
bash $CMPSCRIPT "$opac" "$npac" || SUCCESS=0 bash $CMPSCRIPT "$opac" "$npac" || SUCCESS=0
if test $SUCCESS -eq 0 -a -z "$check_all"; then if test $SUCCESS -eq 0 -a -z "$check_all"; then
exit 1 exit 1
fi fi
fi ;;
esac
done done
if [ -n "${NEWRPMS[0]}" ]; then if [ -n "${NEWRPMS[0]}" ]; then
@ -107,7 +110,7 @@ if test -e $OLDDIR/rpmlint.log -a -e $OTHERDIR/rpmlint.log; then
sort -u $OTHERDIR/rpmlint.log|sed -e "s,$release2,@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file2 sort -u $OTHERDIR/rpmlint.log|sed -e "s,$release2,@RELEASE@,g" -e "s|/tmp/rpmlint\..*spec|.spec|g" > $file2
if ! cmp -s $file1 $file2; then if ! cmp -s $file1 $file2; then
echo "rpmlint.log files differ:" echo "rpmlint.log files differ:"
diff -u $OLDDIR/rpmlint.log $OTHERDIR/rpmlint.log |head -n 20 diff -u $file1 $file2 |head -n 20
SUCCESS=0 SUCCESS=0
fi fi
rm $file1 $file2 rm $file1 $file2

View File

@ -32,7 +32,7 @@ newrpm=`readlink -f $2`
# if those are not the same, the source RPM has changed and therefore # if those are not the same, the source RPM has changed and therefore
# the resulting files are needed. # the resulting files are needed.
cmp_spec $1 $2 cmp_spec
RES=$? RES=$?
case $RES in case $RES in
0) 0)