From dd47afde1cabb1fb0fd918ef229b7f7f3466f1e3fa9f51ebb370bdfb6583d62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Mon, 24 Nov 2014 12:18:21 +0000 Subject: [PATCH] Accepting request 262230 from home:olh:branches:openSUSE:Tools - 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 OBS-URL: https://build.opensuse.org/request/show/262230 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=154 --- build-compare.changes | 11 +++++ build-compare.spec | 5 +-- functions.sh | 98 +++++++++++++++++++++++++++++++++++-------- rpm-check.sh | 53 ++++++++++++++++++++--- same-build-result.sh | 11 +++-- srpm-check.sh | 2 +- 6 files changed, 149 insertions(+), 31 deletions(-) diff --git a/build-compare.changes b/build-compare.changes index 5b38d28..9f4f221 100644 --- a/build-compare.changes +++ b/build-compare.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +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 diff --git a/build-compare.spec b/build-compare.spec index 5fcf883..d5cbe77 100644 --- a/build-compare.spec +++ b/build-compare.spec @@ -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.15 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 diff --git a/functions.sh b/functions.sh index 3133bfe..af6b214 100644 --- a/functions.sh +++ b/functions.sh @@ -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 $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 } diff --git a/rpm-check.sh b/rpm-check.sh index 070cdeb..0dc1f02 100644 --- a/rpm-check.sh +++ b/rpm-check.sh @@ -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,13 @@ 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]\+ :/\1:/' -e 's/<\(.*\)+0x[0-9a-f]\+>/<\1 + ofs>/' } -cmp_spec $1 $2 +cmp_spec $rename_script RES=$? case $RES in 0) - exit 0 + if test -z "$check_all"; then + exit 0 + fi ;; 1) echo "RPM meta information is different" @@ -120,9 +123,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` @@ -177,6 +182,14 @@ check_gzip_file() ret=1 fi ;; + *ASCII\ cpio\ archive\ *) + echo "gzip 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" if ! diff_two_files; then @@ -220,6 +233,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 +563,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 @@ -560,6 +594,14 @@ check_single_file() 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 +620,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 +636,6 @@ if [ "$PROC_MOUNTED" -eq "1" ]; then umount /proc fi -rm $file1 $file2 $dfile +rm $file1 $file2 $dfile $rename_script rm -r $dir exit $ret diff --git a/same-build-result.sh b/same-build-result.sh index 3c08a01..3f1269d 100644 --- a/same-build-result.sh +++ b/same-build-result.sh @@ -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 diff --git a/srpm-check.sh b/srpm-check.sh index 96abf94..ec2104b 100644 --- a/srpm-check.sh +++ b/srpm-check.sh @@ -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)