Accepting request 621344 from openSUSE:Tools

- pkg-diff: fix diff returning 0

- Match also ELF pie executable (bsc#1097339)

- Remove trailing space from two match patterns

- Recognize "setuid ELF nn-bit xSB shared object" ELF binaries

- Avoid large temporary files from hexdump output and avoid
  diff(1) runing OOM by using a fifo (issue#24)

- check rpm capabilities for recommends/suggests

- Ignore /usr/lib/.build-id differences in package filelist

OBS-URL: https://build.opensuse.org/request/show/621344
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/build-compare?expand=0&rev=108
This commit is contained in:
Dominique Leuenberger 2018-07-07 19:52:36 +00:00 committed by Git OBS Bridge
commit 436e7886b3
4 changed files with 93 additions and 17 deletions

View File

@ -1,3 +1,39 @@
-------------------------------------------------------------------
Fri Jul 6 14:01:17 UTC 2018 - olaf@aepfle.de
- pkg-diff: fix diff returning 0
-------------------------------------------------------------------
Wed Jul 4 05:58:13 UTC 2018 - olaf@aepfle.de
- Match also ELF pie executable (bsc#1097339)
-------------------------------------------------------------------
Wed Jul 4 05:42:05 UTC 2018 - olaf@aepfle.de
- Remove trailing space from two match patterns
-------------------------------------------------------------------
Tue Jun 26 06:45:38 UTC 2018 - olaf@aepfle.de
- Recognize "setuid ELF nn-bit xSB shared object" ELF binaries
-------------------------------------------------------------------
Mon May 28 13:26:44 UTC 2018 - olaf@aepfle.de
- Avoid large temporary files from hexdump output and avoid
diff(1) runing OOM by using a fifo (issue#24)
-------------------------------------------------------------------
Fri Apr 13 07:10:30 UTC 2018 - olaf@aepfle.de
- check rpm capabilities for recommends/suggests
-------------------------------------------------------------------
Fri Dec 8 16:57:00 UTC 2017 - ol@infoserver.lv
- Ignore /usr/lib/.build-id differences in package filelist
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Dec 4 10:21:44 UTC 2017 - olaf@aepfle.de Mon Dec 4 10:21:44 UTC 2017 - 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: 20171204T112209.f06fbac Version: 20180706T160151.66224a8
Release: 0 Release: 0
Source1: COPYING Source1: COPYING
Source2: same-build-result.sh Source2: same-build-result.sh
@ -30,8 +30,8 @@ Source4: functions.sh
Source5: srpm-check.sh Source5: srpm-check.sh
%if 0%{?suse_version} %if 0%{?suse_version}
Requires: bash Requires: bash
Requires: coreutils
Requires: cpio Requires: cpio
Requires: coreutils
Requires: diffutils Requires: diffutils
Requires: file Requires: file
Requires: gawk Requires: gawk

View File

@ -10,6 +10,12 @@
RPM="rpm -qp --nodigest --nosignature" RPM="rpm -qp --nodigest --nosignature"
set_rpm_meta_global_variables() {
local pkg=$1
local rpm_tags=
local out=`mktemp`
# Name, Version, Release # Name, Version, Release
QF_NAME="%{NAME}" QF_NAME="%{NAME}"
QF_VER_REL="%{VERSION}-%{RELEASE}" QF_VER_REL="%{VERSION}-%{RELEASE}"
@ -21,8 +27,19 @@ QF_PROVIDES="[%{PROVIDENAME} %{PROVIDEFLAGS} %{PROVIDEVERSION}\\n]\\n"
QF_PROVIDES="${QF_PROVIDES}[%{REQUIRENAME} %{REQUIREFLAGS} %{REQUIREVERSION}\\n]\\n" QF_PROVIDES="${QF_PROVIDES}[%{REQUIRENAME} %{REQUIREFLAGS} %{REQUIREVERSION}\\n]\\n"
QF_PROVIDES="${QF_PROVIDES}[%{CONFLICTNAME} %{CONFLICTFLAGS} %{CONFLICTVERSION}\\n]\\n" QF_PROVIDES="${QF_PROVIDES}[%{CONFLICTNAME} %{CONFLICTFLAGS} %{CONFLICTVERSION}\\n]\\n"
QF_PROVIDES="${QF_PROVIDES}[%{OBSOLETENAME} %{OBSOLETEFLAGS} %{OBSOLETEVERSION}\\n]\\n" QF_PROVIDES="${QF_PROVIDES}[%{OBSOLETENAME} %{OBSOLETEFLAGS} %{OBSOLETEVERSION}\\n]\\n"
QF_PROVIDES="${QF_PROVIDES}[%{RECOMMENDNAME} %{RECOMMENDFLAGS} %{RECOMMENDVERSION}\\n]\\n"
QF_PROVIDES="${QF_PROVIDES}[%{SUPPLEMENTNAME} %{SUPPLEMENTFLAGS} %{SUPPLEMENTVERSION}\\n]\\n" rpm_tags="%{RECOMMENDNAME} %{RECOMMENDFLAGS} %{RECOMMENDVERSION}"
check_header "%{NAME} ${rpm_tags}" > "${out}"
if test -s "${out}"
then
QF_PROVIDES="${QF_PROVIDES}[${rpm_tags}\\n]\\n"
fi
rpm_tags="%{SUPPLEMENTNAME} %{SUPPLEMENTFLAGS} %{SUPPLEMENTVERSION}"
check_header "%{NAME} ${rpm_tags}" > "${out}"
if test -s "${out}"
then
QF_PROVIDES="${QF_PROVIDES}[${rpm_tags}\\n]\\n"
fi
# don't look at RELEASE, it contains our build number # don't look at RELEASE, it contains our build number
QF_TAGS="%{NAME} %{VERSION} %{EPOCH}\\n" QF_TAGS="%{NAME} %{VERSION} %{EPOCH}\\n"
@ -65,6 +82,7 @@ QF_ALL="$QF_ALL\n___QF_PROVIDES___\n${QF_PROVIDES}\n___QF_PROVIDES___\n"
QF_ALL="$QF_ALL\n___QF_SCRIPT___\n${QF_SCRIPT}\n___QF_SCRIPT___\n" QF_ALL="$QF_ALL\n___QF_SCRIPT___\n${QF_SCRIPT}\n___QF_SCRIPT___\n"
QF_ALL="$QF_ALL\n___QF_FILELIST___\n${QF_FILELIST}\n___QF_FILELIST___\n" QF_ALL="$QF_ALL\n___QF_FILELIST___\n${QF_FILELIST}\n___QF_FILELIST___\n"
QF_ALL="$QF_ALL\n___QF_CHECKSUM___\n${QF_CHECKSUM}\n___QF_CHECKSUM___\n" QF_ALL="$QF_ALL\n___QF_CHECKSUM___\n${QF_CHECKSUM}\n___QF_CHECKSUM___\n"
}
check_header() check_header()
{ {
@ -83,6 +101,7 @@ function trim_release_old()
/\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$version_release_old_regex_l\$\|$version_release_old_regex_l)\)/{s,$version_release_old_regex_l,@VERSION@-@RELEASE_LONG@,g;s,$version_release_old_regex_s,@VERSION@-@RELEASE_SHORT@,g} /\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$version_release_old_regex_l\$\|$version_release_old_regex_l)\)/{s,$version_release_old_regex_l,@VERSION@-@RELEASE_LONG@,g;s,$version_release_old_regex_s,@VERSION@-@RELEASE_SHORT@,g}
s/\(\/var\/adm\/update-scripts\/\)${name_ver_rel_old_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g s/\(\/var\/adm\/update-scripts\/\)${name_ver_rel_old_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g
s/\(\/var\/adm\/update-messages\/\)${name_ver_rel_old_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g s/\(\/var\/adm\/update-messages\/\)${name_ver_rel_old_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g
/\/usr\/lib\/\.build-id/d
" "
} }
function trim_release_new() function trim_release_new()
@ -91,6 +110,7 @@ function trim_release_new()
/\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$version_release_new_regex_l\$\|$version_release_new_regex_l)\)/{s,$version_release_new_regex_l,@VERSION@-@RELEASE_LONG@,g;s,$version_release_new_regex_s,@VERSION@-@RELEASE_SHORT@,g} /\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$version_release_new_regex_l\$\|$version_release_new_regex_l)\)/{s,$version_release_new_regex_l,@VERSION@-@RELEASE_LONG@,g;s,$version_release_new_regex_s,@VERSION@-@RELEASE_SHORT@,g}
s/\(\/var\/adm\/update-scripts\/\)${name_ver_rel_new_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g s/\(\/var\/adm\/update-scripts\/\)${name_ver_rel_new_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g
s/\(\/var\/adm\/update-messages\/\)${name_ver_rel_new_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g s/\(\/var\/adm\/update-messages\/\)${name_ver_rel_new_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g
/\/usr\/lib\/\.build-id/d
" "
} }
# Get single directory or filename with long or short release string # Get single directory or filename with long or short release string
@ -222,6 +242,8 @@ function cmp_rpm_meta ()
rpm_meta_old=`mktemp` rpm_meta_old=`mktemp`
rpm_meta_new=`mktemp` rpm_meta_new=`mktemp`
set_rpm_meta_global_variables $oldrpm
check_header "$QF_ALL" $oldrpm > $rpm_meta_old check_header "$QF_ALL" $oldrpm > $rpm_meta_old
check_header "$QF_ALL" $newrpm > $rpm_meta_new check_header "$QF_ALL" $newrpm > $rpm_meta_new

View File

@ -280,6 +280,9 @@ dfile=`mktemp`
diff_two_files() diff_two_files()
{ {
local offset length
local po pn
if test ! -e old/$file; then if test ! -e old/$file; then
echo "Missing in old package: $file" echo "Missing in old package: $file"
return 1 return 1
@ -289,15 +292,25 @@ diff_two_files()
return 1 return 1
fi fi
if cmp -s old/$file new/$file; then if cmp -b old/$file new/$file > $dfile ; then
return 0 return 0
fi fi
if ! test -s $dfile ; then
return 1
fi
echo "$file differs ($ftype)" offset=`sed 's@^.*differ: byte @@;s@,.*@@' < $dfile`
hexdump -C old/$file > $file1 & echo "$file differs at offset '$offset' ($ftype)"
hexdump -C new/$file > $file2 & po=`mktemp --dry-run $TMPDIR/old.XXX`
wait pn=`mktemp --dry-run $TMPDIR/new.XXX`
diff -u $file1 $file2 | $buildcompare_head mkfifo -m 0600 $po
mkfifo -m 0600 $pn
offset=$(( ($offset >> 6) << 6 ))
length=512
hexdump -C -s $offset -n $length old/$file > $po &
hexdump -C -s $offset -n $length new/$file > $pn &
diff -u $po $pn | $buildcompare_head
rm -f $po $pn
return 1 return 1
} }
@ -456,6 +469,7 @@ check_compressed_file()
check_single_file() check_single_file()
{ {
local file="$1" local file="$1"
local ret=0
# If the two files are the same, return at once. # If the two files are the same, return at once.
if [ -f old/$file -a -f new/$file ]; then if [ -f old/$file -a -f new/$file ]; then
@ -499,7 +513,6 @@ check_single_file()
cd $pwd/new/$fdir cd $pwd/new/$fdir
cpio --quiet --extract --force-local < "../${file##*/}" cpio --quiet --extract --force-local < "../${file##*/}"
cd $pwd cd $pwd
local ret=0
for f in $flist; do for f in $flist; do
if ! check_single_file $fdir/$f; then if ! check_single_file $fdir/$f; then
ret=1 ret=1
@ -516,7 +529,6 @@ check_single_file()
fdir=$file.extract.$PPID.$$ fdir=$file.extract.$PPID.$$
unsquashfs -no-progress -dest old/$fdir "old/$file" unsquashfs -no-progress -dest old/$fdir "old/$file"
unsquashfs -no-progress -dest new/$fdir "new/$file" unsquashfs -no-progress -dest new/$fdir "new/$file"
local ret=0
for f in $flist; do for f in $flist; do
if ! check_single_file $fdir/$f; then if ! check_single_file $fdir/$f; then
ret=1 ret=1
@ -537,7 +549,6 @@ check_single_file()
cd $pwd/new/$fdir cd $pwd/new/$fdir
tar xf `basename $file` tar xf `basename $file`
cd $pwd cd $pwd
local ret=0
for f in $flist; do for f in $flist; do
if ! check_single_file $fdir/$f; then if ! check_single_file $fdir/$f; then
ret=1 ret=1
@ -569,7 +580,6 @@ check_single_file()
cd $pwd/new/$fdir cd $pwd/new/$fdir
unjar `basename $file` unjar `basename $file`
cd $pwd cd $pwd
local ret=0
for f in $flist; do for f in $flist; do
if test -f new/$fdir/$f && ! check_single_file $fdir/$f; then if test -f new/$fdir/$f && ! check_single_file $fdir/$f; then
ret=1 ret=1
@ -659,6 +669,7 @@ check_single_file()
# <!-- Generated by javadoc (version 1.7.0_75) on Tue Feb 03 02:20:12 GMT 2015 --> # <!-- Generated by javadoc (version 1.7.0_75) on Tue Feb 03 02:20:12 GMT 2015 -->
# <!-- Generated by javadoc on Tue Feb 03 00:02:48 GMT 2015 --> # <!-- Generated by javadoc on Tue Feb 03 00:02:48 GMT 2015 -->
# <!-- Generated by javadoc (1.8.0_72) on Thu Mar 03 12:50:28 GMT 2016 --> # <!-- Generated by javadoc (1.8.0_72) on Thu Mar 03 12:50:28 GMT 2016 -->
# <!-- Generated by javadoc (10-internal) on Wed Feb 07 06:33:41 GMT 2018 -->
# <meta name="date" content="2015-02-03"> # <meta name="date" content="2015-02-03">
# </head> # </head>
sed -i -e ' sed -i -e '
@ -672,6 +683,8 @@ check_single_file()
t next t next
s/^\(<!-- Generated by javadoc\) \((\(build\|version\) [0-9._]\+) on ... ... .. ..:..:.. \(GMT\|UTC\) ....\) \(-->\)/\1 some-date-removed-by-build-compare \5/ s/^\(<!-- Generated by javadoc\) \((\(build\|version\) [0-9._]\+) on ... ... .. ..:..:.. \(GMT\|UTC\) ....\) \(-->\)/\1 some-date-removed-by-build-compare \5/
t next t next
s/^\(<!-- Generated by javadoc\) ([0-9._]\+-internal) on ... ... .. ..:..:.. \(GMT\|UTC\) .... \(-->\)/\1 some-date-removed-by-build-compare \3/
t next
s/^\(<!-- Generated by javadoc\) \(on ... ... .. ..:..:.. \(GMT\|UTC\) ....\) \(-->\)/\1 some-date-removed-by-build-compare \3/ s/^\(<!-- Generated by javadoc\) \(on ... ... .. ..:..:.. \(GMT\|UTC\) ....\) \(-->\)/\1 some-date-removed-by-build-compare \3/
t next t next
s/^<meta name="date" content="[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}">/<meta name="date" content="some-date-removed-by-build-compare">/ s/^<meta name="date" content="[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}">/<meta name="date" content="some-date-removed-by-build-compare">/
@ -808,7 +821,12 @@ check_single_file()
return 1 return 1
fi fi
;; ;;
ELF*executable*|ELF*[LM]SB\ relocatable*|ELF*[LM]SB\ shared\ object*) ELF*executable*|\
ELF*[LM]SB\ relocatable*|\
ELF*[LM]SB\ shared\ object*|\
setuid\ ELF*[LM]SB\ shared\ object*|\
ELF*[LM]SB\ pie\ executable*|\
setuid\ ELF*[LM]SB\ pie\ executable*)
$OBJDUMP -d --no-show-raw-insn old/$file > $file1 $OBJDUMP -d --no-show-raw-insn old/$file > $file1
ret=$? ret=$?
$OBJDUMP -d --no-show-raw-insn new/$file > $file2 $OBJDUMP -d --no-show-raw-insn new/$file > $file2