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

martin.langhoff at gmail.com martin.langhoff at gmail.com
Mon Mar 21 16:19:40 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
---
This version uses bitfrost utils to walk the datastructure, yielding
a more readable output.

Still investigating why 10.1.3 rebuilds have so much delta. The tip of
v1.3 builds it with perfectly matching packages.txt, but there's an important
number of binaries and SOs that don't match.

---
 os-toc-diff.py |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 61 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..cf6ad35
--- /dev/null
+++ b/os-toc-diff.py
@@ -0,0 +1,61 @@
+#!/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>
+#
+#
+import os, sys
+import tempfile
+import subprocess
+import shutil
+from bitfrost.contents.utils import UnifiedContents
+
+tmpdir = tempfile.mkdtemp()
+
+if len(sys.argv) != 3:
+    sys.stderr.write("Incorrect number of arguments!")
+    sys.exit(1)
+
+def pretty_print_content_rec(c, f, path):
+    dirents = c.get_dirobject_pair(path)[1][2][1]
+    for fn in dirents.keys():
+        dent = dirents[fn]
+        fpath = os.path.join(path, fn)
+        if 'dl' in dent:
+            f.write('%s dir %s %s %o ' % (fpath, dent['u'], dent['g'], dent['m']))
+            f.write("\n")
+            pretty_print_content_rec(c, f, os.path.join(path, fn))
+        else:
+            f.write('%s %s %s %o ' % (fpath, dent['u'], dent['g'], dent['m']))
+            if 'l' in dent:
+                f.write('symlink ' + dent['l'])
+            elif 'd' in dent:
+                f.write('devnode %s' % dent['d'])
+            else: # file
+                f.write(dent['h'][0])
+            f.write("\n")
+
+tocs = [ sys.argv[1], sys.argv[2] ]
+
+for toc in tocs:
+    print "Preparing " + toc
+    f = file(os.path.join(tmpdir, os.path.basename(toc)), 'w')
+    print os.path.join(tmpdir, os.path.basename(toc))
+    c = UnifiedContents(toc)
+    pretty_print_content_rec(c, f, '')
+
+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