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

View File

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

View File

@ -15,16 +15,38 @@ check_header()
$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()
{
local pkg=$1
# provides destroy this because at least the self-provide includes the
# -buildnumber :-(
QF="[%{PROVIDENAME} %{PROVIDEFLAGS} %{PROVIDEVERSION}\\n]\\n"
QF="$QF [%{REQUIRENAME} %{REQUIREFLAGS} %{REQUIREVERSION}\\n]\\n"
QF="$QF [%{CONFLICTNAME} %{CONFLICTFLAGS} %{CONFLICTVERSION}\\n]\\n"
QF="$QF [%{OBSOLETENAME} %{OBSOLETEFLAGS} %{OBSOLETEVERSION}\\n]\\n"
check_header "$1" | sed -e "s,-$2$,-@RELEASE@,"
check_header "$pkg"
}
#usage unrpm <file> $dir
@ -51,6 +73,11 @@ function unrpm()
# Sets $files with list of files that need further investigation
function cmp_spec ()
{
local RES
local file1 file2
local f
local sh=$1
QF="%{NAME}"
# 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
#echo "$QF"
echo "comparing rpmtags"
if ! diff -au $file1 $file2; then
if test -z "$check_all"; then
rm $file1 $file2
@ -89,19 +117,36 @@ function cmp_spec ()
fi
# Remember to quote the . which is in release
release1=$($RPM --qf "%{RELEASE}" "$oldrpm"|sed -e 's/\./\\./g')
release2=$($RPM --qf "%{RELEASE}" "$newrpm"|sed -e 's/\./\\./g')
# This might happen with a forced rebuild of factory
if [ "${release1%.*}" != "${release2%.*}" ] ; then
echo "release prefix mismatch"
if test -z "$check_all"; then
return 1
fi
release_old=$($RPM --qf "%{RELEASE}" "$oldrpm")
release_new=$($RPM --qf "%{RELEASE}" "$newrpm")
# Short version without B_CNT
release_old_regex_s=${release_old%.*}
release_old_regex_s=${release_old_regex_s//./\\.}
release_new_regex_s=${release_new%.*}
release_new_regex_s=${release_new_regex_s//./\\.}
# 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
check_provides $oldrpm $release1 > $file1
check_provides $newrpm $release2 > $file2
check_provides $oldrpm | trim_release_old | sort > $file1
check_provides $newrpm | trim_release_new | sort > $file2
echo "comparing PROVIDES"
if ! diff -au $file1 $file2; then
if test -z "$check_all"; then
rm $file1 $file2
@ -111,9 +156,10 @@ function cmp_spec ()
# scripts, might contain release number
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 $newrpm | sed -e "s,-$release2$,-@RELEASE@," > $file2
check_header $oldrpm | trim_release_old > $file1
check_header $newrpm | trim_release_new > $file2
echo "comparing scripts"
if ! diff -au $file1 $file2; then
if test -z "$check_all"; then
rm $file1 $file2
@ -134,9 +180,10 @@ function cmp_spec ()
QF="[%{FILENAMES} %{FILEFLAGS} %{FILESTATES} %{FILEMODES:octal} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILERDEVS} %{FILEVERIFYFLAGS} %{FILELINKTOS}\n]\\n"
# ??? what to do with FILEPROVIDE and FILEREQUIRE?
check_header $oldrpm | sed -e "s,-$release1,-@RELEASE@," > $file1
check_header $newrpm | sed -e "s,-$release2,-@RELEASE@," > $file2
check_header $oldrpm | trim_release_old > $file1
check_header $newrpm | trim_release_new > $file2
echo "comparing filelist"
if ! diff -au $file1 $file2; then
if test -z "$check_all"; then
rm $file1 $file2
@ -148,11 +195,12 @@ function cmp_spec ()
# if there are different filenames, we will already have aborted before
# file flag 64 means "ghost", filter those out.
QF="[%{FILENAMES} %{FILEMD5S} %{FILEFLAGS}\n]\\n"
check_header $oldrpm |grep -v " 64$"> $file1
check_header $newrpm |grep -v " 64$"> $file2
check_header $oldrpm |grep -v " 64$"| trim_release_old > $file1
check_header $newrpm |grep -v " 64$"| trim_release_new > $file2
RES=2
# done if the same
echo "comparing file checksum"
if cmp -s $file1 $file2; then
RES=0
fi
@ -160,6 +208,20 @@ function cmp_spec ()
# Get only files with different MD5sums
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
return $RES
}

View File

@ -24,6 +24,7 @@ source $FUNCTIONS
oldrpm=`readlink -f $1`
newrpm=`readlink -f $2`
rename_script=`mktemp`
if test ! -f $oldrpm; then
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>/'
}
cmp_spec $1 $2
cmp_spec $rename_script
RES=$?
case $RES in
0)
exit 0
echo "RPM meta information is identical"
if test -z "$check_all"; then
exit 0
fi
;;
1)
echo "RPM meta information is different"
@ -109,6 +113,8 @@ case $RES in
fi
;;
2)
echo "RPM file checksum differs."
RES=0
;;
*)
echo "Wrong exit code!"
@ -120,9 +126,11 @@ file1=`mktemp`
file2=`mktemp`
dir=`mktemp -d`
echo "Extracting packages"
unrpm $oldrpm $dir/old
unrpm $newrpm $dir/new
cd $dir
bash $rename_script
dfile=`mktemp`
@ -152,33 +160,59 @@ strip_numbered_anchors()
}
check_gzip_file()
check_compressed_file()
{
local file=$1
local ext=$2
local tmpdir=`mktemp -d`
local ftype
local ret=0
echo "$ext file with odd filename: $file"
if test -n "$tmpdir"; then
mkdir $tmpdir/{old,new}
cp --parents --dereference old/$file $tmpdir/
cp --parents --dereference new/$file $tmpdir/
if pushd $tmpdir > /dev/null ; then
mv old/$file{,.gz}
mv new/$file{,.gz}
gunzip old/$file.gz
gunzip new/$file.gz
case "$ext" in
bz2)
mv old/$file{,.bz2}
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-`
case $ftype in
*POSIX\ tar\ archive)
echo "gzip content is: $ftype"
echo "$ext content is: $ftype"
mv old/$file{,.tar}
mv new/$file{,.tar}
if ! check_single_file ${file}.tar; then
ret=1
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
ret=1
fi
@ -220,6 +254,26 @@ check_single_file()
done
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)
flist=`tar tf new/$file`
pwd=$PWD
@ -530,7 +584,8 @@ check_single_file()
echo "" >$file1
echo "" >$file2
# 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 new/$file | sed "s,new/,," >> $file2
done
@ -554,12 +609,29 @@ check_single_file()
# tar might package directories - ignore them here
return 0
;;
*gzip\ compressed\ data*)
echo "gzipped file with odd filename: $file"
if ! check_gzip_file "$file"; then
*bzip2\ compressed\ data*)
if ! check_compressed_file "$file" "bz2"; then
return 1
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
return 1
@ -578,7 +650,8 @@ if [ ! -d /proc/self/ ]; then
PROC_MOUNTED=1
fi
ret=0
# preserve cmp_spec result for check_all runs
ret=$RES
for file in $files; do
if ! check_single_file $file; then
ret=1
@ -593,6 +666,9 @@ if [ "$PROC_MOUNTED" -eq "1" ]; then
umount /proc
fi
rm $file1 $file2 $dfile
rm $file1 $file2 $dfile $rename_script
rm -r $dir
if test "$ret" = 0; then
echo "RPM content is identical"
fi
exit $ret

View File

@ -79,14 +79,17 @@ for opac in ${OLDRPMS[*]}; do
echo "names differ: $oname $nname"
exit 1
fi
if [ $(echo "$opac" | grep -e "debuginfo") ]; then
case "$opac" in
*debuginfo*)
echo "skipping -debuginfo package"
else
;;
*)
bash $CMPSCRIPT "$opac" "$npac" || SUCCESS=0
if test $SUCCESS -eq 0 -a -z "$check_all"; then
exit 1
fi
fi
;;
esac
done
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
if ! cmp -s $file1 $file2; then
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
fi
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
# the resulting files are needed.
cmp_spec $1 $2
cmp_spec
RES=$?
case $RES in
0)