- Avoid large temporary files from hexdump output and avoid

diff(1) runing OOM by using a fifo (issue#24)

OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/build-compare?expand=0&rev=248
This commit is contained in:
Olaf Hering 2018-05-28 13:38:08 +00:00 committed by Git OBS Bridge
parent 1fe1bd2bc8
commit 159d089c59
3 changed files with 26 additions and 7 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
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 Fri Apr 13 07:10:30 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: 20180413T091103.4639e30 Version: 20180528T152809.3cec12e
Release: 0 Release: 0
Source1: COPYING Source1: COPYING
Source2: same-build-result.sh Source2: same-build-result.sh

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 -l $length old/$file > $po &
hexdump -C -s $offset -l $length new/$file > $pn &
diff -u $po $pn | $buildcompare_head
rm -f $po $pn
return 1 return 1
} }