diff --git a/build-compare.changes b/build-compare.changes index 68e6fff..78c5deb 100644 --- a/build-compare.changes +++ b/build-compare.changes @@ -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 diff --git a/build-compare.spec b/build-compare.spec index 60c4e0a..71be5b7 100644 --- a/build-compare.spec +++ b/build-compare.spec @@ -21,7 +21,7 @@ Summary: Build Result Compare Script License: GPL-2.0+ Group: Development/Tools/Building Url: https://github.com/openSUSE/build-compare -Version: 20180413T091103.4639e30 +Version: 20180528T152809.3cec12e Release: 0 Source1: COPYING Source2: same-build-result.sh diff --git a/pkg-diff.sh b/pkg-diff.sh index 680233d..5e5f53e 100644 --- a/pkg-diff.sh +++ b/pkg-diff.sh @@ -280,6 +280,9 @@ dfile=`mktemp` diff_two_files() { + local offset length + local po pn + if test ! -e old/$file; then echo "Missing in old package: $file" return 1 @@ -289,15 +292,25 @@ diff_two_files() return 1 fi - if cmp -s old/$file new/$file; then + if cmp -b old/$file new/$file > $dfile ; then return 0 fi + if ! test -s $dfile ; then + return 1 + fi - echo "$file differs ($ftype)" - hexdump -C old/$file > $file1 & - hexdump -C new/$file > $file2 & - wait - diff -u $file1 $file2 | $buildcompare_head + offset=`sed 's@^.*differ: byte @@;s@,.*@@' < $dfile` + echo "$file differs at offset '$offset' ($ftype)" + po=`mktemp --dry-run $TMPDIR/old.XXX` + pn=`mktemp --dry-run $TMPDIR/new.XXX` + 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 }