From 6cffad16566b2911d8b563f0bc6ab05a94645e0a594baf5f90554dfd10a89ebe Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Tue, 10 Feb 2015 15:54:31 +0000 Subject: [PATCH 1/3] - 2015.02.10 - Trim objdump output properly - Trim .TH also in localized man pages (bnc#915941) - Print section differences even if assembly has differences. - Add support for nested rpms. - Make rpm-check work for "packages" other than rpm. - Tell which section was different when doing ELF comparisons. - Error when one of the rpms is not found OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=173 --- build-compare.changes | 16 +++++++ build-compare.spec | 2 +- functions.sh | 30 +++++++++--- rpm-check.sh | 103 ++++++++++++++++++++++++++---------------- 4 files changed, 105 insertions(+), 46 deletions(-) diff --git a/build-compare.changes b/build-compare.changes index 94824da..33be208 100644 --- a/build-compare.changes +++ b/build-compare.changes @@ -1,3 +1,19 @@ +------------------------------------------------------------------- +Tue Feb 10 15:35:25 UTC 2015 - olaf@aepfle.de + +- 2015.02.10 +- Trim objdump output properly +- Trim .TH also in localized man pages (bnc#915941) + +------------------------------------------------------------------- +Tue Feb 10 15:33:32 UTC 2015 - randy.e.witt@linux.intel.com + +- Print section differences even if assembly has differences. +- Add support for nested rpms. +- Make rpm-check work for "packages" other than rpm. +- Tell which section was different when doing ELF comparisons. +- Error when one of the rpms is not found + ------------------------------------------------------------------- Fri Feb 6 10:35:56 UTC 2015 - olaf@aepfle.de diff --git a/build-compare.spec b/build-compare.spec index 2be26cd..1ccf07f 100644 --- a/build-compare.spec +++ b/build-compare.spec @@ -21,7 +21,7 @@ Summary: Build Result Compare Script License: GPL-2.0+ Group: Development/Tools/Building Url: https://github.com/openSUSE/build-compare -Version: 2015.02.06 +Version: 2015.02.10 Release: 0 Source1: COPYING Source2: same-build-result.sh diff --git a/functions.sh b/functions.sh index 6e93d84..cb00279 100644 --- a/functions.sh +++ b/functions.sh @@ -57,19 +57,35 @@ function check_provides() check_header "$pkg" } -#usage unrpm $dir -# Unpack rpm files in directory $dir -# like /usr/bin/unrpm - just for one file and with no options -function unrpm() +#usage unpackage $dir +# Unpack files in directory $dir +# like /usr/bin/unpackage - just for one file and with no options +function unpackage() { local file local dir file=$1 dir=$2 - CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories --quiet" mkdir -p $dir pushd $dir 1>/dev/null - rpm2cpio $file | cpio ${CPIO_OPTS} + case $file in + *.bz2) + bzip2 -d $file + ;; + *.gz) + gzip -d $file + ;; + *.xz) + xz -d $file + ;; + *.tar|*.tar.bz2|*.tar.gz|*.tgz|*.tbz2) + tar xf $file + ;; + *.rpm) + CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories --quiet" + rpm2cpio $file | cpio ${CPIO_OPTS} + ;; + esac popd 1>/dev/null } @@ -85,6 +101,8 @@ function cmp_spec () local file1 file2 local f local sh=$1 + local oldrpm=$2 + local newrpm=$3 QF="%{NAME}" diff --git a/rpm-check.sh b/rpm-check.sh index 5191524..717ed5a 100644 --- a/rpm-check.sh +++ b/rpm-check.sh @@ -20,19 +20,21 @@ if test "$#" != 2; then exit 1 fi +self_script=$(cd $(dirname $0); echo $(pwd)/$(basename $0)) + source $FUNCTIONS -oldrpm=`readlink -f $1` -newrpm=`readlink -f $2` +oldpkg=`readlink -f $1` +newpkg=`readlink -f $2` rename_script=`mktemp` -if test ! -f $oldrpm; then - echo "can't open $oldrpm" +if test ! -f "$oldpkg"; then + echo "can't open $1" exit 1 fi -if test ! -f $newrpm; then - echo "can't open $newrpm" +if test ! -f "$newpkg"; then + echo "can't open $2" exit 1 fi @@ -97,28 +99,34 @@ 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 $rename_script -RES=$? -case $RES in - 0) - echo "RPM meta information is identical" - if test -z "$check_all"; then - exit 0 - fi - ;; - 1) - echo "RPM meta information is different" - if test -z "$check_all"; then - exit 1 - fi - ;; - 2) - echo "RPM file checksum differs." - RES=0 - ;; - *) - echo "Wrong exit code!" - exit 1 +echo "Comparing `basename $oldpkg` to `basename $newpkg`" + +case $oldpkg in + *.rpm) + cmp_spec $rename_script $oldpkg $newpkg + RES=$? + case $RES in + 0) + echo "RPM meta information is identical" + if test -z "$check_all"; then + exit 0 + fi + ;; + 1) + echo "RPM meta information is different" + if test -z "$check_all"; then + exit 1 + fi + ;; + 2) + echo "RPM file checksum differs." + RES=0 + ;; + *) + echo "Wrong exit code!" + exit 1 + ;; + esac ;; esac @@ -127,8 +135,18 @@ file2=`mktemp` dir=`mktemp -d` echo "Extracting packages" -unrpm $oldrpm $dir/old -unrpm $newrpm $dir/new +unpackage $oldpkg $dir/old +unpackage $newpkg $dir/new + +# files is set in cmp_spec for rpms, so if RES is empty we should assume +# it wasn't an rpm and pick all files for comparison. +if [ -z $RES ]; then + oldfiles=`cd $dir/old; find . -type f` + newfiles=`cd $dir/new; find . -type f` + + files=`echo -e "$oldfiles\n$newfiles" | sort -u` +fi + cd $dir bash $rename_script @@ -388,6 +406,10 @@ check_single_file() check_single_file ${file/.gz/} return $? ;; + *.rpm) + $self_script -a old/$file new/$file + return $? + ;; *png) # Try to remove timestamps, only if convert from ImageMagick is installed if [[ $(type -p convert) ]]; then @@ -484,7 +506,7 @@ check_single_file() trim_man_first_line $f done ;; - /usr/share/man/man*/*|/usr/lib/texmf/doc/man/*/*) + /usr/share/man/*/man*|/usr/share/man/man*|/usr/lib/texmf/doc/man/*/*) for f in old/$file new/$file; do trim_man_TH $f @@ -623,26 +645,29 @@ check_single_file() break fi fi + elfdiff= sed -i -e "s,old/,," $file1 objdump -d --no-show-raw-insn new/$file | filter_disasm > $file2 sed -i -e "s,new/,," $file2 if ! diff -u $file1 $file2 > $dfile; then echo "$file differs in assembler output" head -n 200 $dfile - return 1 + elfdiff="1" fi echo "" >$file1 echo "" >$file2 # Don't compare .build-id and .gnu_debuglink sections 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 + objdump -s -j $section old/$file | sed "s,^old/,," > $file1 + objdump -s -j $section new/$file | sed "s,^new/,," > $file2 + if ! diff -u $file1 $file2 > $dfile; then + echo "$file differs in ELF section $section" + head -n 200 $dfile + elfdiff="1" + fi done - if ! diff -u $file1 $file2 > $dfile; then - echo "$file differs in ELF sections" - head -n 200 $dfile - else + if test -z "$elfdiff"; then echo "$file: only difference was in build-id or gnu_debuglink, GOOD." return 0 fi @@ -733,7 +758,7 @@ fi rm $file1 $file2 $dfile $rename_script rm -rf $dir if test "$ret" = 0; then - echo "RPM content is identical" + echo "Package content is identical" fi exit $ret # vim: tw=666 ts=2 et From 1454a884a174335493a2c43735f35413f49d5c0a0539c76c8b0c49af6b0d157d Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Tue, 10 Feb 2015 17:41:49 +0000 Subject: [PATCH 2/3] - Remove also DVIPSSource from .ps files OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=174 --- build-compare.changes | 1 + rpm-check.sh | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build-compare.changes b/build-compare.changes index 33be208..8dedd36 100644 --- a/build-compare.changes +++ b/build-compare.changes @@ -4,6 +4,7 @@ Tue Feb 10 15:35:25 UTC 2015 - olaf@aepfle.de - 2015.02.10 - Trim objdump output properly - Trim .TH also in localized man pages (bnc#915941) +- Remove also DVIPSSource from .ps files ------------------------------------------------------------------- Tue Feb 10 15:33:32 UTC 2015 - randy.e.witt@linux.intel.com diff --git a/rpm-check.sh b/rpm-check.sh index 717ed5a..d25d652 100644 --- a/rpm-check.sh +++ b/rpm-check.sh @@ -590,9 +590,10 @@ check_single_file() *.ps) for f in "old/$file" "new/$file"; do sed -i -e ' - /^%%CreationDate:[[:blank:]]/d - /^%%Creator:[[:blank:]]groff[[:blank:]]version[[:blank:]]/d - ' "$f" + /^%%CreationDate:[[:blank:]]/d + /^%%Creator:[[:blank:]]groff[[:blank:]]version[[:blank:]]/d + /^%DVIPSSource:[[:blank:]]/d + ' "$f" done ;; *pdf) From a3ff50b6b42c127ef2ae11a5cc4d35439fe66cb581ab812eb427b9837d7faea9 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Thu, 12 Feb 2015 11:10:09 +0000 Subject: [PATCH 3/3] - Handle also .o files as ELF relocatable objects - Rename rpm-check.sh to pkg-diff.sh OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=175 --- build-compare.changes | 10 ++++++++++ build-compare.spec | 2 +- rpm-check.sh => pkg-diff.sh | 2 +- same-build-result.sh | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) rename rpm-check.sh => pkg-diff.sh (99%) diff --git a/build-compare.changes b/build-compare.changes index 8dedd36..08e374e 100644 --- a/build-compare.changes +++ b/build-compare.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Thu Feb 12 10:41:45 UTC 2015 - olaf@aepfle.de + +- Handle also .o files as ELF relocatable objects + +------------------------------------------------------------------- +Thu Feb 12 08:22:09 UTC 2015 - randy.e.witt@linux.intel.com + +- Rename rpm-check.sh to pkg-diff.sh + ------------------------------------------------------------------- Tue Feb 10 15:35:25 UTC 2015 - olaf@aepfle.de diff --git a/build-compare.spec b/build-compare.spec index 1ccf07f..62cac35 100644 --- a/build-compare.spec +++ b/build-compare.spec @@ -25,7 +25,7 @@ Version: 2015.02.10 Release: 0 Source1: COPYING Source2: same-build-result.sh -Source3: rpm-check.sh +Source3: pkg-diff.sh Source4: functions.sh Source5: srpm-check.sh BuildRoot: %{_tmppath}/%{name}-%{version}-build diff --git a/rpm-check.sh b/pkg-diff.sh similarity index 99% rename from rpm-check.sh rename to pkg-diff.sh index d25d652..6127afe 100644 --- a/rpm-check.sh +++ b/pkg-diff.sh @@ -637,7 +637,7 @@ check_single_file() return 1 fi ;; - ELF*executable*|ELF*[LM]SB\ shared\ object*) + ELF*executable*|ELF*[LM]SB\ relocatable*|ELF*[LM]SB\ shared\ object*) objdump -d --no-show-raw-insn old/$file | filter_disasm > $file1 if ! test -s $file1; then # objdump has no idea how to handle it diff --git a/same-build-result.sh b/same-build-result.sh index a2d69a5..942e201 100644 --- a/same-build-result.sh +++ b/same-build-result.sh @@ -7,11 +7,11 @@ # Enhanced by Andreas Jaeger # # The script decides if the new build differes from the former one, -# using rpm-check.sh. +# using pkg-diff.sh. # 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 -CMPSCRIPT=${0%/*}/rpm-check.sh +CMPSCRIPT=${0%/*}/pkg-diff.sh SCMPSCRIPT=${0%/*}/srpm-check.sh check_all=1