[PATCH] Introduce os-toc-diff.py -- helps compare the output of osbuilder

martin.langhoff at gmail.com martin.langhoff at gmail.com
Fri Mar 18 16:03:00 EDT 2011


From: Martin Langhoff <martin at laptop.org>

Question: Is a new osbuilder still building the exact same build?

os-toc-diff.py original/os860.toc build/output/osNN.toc > results.diff
---
 os-toc-diff.py |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)
 create mode 100755 os-toc-diff.py

diff --git a/os-toc-diff.py b/os-toc-diff.py
new file mode 100755
index 0000000..93f2c39
--- /dev/null
+++ b/os-toc-diff.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+#
+# Compare OS versions based on the .toc files
+#
+# Usage:
+#    os-toc-diff os852.toc os860.toc
+#
+# Copyright (C) 2009, One Laptop per Child
+# License GPLv2+
+# Author: Martin Langhoff <martin at laptop.org>
+#
+# FIXME: Flatten and data structure to something more readable
+#       like
+# drwxr-xr-x. 1 martin martin /usr/lib 92a875c5b...
+#
+import os, sys
+import tempfile
+import subprocess
+import shutil
+import json
+import pprint
+
+tmpdir = tempfile.mkdtemp()
+
+if len(sys.argv) != 3:
+    sys.stderr.write("Incorrect number of arguments!")
+    sys.exit(1)
+
+tocs = [ sys.argv[1], sys.argv[2] ]
+
+for toc in tocs:
+    print "Preparing " + toc
+    data = json.load(file(toc))
+    f = file(os.path.join(tmpdir, os.path.basename(toc)), 'w')
+    pp = pprint.PrettyPrinter(indent=1, stream=f)
+    pp.pprint(data)
+
+subprocess.Popen(['diff', '-u',
+                  os.path.join(tmpdir, os.path.basename(tocs[0])),
+                  os.path.join(tmpdir, os.path.basename(tocs[1]))
+                  ], stdout=sys.stdout).communicate()
+
+# cleanup
+shutil.rmtree(tmpdir)
+
+
-- 
1.7.3.4




More information about the Devel mailing list