[Reproducible-builds] [misc] 01/01: Import current diffp
Jérémy Bobbio
lunar at alioth.debian.org
Tue Sep 10 08:43:57 UTC 2013
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository misc.
commit 6b4637a78ba5cf7d2c4e061aca9a3e65a74a7c24
Author: Jérémy Bobbio <lunar at debian.org>
Date: Tue Sep 10 10:43:46 2013 +0200
Import current diffp
---
README | 18 ++++++++++++
diffp | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 118 insertions(+)
diff --git a/README b/README
new file mode 100644
index 0000000..87c903a
--- /dev/null
+++ b/README
@@ -0,0 +1,18 @@
+Misc. collection of scripts for reproducible builds in Debian
+=============================================================
+
+See <https://wiki.debian.org/ReproducibleBuilds> to know more about the
+project.
+
+diffp: compare two package builds
+---------------------------------
+
+`diffp` was written to be able to quickly spot and investigate differences
+between the binary packages produced by two different builds.
+
+Usage:
+
+ diffp r1/hello_2.8-4_amd64.changes r2/hello_2.8-4_amd64
+
+The current output is pretty crude — a collection of diff outputs — but it has
+proven really helpful so far.
diff --git a/diffp b/diffp
new file mode 100755
index 0000000..beafc53
--- /dev/null
+++ b/diffp
@@ -0,0 +1,100 @@
+#!/bin/bash
+# diffp: compare two package builds
+# Copyright © 2013 Lunar <lunar at debian.org>
+# Licensed under WTFPL — http://www.wtfpl.net/txt/copying/
+#
+# Depends: bash, binutils, unzip
+
+CHANGES_A="$1"
+CHANGES_B="$2"
+
+trim_diff() {
+ grep -Ev '^(@@ |--- |\+\+\+ )'
+}
+
+get_ops() {
+ local file="$1"
+
+ case "$file" in
+ *.so|*.so.[0-9]*)
+ echo "readelf -a FILE"
+ echo "readelf -w FILE"
+ echo "objdump -d FILE"
+ ;;
+ *.a)
+ echo "ar tv FILE"
+ ;;
+ *.zip|*.jar)
+ echo "unzip -lv FILE"
+ ;;
+ *.gz)
+ echo "file FILE"
+ echo "zcat FILE"
+ ;;
+ esac
+}
+
+diffc() {
+ local diff
+
+ diff="$(diff -u0 <(echo "$@" | sed -e "s,PACKAGE,$PACKAGE_A," | sh) \
+ <(echo "$@" | sed -e "s,PACKAGE,$PACKAGE_B," | sh))"
+ [ "$diff" ] || return 0
+ echo "$diff" | trim_diff
+ return 1
+}
+
+paste <(dcmd "$CHANGES_A" | sort | grep '\.deb$') <(dcmd "$CHANGES_B" | sort | grep '\.deb$') | while read PACKAGE_A PACKAGE_B; do
+ PACKAGE="$(basename "$PACKAGE_A")"
+ if [ "$PACKAGE" != "$(basename "$PACKAGE_B")" ]; then
+ echo "$PACKAGE_A and $PACKAGE_B does not match. Something is wrong."
+ exit 1
+ fi
+ echo "***** $PACKAGE"
+
+ diffc "sha1sum < PACKAGE | sed -e 's,-$,$PACKAGE,'" && continue
+
+ diffc 'ar tv PACKAGE' && continue
+
+ MISMATCH=
+ for file in debian-binary control.tar.gz data.tar.xz; do
+ if diffc "ar p PACKAGE $file | sha1sum | sed -e s/-$/$file/"; then
+ MISMATCH=1
+ fi
+ done
+ [ "$MISMATCH" ] || continue
+
+ echo "===== control.tar.gz"
+
+ diffc 'ar p PACKAGE control.tar.gz | tar -ztvf -'
+ ar p $PACKAGE_A control.tar.gz | tar -zvtf - | grep '^-' | while read flags user size date time file; do
+ echo "----- $file"
+ diffc "ar p PACKAGE control.tar.gz | tar -zxOf - $file"
+ done
+
+ echo "===== data.tar.xz"
+ if ar p "$PACKAGE_A" control.tar.gz | tar -ztf - ./md5sums; then
+ FILES="$(diffc "ar p PACKAGE control.tar.gz | tar -zxOf - ./md5sums" | awk '/^-/ { print "./" $2 }')"
+ else
+ FILES="$(ar p $PACKAGE_A data.tar.xz | tar -Jvtf - | awk '/^-/ { print $6 }')"
+ fi
+ diffc 'ar p PACKAGE data.tar.xz | tar -Jtvf -'
+ echo "$FILES" | while read file; do
+ echo "----- $file"
+ diffc "ar p PACKAGE data.tar.xz | tar -JxOf - $file" |
+ sed -e "s,Binary files [^ ]* and [^ ]* differ,Binary file $file differ,"
+
+ OPS="$(get_ops "$file")"
+ [ "$OPS" ] || continue
+
+ TMP_A=$(mktemp)
+ TMP_B=$(mktemp)
+ ar p $PACKAGE_A data.tar.xz | tar -JxOf - $file > "$TMP_A"
+ ar p $PACKAGE_B data.tar.xz | tar -JxOf - $file > "$TMP_B"
+ echo "$OPS" | while read op; do
+ diff -u0 <(echo "$op" | sed -e "s,FILE,$TMP_A," | sh | sed -e "s,$TMP_A,$file,g") \
+ <(echo "$op" | sed -e "s,FILE,$TMP_B," | sh | sed -e "s,$TMP_B,$file,g") | trim_diff
+ done
+ rm -f "$TMP_A" "$TMP_B"
+ done
+done
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/misc.git
More information about the Reproducible-builds
mailing list