3
0
forked from pool/build-compare

- 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
This commit is contained in:
Olaf Hering 2015-02-10 15:54:31 +00:00 committed by Git OBS Bridge
parent 2edf4d28d7
commit 6cffad1656
4 changed files with 105 additions and 46 deletions

View File

@ -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 Fri Feb 6 10:35:56 UTC 2015 - olaf@aepfle.de

View File

@ -21,7 +21,7 @@ Summary: Build Result Compare Script
License: GPL-2.0+ License: GPL-2.0+
Group: Development/Tools/Building Group: Development/Tools/Building
Url: https://github.com/openSUSE/build-compare Url: https://github.com/openSUSE/build-compare
Version: 2015.02.06 Version: 2015.02.10
Release: 0 Release: 0
Source1: COPYING Source1: COPYING
Source2: same-build-result.sh Source2: same-build-result.sh

View File

@ -57,19 +57,35 @@ function check_provides()
check_header "$pkg" check_header "$pkg"
} }
#usage unrpm <file> $dir #usage unpackage <file> $dir
# Unpack rpm files in directory $dir # Unpack files in directory $dir
# like /usr/bin/unrpm - just for one file and with no options # like /usr/bin/unpackage - just for one file and with no options
function unrpm() function unpackage()
{ {
local file local file
local dir local dir
file=$1 file=$1
dir=$2 dir=$2
CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories --quiet"
mkdir -p $dir mkdir -p $dir
pushd $dir 1>/dev/null pushd $dir 1>/dev/null
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} rpm2cpio $file | cpio ${CPIO_OPTS}
;;
esac
popd 1>/dev/null popd 1>/dev/null
} }
@ -85,6 +101,8 @@ function cmp_spec ()
local file1 file2 local file1 file2
local f local f
local sh=$1 local sh=$1
local oldrpm=$2
local newrpm=$3
QF="%{NAME}" QF="%{NAME}"

View File

@ -20,19 +20,21 @@ if test "$#" != 2; then
exit 1 exit 1
fi fi
self_script=$(cd $(dirname $0); echo $(pwd)/$(basename $0))
source $FUNCTIONS source $FUNCTIONS
oldrpm=`readlink -f $1` oldpkg=`readlink -f $1`
newrpm=`readlink -f $2` newpkg=`readlink -f $2`
rename_script=`mktemp` rename_script=`mktemp`
if test ! -f $oldrpm; then if test ! -f "$oldpkg"; then
echo "can't open $oldrpm" echo "can't open $1"
exit 1 exit 1
fi fi
if test ! -f $newrpm; then if test ! -f "$newpkg"; then
echo "can't open $newrpm" echo "can't open $2"
exit 1 exit 1
fi fi
@ -97,7 +99,11 @@ 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 $rename_script echo "Comparing `basename $oldpkg` to `basename $newpkg`"
case $oldpkg in
*.rpm)
cmp_spec $rename_script $oldpkg $newpkg
RES=$? RES=$?
case $RES in case $RES in
0) 0)
@ -121,14 +127,26 @@ case $RES in
exit 1 exit 1
;; ;;
esac esac
;;
esac
file1=`mktemp` file1=`mktemp`
file2=`mktemp` file2=`mktemp`
dir=`mktemp -d` dir=`mktemp -d`
echo "Extracting packages" echo "Extracting packages"
unrpm $oldrpm $dir/old unpackage $oldpkg $dir/old
unrpm $newrpm $dir/new 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 cd $dir
bash $rename_script bash $rename_script
@ -388,6 +406,10 @@ check_single_file()
check_single_file ${file/.gz/} check_single_file ${file/.gz/}
return $? return $?
;; ;;
*.rpm)
$self_script -a old/$file new/$file
return $?
;;
*png) *png)
# Try to remove timestamps, only if convert from ImageMagick is installed # Try to remove timestamps, only if convert from ImageMagick is installed
if [[ $(type -p convert) ]]; then if [[ $(type -p convert) ]]; then
@ -484,7 +506,7 @@ check_single_file()
trim_man_first_line $f trim_man_first_line $f
done 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 for f in old/$file new/$file; do
trim_man_TH $f trim_man_TH $f
@ -623,26 +645,29 @@ check_single_file()
break break
fi fi
fi fi
elfdiff=
sed -i -e "s,old/,," $file1 sed -i -e "s,old/,," $file1
objdump -d --no-show-raw-insn new/$file | filter_disasm > $file2 objdump -d --no-show-raw-insn new/$file | filter_disasm > $file2
sed -i -e "s,new/,," $file2 sed -i -e "s,new/,," $file2
if ! diff -u $file1 $file2 > $dfile; then if ! diff -u $file1 $file2 > $dfile; then
echo "$file differs in assembler output" echo "$file differs in assembler output"
head -n 200 $dfile head -n 200 $dfile
return 1 elfdiff="1"
fi fi
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
sections="$(objdump -s new/$file | grep "Contents of section .*:" | sed -r "s,.* (.*):,\1,g" | grep -v -e "\.build-id" -e "\.gnu_debuglink" | tr "\n" " ")" 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 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
if ! diff -u $file1 $file2 > $dfile; then if ! diff -u $file1 $file2 > $dfile; then
echo "$file differs in ELF sections" echo "$file differs in ELF section $section"
head -n 200 $dfile head -n 200 $dfile
else elfdiff="1"
fi
done
if test -z "$elfdiff"; then
echo "$file: only difference was in build-id or gnu_debuglink, GOOD." echo "$file: only difference was in build-id or gnu_debuglink, GOOD."
return 0 return 0
fi fi
@ -733,7 +758,7 @@ fi
rm $file1 $file2 $dfile $rename_script rm $file1 $file2 $dfile $rename_script
rm -rf $dir rm -rf $dir
if test "$ret" = 0; then if test "$ret" = 0; then
echo "RPM content is identical" echo "Package content is identical"
fi fi
exit $ret exit $ret
# vim: tw=666 ts=2 et # vim: tw=666 ts=2 et