[misc] 03/03: has-only: single-shot tool for finding invalid build_path tags

Chris West faux-guest at moszumanska.debian.org
Sun Apr 16 17:58:05 UTC 2017


This is an automated email from the git hooks/post-receive script.

faux-guest pushed a commit to branch master
in repository misc.

commit eef4e72ab83387c3ab3da55015c930f470462a25
Author: Chris West (Faux) <git at goeswhere.com>
Date:   Sun Apr 16 18:55:46 2017 +0100

    has-only: single-shot tool for finding invalid build_path tags
---
 has-only.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 52 insertions(+), 3 deletions(-)

diff --git a/has-only.py b/has-only.py
index e370a97..0478c58 100755
--- a/has-only.py
+++ b/has-only.py
@@ -7,6 +7,7 @@ import re
 DO_FILE_PREFIX = '├── '
 DO_DIFF_PREFIX = re.compile('(?:│ )+([+-])(.*)')
 XXD_LINE = re.compile('[0-9a-f]{8}: (?:[0-9a-f]{4} ){8} (.{16})')
+XXD_END =  re.compile('[0-9a-f]{8}: [0-9a-f]{2}(?:[0-9a-f]{2}|  ) (?:[0-9a-f ]{4} ){7} (.{1,16})')
 
 def diff_parse(lines):
     file = None
@@ -39,20 +40,68 @@ def diff_parse(lines):
 
 def strip_xxd(lines):
     stripped = ''
-    for line in lines:
+    for no, line in enumerate(lines):
         ma = XXD_LINE.match(line)
         if not ma:
+            if no == len(lines) - 1:
+                end = XXD_END.match(line)
+                if end:
+                    stripped += end.group(1)
+                    break
             return '\n'.join(lines)
         stripped += ma.group(1)
 
     return stripped
 
+def process(f):
+    has = set()
+    hunks = diff_parse(f)
+    without_xxd = ((file, strip_xxd(bef), strip_xxd(aft)) for file, bef, aft in hunks)
+    for file, before, after in without_xxd:
+        has = set()
+
+        if file in {'file list', 'md5sums', 'Files', './control'}:
+            # TODO: confirm these are actually the special entries
+            continue
+
+        if '1st/' in before and '/2nd' in after:
+            has.add('build_path')
+
+        if 'pdftk {} output - uncompress' == file and '/ID [<' in before and '/ID [<' in after:
+            has.add('pdf')
+
+        if 'Build ID: ' in before and 'Build ID: ' in after:
+            has.add('build_id')
+
+        if 'readelf --wide --debug-dump=info {}' == file:
+            has.add('build_id')
+
+        if file.endswith('.rdb'):
+            has.add('rdb')
+
+        yield tuple(sorted(has))
+        #if not has:
+        #    raise Exception("unclassified: {}".format((file, before, after)))
+
+def warn(path, msg):
+    sys.stderr.write('{}: {}\n'.format(path, msg))
+
 
 def main():
     for path in sys.argv[1:]:
-        with open(path) as f:
-            print (path, list((file, strip_xxd(bef), strip_xxd(aft)) for file, bef, aft in diff_parse(f)))
+        try:
+            with open(path) as f:
+                problems = set(process(f))
+            if () in problems:
+                warn(path, 'unclassified problems')
+                continue
+
+            if 'build_path' not in (x for y in problems for x in y):
+                print(path)
 
+        except Exception as e:
+            print(path)
+            raise
 
 if '__main__' == __name__:
     main()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/misc.git



More information about the Reproducible-commits mailing list