]> git.donarmstrong.com Git - bin.git/commitdiff
use git if it exists
authorDon Armstrong <don@donarmstrong.com>
Wed, 12 Dec 2012 01:23:27 +0000 (01:23 +0000)
committerDon Armstrong <don@donarmstrong.com>
Wed, 12 Dec 2012 01:23:27 +0000 (01:23 +0000)
deepdebdiff [new file with mode: 0755]

diff --git a/deepdebdiff b/deepdebdiff
new file mode 100755 (executable)
index 0000000..520b0e0
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# Copyright © 2011, 2012 Jakub Wilk <jwilk@debian.org>
+
+# Redistribution and use in source and compiled forms, with or without
+# modification, are permitted under any circumstances. No warranty.
+
+if [ $# -ne 2 ]
+then
+    printf 'Usage: %s <deb1> <deb2>\n' "$0"
+    exit 1
+fi
+
+set -e
+
+deb1="$1"
+deb2="$2"
+base1=$(basename "$deb1" .deb)
+base2=$(basename "$deb2" .deb)
+tmpdir=$(mktemp -t -d)
+if which git >/dev/null 2>&1; then
+    git init "$tmpdir/repo" >/dev/null 2>&1
+    (cd "$tmpdir/repo";
+       touch emptyfile;
+       git add emptyfile;
+       git commit -m'initial commit' >/dev/null 2>&1;
+       git checkout -b "$base1"  >/dev/null 2>&1;
+    );
+    dpkg-deb --raw-extract "$deb1" "$tmpdir/repo"
+    (cd "$tmpdir/repo";
+       git add * >/dev/null 2>&1;
+       git rm emptyfile >/dev/null 2>&1;
+       git commit -m"add $base1" >/dev/null 2>&1;
+       git checkout master >/dev/null 2>&1;
+       git checkout -b "$base2" >/dev/null 2>&1;
+    );
+    dpkg-deb --raw-extract "$deb2" "$tmpdir/repo"
+    (cd "$tmpdir/repo";
+       git add * >/dev/null 2>&1;
+       git rm emptyfile >/dev/null 2>&1;
+       git commit -m"add $base2" >/dev/null 2>&1;
+       git diff "$base1" "$base2" --;
+    );
+    rm -rf "$tmpdir";    
+else
+    mkdir -p "$tmpdir/a/$base1/"
+    dpkg-deb --raw-extract "$deb1" "$tmpdir/a/$base1/"
+    mkdir -p "$tmpdir/b/$base2/"
+    dpkg-deb --raw-extract "$deb2" "$tmpdir/b/$base2/"
+    cd "$tmpdir"
+    diff -urN "a/$base1/" "b/$base2/"
+    cd /
+    rm -rf "$tmpdir"
+fi;
+
+# vim:ts=4 sw=4 et