- javadoc: filter dc.created

- Support filenames with spaces
- jar: always list files without date+size
- Fix differing jars reported as identical

- Ignore value of Release header when comparing spec files

OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=255
This commit is contained in:
Olaf Hering 2019-02-19 09:32:50 +00:00 committed by Git OBS Bridge
parent e3e3d3e14d
commit 5cee16f457
6 changed files with 88 additions and 87 deletions

View File

@ -1,3 +1,16 @@
-------------------------------------------------------------------
Tue Feb 19 09:30:20 UTC 2019 - olaf@aepfle.de
- javadoc: filter dc.created
- Support filenames with spaces
- jar: always list files without date+size
- Fix differing jars reported as identical
-------------------------------------------------------------------
Tue Aug 28 20:14:53 UTC 2018 - ol@infoserver.lv
- Ignore value of Release header when comparing spec files
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Jul 6 14:01:17 UTC 2018 - olaf@aepfle.de Fri Jul 6 14:01:17 UTC 2018 - 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: 20180706T160151.66224a8 Version: 20190219T103140.3277313
Release: 0 Release: 0
Source1: COPYING Source1: COPYING
Source2: same-build-result.sh Source2: same-build-result.sh

View File

@ -175,6 +175,7 @@ function comp_file()
rm $2 $3 $4 $5 rm $2 $3 $4 $5
return 1 return 1
fi fi
difffound=1
fi fi
return 0 return 0
} }
@ -265,17 +266,15 @@ function cmp_rpm_meta ()
set_regex set_regex
# Check the whole spec file at first, return 0 immediately if the # Check the whole spec file at first, return 0 immediately if they
# are the same. # are the same.
cat $rpm_meta_old | trim_release_old > $file1 cat $rpm_meta_old | trim_release_old > $file1
cat $rpm_meta_new | trim_release_new > $file2 cat $rpm_meta_new | trim_release_new > $file2
echo "comparing the rpm tags of $name_new" echo "comparing the rpm tags of $name_new"
if diff -au $file1 $file2; then if diff -au $file1 $file2; then
if test -z "$check_all"; then
rm $file1 $file2 $rpm_meta_old $rpm_meta_new rm $file1 $file2 $rpm_meta_old $rpm_meta_new
return 0 return 0
fi fi
fi
get_value QF_TAGS $rpm_meta_old > $file1 get_value QF_TAGS $rpm_meta_old > $file1
get_value QF_TAGS $rpm_meta_new > $file2 get_value QF_TAGS $rpm_meta_new > $file2
@ -291,6 +290,7 @@ function cmp_rpm_meta ()
if test -z "$check_all"; then if test -z "$check_all"; then
return 1 return 1
fi fi
difffound=1
;; ;;
# Every other package is allowed to have a different RELEASE # Every other package is allowed to have a different RELEASE
*) ;; *) ;;
@ -323,7 +323,7 @@ function cmp_rpm_meta ()
fi fi
# Get only files with different MD5sums # Get only files with different MD5sums
files=`diff -U0 $file1 $file2 | fgrep -v +++ | grep ^+ | cut -b2- | awk '{print $1}'` files=`diff -U0 $file1 $file2 | fgrep -v +++ | grep ^+ | cut -b2- | sed -E -e 's/ [0-9a-f]+ [0-9]+$//'`
if test -n "$sh"; then if test -n "$sh"; then
echo "creating rename script" echo "creating rename script"
@ -340,6 +340,7 @@ function cmp_rpm_meta ()
fi fi
# #
rm $file1 $file2 rm $file1 $file2
[ "$difffound" = 1 ] && RES=1
return $RES return $RES
} }

View File

@ -59,12 +59,8 @@ if test ! -f "$newpkg"; then
exit 1 exit 1
fi fi
#usage unjar <file> function findunjarbin
function unjar()
{ {
local file
file=$1
if [[ $(type -p fastjar) ]]; then if [[ $(type -p fastjar) ]]; then
UNJAR=fastjar UNJAR=fastjar
elif [[ $(type -p jar) ]]; then elif [[ $(type -p jar) ]]; then
@ -75,7 +71,15 @@ function unjar()
echo "ERROR: jar, fastjar, or unzip is not installed (trying file $file)" echo "ERROR: jar, fastjar, or unzip is not installed (trying file $file)"
exit 1 exit 1
fi fi
}
#usage unjar <file>
function unjar()
{
local file
file=$1
findunjarbin
case $UNJAR in case $UNJAR in
jar|fastjar) jar|fastjar)
# echo jar -xf $file # echo jar -xf $file
@ -87,30 +91,20 @@ function unjar()
esac esac
} }
# list files in directory # list files in given jar file
#usage unjar_l <file> #usage unjar_l <file>
function unjar_l() function unjar_l()
{ {
local file local file
file=$1 file=$1
if [[ $(type -p fastjar) ]]; then findunjarbin
UNJAR=fastjar
elif [[ $(type -p jar) ]]; then
UNJAR=jar
elif [[ $(type -p unzip) ]]; then
UNJAR=unzip
else
echo "ERROR: jar, fastjar, or unzip is not installed (trying file $file)"
exit 1
fi
case $UNJAR in case $UNJAR in
jar|fastjar) jar|fastjar)
${UNJAR} -tf $file ${UNJAR} -tf $file
;; ;;
unzip) unzip)
unzip -l $file unzip -Z -1 $file
;; ;;
esac esac
} }
@ -122,16 +116,6 @@ filter_disasm()
sed -i -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>/' ${file} sed -i -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>/' ${file}
} }
filter_zip_flist()
{
local file=$1
[[ $nofilter ]] && return
# 10-05-2010 14:39
sed -i -e "s, [0-9][0-9]-[0-9][0-9]-[0-9]\+ [0-9][0-9]:[0-9][0-9] , date ," $file
# 2012-02-03 07:59
sed -i -e "s, 20[0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9] , date ," $file
}
filter_xenefi() { filter_xenefi() {
# PE32+ executable (EFI application) x86-64 (stripped to external PDB), for MS Windows # PE32+ executable (EFI application) x86-64 (stripped to external PDB), for MS Windows
perl -e "open fh, '+<', '$f'; seek fh, 0x80 + 0x08, SEEK_SET; print fh 'time'; seek fh, 0x80 + 0x58, SEEK_SET; print fh 'chck';" perl -e "open fh, '+<', '$f'; seek fh, 0x80 + 0x08, SEEK_SET; print fh 'time'; seek fh, 0x80 + 0x58, SEEK_SET; print fh 'chck';"
@ -283,16 +267,16 @@ diff_two_files()
local offset length local offset length
local po pn 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
fi fi
if test ! -e new/$file; then if test ! -e "new/$file"; then
echo "Missing in new package: $file" echo "Missing in new package: $file"
return 1 return 1
fi fi
if cmp -b old/$file new/$file > $dfile ; then if cmp -b "old/$file" "new/$file" > $dfile ; then
return 0 return 0
fi fi
if ! test -s $dfile ; then if ! test -s $dfile ; then
@ -307,8 +291,8 @@ diff_two_files()
mkfifo -m 0600 $pn mkfifo -m 0600 $pn
offset=$(( ($offset >> 6) << 6 )) offset=$(( ($offset >> 6) << 6 ))
length=512 length=512
hexdump -C -s $offset -n $length old/$file > $po & hexdump -C -s $offset -n $length "old/$file" > $po &
hexdump -C -s $offset -n $length new/$file > $pn & hexdump -C -s $offset -n $length "new/$file" > $pn &
diff -u $po $pn | $buildcompare_head diff -u $po $pn | $buildcompare_head
rm -f $po $pn rm -f $po $pn
return 1 return 1
@ -472,15 +456,15 @@ check_single_file()
local ret=0 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
if cmp -s old/$file new/$file; then if cmp -s "old/$file" "new/$file"; then
return 0 return 0
fi fi
fi fi
case $file in case "$file" in
*.spec) *.spec)
sed -i -e "s,Release:.*$release1,Release: @RELEASE@," old/$file sed -i -e "s,Release:.*$release1,Release: @RELEASE@," "old/$file"
sed -i -e "s,Release:.*$release2,Release: @RELEASE@," new/$file sed -i -e "s,Release:.*$release2,Release: @RELEASE@," "new/$file"
;; ;;
*.exe.mdb|*.dll.mdb) *.exe.mdb|*.dll.mdb)
# Just debug information, we can skip them # Just debug information, we can skip them
@ -488,16 +472,16 @@ check_single_file()
return 0 return 0
;; ;;
*.a) *.a)
flist=`ar t new/$file` flist=`ar t "new/$file"`
pwd=$PWD pwd=$PWD
fdir=`dirname $file` fdir=`dirname "$file"`
cd old/$fdir cd "old/$fdir"
ar x `basename $file` ar x `basename "$file"`
cd $pwd/new/$fdir cd "$pwd/new/$fdir"
ar x `basename $file` ar x `basename "$file"`
cd $pwd cd "$pwd"
for f in $flist; do for f in $flist; do
if ! check_single_file $fdir/$f; then if ! check_single_file "$fdir/$f"; then
return 1 return 1
fi fi
done done
@ -506,51 +490,51 @@ check_single_file()
*.cpio) *.cpio)
flist=`cpio --quiet --list --force-local < "new/$file" | $sort` flist=`cpio --quiet --list --force-local < "new/$file" | $sort`
pwd=$PWD pwd=$PWD
fdir=$file.extract.$PPID.$$ fdir="$file.extract.$PPID.$$"
mkdir old/$fdir new/$fdir mkdir "old/$fdir" "new/$fdir"
cd old/$fdir cd "old/$fdir"
cpio --quiet --extract --force-local < "../${file##*/}" cpio --quiet --extract --force-local < "../${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"
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
if test -z "$check_all"; then if test -z "$check_all"; then
break break
fi fi
fi fi
done done
rm -rf old/$fdir new/$fdir rm -rf "old/$fdir" "new/$fdir"
return $ret return $ret
;; ;;
*.squashfs) *.squashfs)
flist=`unsquashfs -no-progress -ls -dest '' "new/$file" | grep -Ev '^(Parallel unsquashfs:|[0-9]+ inodes )' | $sort` flist=`unsquashfs -no-progress -ls -dest '' "new/$file" | grep -Ev '^(Parallel unsquashfs:|[0-9]+ inodes )' | $sort`
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"
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
if test -z "$check_all"; then if test -z "$check_all"; then
break break
fi fi
fi fi
done done
rm -rf old/$fdir new/$fdir rm -rf "old/$fdir" "new/$fdir"
return $ret return $ret
;; ;;
*.tar|*.tar.bz2|*.tar.gz|*.tgz|*.tbz2) *.tar|*.tar.bz2|*.tar.gz|*.tgz|*.tbz2)
flist=`tar tf new/$file` flist=`tar tf "new/$file"`
pwd=$PWD pwd=$PWD
fdir=`dirname $file` fdir=`dirname "$file"`
cd old/$fdir cd "old/$fdir"
tar xf `basename $file` tar xf `basename "$file"`
cd $pwd/new/$fdir cd "$pwd/new/$fdir"
tar xf `basename $file` tar xf `basename "$file"`
cd $pwd cd "$pwd"
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
if test -z "$check_all"; then if test -z "$check_all"; then
break break
@ -564,7 +548,6 @@ check_single_file()
( (
cd $dir cd $dir
unjar_l ./$file | $sort > flist unjar_l ./$file | $sort > flist
filter_zip_flist flist
) )
done done
if ! cmp -s old/flist new/flist; then if ! cmp -s old/flist new/flist; then
@ -572,7 +555,7 @@ check_single_file()
diff -u old/flist new/flist diff -u old/flist new/flist
return 1 return 1
fi fi
flist=`grep date new/flist | sed -e 's,.* date ,,'` flist=`cat new/flist`
pwd=$PWD pwd=$PWD
fdir=`dirname $file` fdir=`dirname $file`
cd old/$fdir cd old/$fdir
@ -670,6 +653,7 @@ check_single_file()
# <!-- 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 --> # <!-- Generated by javadoc (10-internal) on Wed Feb 07 06:33:41 GMT 2018 -->
# <meta name="dc.created" content="2019-02-07">
# <meta name="date" content="2015-02-03"> # <meta name="date" content="2015-02-03">
# </head> # </head>
sed -i -e ' sed -i -e '
@ -687,6 +671,8 @@ check_single_file()
t next 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="dc.created" content="[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}">/<meta name="dc.created" content="some-date-removed-by-build-compare">/
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">/
b next b next
} }
@ -804,16 +790,16 @@ check_single_file()
;; ;;
esac esac
ftype=`/usr/bin/file old/$file | sed -e 's@^[^:]\+:[[:blank:]]*@@' -e 's@[[:blank:]]*$@@'` ftype=`/usr/bin/file "old/$file" | sed -e 's@^[^:]\+:[[:blank:]]*@@' -e 's@[[:blank:]]*$@@'`
case $ftype in case $ftype in
PE32\ executable*Mono\/\.Net\ assembly*) PE32\ executable*Mono\/\.Net\ assembly*)
echo "PE32 Mono/.Net assembly: $file" echo "PE32 Mono/.Net assembly: $file"
if [ -x /usr/bin/monodis ] ; then if [ -x /usr/bin/monodis ] ; then
monodis old/$file 2>/dev/null|sed -e 's/GUID = {.*}/GUID = { 42 }/;'> ${file1} monodis "old/$file" 2>/dev/null|sed -e 's/GUID = {.*}/GUID = { 42 }/;'> ${file1}
monodis new/$file 2>/dev/null|sed -e 's/GUID = {.*}/GUID = { 42 }/;'> ${file2} monodis "new/$file" 2>/dev/null|sed -e 's/GUID = {.*}/GUID = { 42 }/;'> ${file2}
if ! cmp -s ${file1} ${file2}; then if ! cmp -s "${file1}" "${file2}"; then
echo "$file differs ($ftype)" echo "$file differs ($ftype)"
diff --speed-large-files -u ${file1} ${file2} diff --speed-large-files -u "${file1}" "${file2}"
return 1 return 1
fi fi
else else
@ -867,9 +853,9 @@ check_single_file()
return 1 return 1
;; ;;
*ASCII*|*text*) *ASCII*|*text*)
if ! cmp -s old/$file new/$file; then if ! cmp -s "old/$file" "new/$file"; then
echo "$file differs ($ftype)" echo "$file differs ($ftype)"
diff -u old/$file new/$file | $buildcompare_head diff -u "old/$file" "new/$file" | $buildcompare_head
return 1 return 1
fi fi
;; ;;
@ -946,8 +932,9 @@ fi
# preserve cmp_rpm_meta result for check_all runs # preserve cmp_rpm_meta result for check_all runs
ret=$RES ret=$RES
for file in $files; do readarray -t filesarray <<<"$files"
if ! check_single_file $file; then for file in "${filesarray[@]}"; do
if ! check_single_file "$file"; then
ret=1 ret=1
if test -z "$check_all"; then if test -z "$check_all"; then
break break

View File

@ -184,6 +184,6 @@ fi
if test $SUCCESS -eq 0; then if test $SUCCESS -eq 0; then
exit 1 exit 1
fi fi
echo 'compare validated built as identical !' echo 'compare validated build as identical !'
exit 0 exit 0
# vim: tw=666 ts=2 shiftwidth=2 et # vim: tw=666 ts=2 shiftwidth=2 et

View File

@ -69,8 +69,8 @@ check_single_file()
local file=$1 local file=$1
case $file in case $file in
*.spec) *.spec)
sed -i -e "s,Release:.*${ver_rel_old}$,Release: @RELEASE@," old/$file sed -i -e 's,^Release:.*$,Release: @RELEASE@,' old/$file
sed -i -e "s,Release:.*${ver_rel_new}$,Release: @RELEASE@," new/$file sed -i -e 's,^Release:.*$,Release: @RELEASE@,' new/$file
if ! cmp -s old/$file new/$file; then if ! cmp -s old/$file new/$file; then
echo "$file differs (spec file)" echo "$file differs (spec file)"
diff -u old/$file new/$file | head -n 20 diff -u old/$file new/$file | head -n 20