forked from pool/build-compare
- 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:
141
pkg-diff.sh
141
pkg-diff.sh
@@ -59,12 +59,8 @@ if test ! -f "$newpkg"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#usage unjar <file>
|
||||
function unjar()
|
||||
function findunjarbin
|
||||
{
|
||||
local file
|
||||
file=$1
|
||||
|
||||
if [[ $(type -p fastjar) ]]; then
|
||||
UNJAR=fastjar
|
||||
elif [[ $(type -p jar) ]]; then
|
||||
@@ -75,7 +71,15 @@ function unjar()
|
||||
echo "ERROR: jar, fastjar, or unzip is not installed (trying file $file)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
#usage unjar <file>
|
||||
function unjar()
|
||||
{
|
||||
local file
|
||||
file=$1
|
||||
|
||||
findunjarbin
|
||||
case $UNJAR in
|
||||
jar|fastjar)
|
||||
# echo jar -xf $file
|
||||
@@ -87,30 +91,20 @@ function unjar()
|
||||
esac
|
||||
}
|
||||
|
||||
# list files in directory
|
||||
# list files in given jar file
|
||||
#usage unjar_l <file>
|
||||
function unjar_l()
|
||||
{
|
||||
local file
|
||||
file=$1
|
||||
|
||||
if [[ $(type -p fastjar) ]]; then
|
||||
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
|
||||
|
||||
findunjarbin
|
||||
case $UNJAR in
|
||||
jar|fastjar)
|
||||
${UNJAR} -tf $file
|
||||
;;
|
||||
unzip)
|
||||
unzip -l $file
|
||||
unzip -Z -1 $file
|
||||
;;
|
||||
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}
|
||||
}
|
||||
|
||||
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() {
|
||||
# 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';"
|
||||
@@ -283,16 +267,16 @@ 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"
|
||||
return 1
|
||||
fi
|
||||
if test ! -e new/$file; then
|
||||
if test ! -e "new/$file"; then
|
||||
echo "Missing in new package: $file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if cmp -b old/$file new/$file > $dfile ; then
|
||||
if cmp -b "old/$file" "new/$file" > $dfile ; then
|
||||
return 0
|
||||
fi
|
||||
if ! test -s $dfile ; then
|
||||
@@ -307,8 +291,8 @@ diff_two_files()
|
||||
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 &
|
||||
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
|
||||
@@ -472,15 +456,15 @@ check_single_file()
|
||||
local ret=0
|
||||
|
||||
# If the two files are the same, return at once.
|
||||
if [ -f old/$file -a -f new/$file ]; then
|
||||
if cmp -s old/$file new/$file; then
|
||||
if [ -f "old/$file" -a -f "new/$file" ]; then
|
||||
if cmp -s "old/$file" "new/$file"; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
case $file in
|
||||
case "$file" in
|
||||
*.spec)
|
||||
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:.*$release1,Release: @RELEASE@," "old/$file"
|
||||
sed -i -e "s,Release:.*$release2,Release: @RELEASE@," "new/$file"
|
||||
;;
|
||||
*.exe.mdb|*.dll.mdb)
|
||||
# Just debug information, we can skip them
|
||||
@@ -488,16 +472,16 @@ check_single_file()
|
||||
return 0
|
||||
;;
|
||||
*.a)
|
||||
flist=`ar t new/$file`
|
||||
flist=`ar t "new/$file"`
|
||||
pwd=$PWD
|
||||
fdir=`dirname $file`
|
||||
cd old/$fdir
|
||||
ar x `basename $file`
|
||||
cd $pwd/new/$fdir
|
||||
ar x `basename $file`
|
||||
cd $pwd
|
||||
fdir=`dirname "$file"`
|
||||
cd "old/$fdir"
|
||||
ar x `basename "$file"`
|
||||
cd "$pwd/new/$fdir"
|
||||
ar x `basename "$file"`
|
||||
cd "$pwd"
|
||||
for f in $flist; do
|
||||
if ! check_single_file $fdir/$f; then
|
||||
if ! check_single_file "$fdir/$f"; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
@@ -506,51 +490,51 @@ check_single_file()
|
||||
*.cpio)
|
||||
flist=`cpio --quiet --list --force-local < "new/$file" | $sort`
|
||||
pwd=$PWD
|
||||
fdir=$file.extract.$PPID.$$
|
||||
mkdir old/$fdir new/$fdir
|
||||
cd old/$fdir
|
||||
fdir="$file.extract.$PPID.$$"
|
||||
mkdir "old/$fdir" "new/$fdir"
|
||||
cd "old/$fdir"
|
||||
cpio --quiet --extract --force-local < "../${file##*/}"
|
||||
cd $pwd/new/$fdir
|
||||
cd "$pwd/new/$fdir"
|
||||
cpio --quiet --extract --force-local < "../${file##*/}"
|
||||
cd $pwd
|
||||
cd "$pwd"
|
||||
for f in $flist; do
|
||||
if ! check_single_file $fdir/$f; then
|
||||
if ! check_single_file "$fdir/$f"; then
|
||||
ret=1
|
||||
if test -z "$check_all"; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
rm -rf old/$fdir new/$fdir
|
||||
rm -rf "old/$fdir" "new/$fdir"
|
||||
return $ret
|
||||
;;
|
||||
*.squashfs)
|
||||
flist=`unsquashfs -no-progress -ls -dest '' "new/$file" | grep -Ev '^(Parallel unsquashfs:|[0-9]+ inodes )' | $sort`
|
||||
fdir=$file.extract.$PPID.$$
|
||||
unsquashfs -no-progress -dest old/$fdir "old/$file"
|
||||
unsquashfs -no-progress -dest new/$fdir "new/$file"
|
||||
fdir="$file.extract.$PPID.$$"
|
||||
unsquashfs -no-progress -dest "old/$fdir" "old/$file"
|
||||
unsquashfs -no-progress -dest "new/$fdir" "new/$file"
|
||||
for f in $flist; do
|
||||
if ! check_single_file $fdir/$f; then
|
||||
if ! check_single_file "$fdir/$f"; then
|
||||
ret=1
|
||||
if test -z "$check_all"; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
rm -rf old/$fdir new/$fdir
|
||||
rm -rf "old/$fdir" "new/$fdir"
|
||||
return $ret
|
||||
;;
|
||||
*.tar|*.tar.bz2|*.tar.gz|*.tgz|*.tbz2)
|
||||
flist=`tar tf new/$file`
|
||||
flist=`tar tf "new/$file"`
|
||||
pwd=$PWD
|
||||
fdir=`dirname $file`
|
||||
cd old/$fdir
|
||||
tar xf `basename $file`
|
||||
cd $pwd/new/$fdir
|
||||
tar xf `basename $file`
|
||||
cd $pwd
|
||||
fdir=`dirname "$file"`
|
||||
cd "old/$fdir"
|
||||
tar xf `basename "$file"`
|
||||
cd "$pwd/new/$fdir"
|
||||
tar xf `basename "$file"`
|
||||
cd "$pwd"
|
||||
for f in $flist; do
|
||||
if ! check_single_file $fdir/$f; then
|
||||
if ! check_single_file "$fdir/$f"; then
|
||||
ret=1
|
||||
if test -z "$check_all"; then
|
||||
break
|
||||
@@ -564,7 +548,6 @@ check_single_file()
|
||||
(
|
||||
cd $dir
|
||||
unjar_l ./$file | $sort > flist
|
||||
filter_zip_flist flist
|
||||
)
|
||||
done
|
||||
if ! cmp -s old/flist new/flist; then
|
||||
@@ -572,7 +555,7 @@ check_single_file()
|
||||
diff -u old/flist new/flist
|
||||
return 1
|
||||
fi
|
||||
flist=`grep date new/flist | sed -e 's,.* date ,,'`
|
||||
flist=`cat new/flist`
|
||||
pwd=$PWD
|
||||
fdir=`dirname $file`
|
||||
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 (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="dc.created" content="2019-02-07">
|
||||
# <meta name="date" content="2015-02-03">
|
||||
# </head>
|
||||
sed -i -e '
|
||||
@@ -687,6 +671,8 @@ check_single_file()
|
||||
t next
|
||||
s/^\(<!-- Generated by javadoc\) \(on ... ... .. ..:..:.. \(GMT\|UTC\) ....\) \(-->\)/\1 some-date-removed-by-build-compare \3/
|
||||
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">/
|
||||
b next
|
||||
}
|
||||
@@ -804,16 +790,16 @@ check_single_file()
|
||||
;;
|
||||
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
|
||||
PE32\ executable*Mono\/\.Net\ assembly*)
|
||||
echo "PE32 Mono/.Net assembly: $file"
|
||||
if [ -x /usr/bin/monodis ] ; then
|
||||
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}
|
||||
if ! cmp -s ${file1} ${file2}; then
|
||||
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}
|
||||
if ! cmp -s "${file1}" "${file2}"; then
|
||||
echo "$file differs ($ftype)"
|
||||
diff --speed-large-files -u ${file1} ${file2}
|
||||
diff --speed-large-files -u "${file1}" "${file2}"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
@@ -867,9 +853,9 @@ check_single_file()
|
||||
return 1
|
||||
;;
|
||||
*ASCII*|*text*)
|
||||
if ! cmp -s old/$file new/$file; then
|
||||
if ! cmp -s "old/$file" "new/$file"; then
|
||||
echo "$file differs ($ftype)"
|
||||
diff -u old/$file new/$file | $buildcompare_head
|
||||
diff -u "old/$file" "new/$file" | $buildcompare_head
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
@@ -946,8 +932,9 @@ fi
|
||||
|
||||
# preserve cmp_rpm_meta result for check_all runs
|
||||
ret=$RES
|
||||
for file in $files; do
|
||||
if ! check_single_file $file; then
|
||||
readarray -t filesarray <<<"$files"
|
||||
for file in "${filesarray[@]}"; do
|
||||
if ! check_single_file "$file"; then
|
||||
ret=1
|
||||
if test -z "$check_all"; then
|
||||
break
|
||||
|
Reference in New Issue
Block a user