[Reproducible-commits] [misc] 01/01: add clean-notes script
Mattia Rizzolo
mapreri-guest at moszumanska.debian.org
Sun Jan 4 12:33:25 UTC 2015
This is an automated email from the git hooks/post-receive script.
mapreri-guest pushed a commit to branch master
in repository misc.
commit a19375733b2c0cc94aa824e33fd1c288d903f2f1
Author: Mattia Rizzolo <mattia at mapreri.org>
Date: Sun Jan 4 13:32:39 2015 +0100
add clean-notes script
---
README | 12 ++++++++
clean-notes | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 112 insertions(+)
diff --git a/README b/README
index 87c903a..95b5efa 100644
--- a/README
+++ b/README
@@ -16,3 +16,15 @@ Usage:
The current output is pretty crude — a collection of diff outputs — but it has
proven really helpful so far.
+
+clean-notes: sort and cleanup the packages' notes
+-------------------------------------------------
+
+`clean-notes` compares the reproducible.json from jenkins continuos building and
+the packages.yml file in the notes.git repository to find out old entries (so,
+packages that have been fixed in the meantime) and remove them from the file.
+It also help keeping the file sorted by package name.
+
+Usage:
+
+ clean-notes
diff --git a/clean-notes b/clean-notes
new file mode 100755
index 0000000..94a0032
--- /dev/null
+++ b/clean-notes
@@ -0,0 +1,100 @@
+#!/usr/bin/python3
+
+# clean-notes: sort and clean the notes stored in notes.git
+# Copyright © 2015 Mattia Rizzolo <mattia at mapreri.org>
+# Licensed under WTFPL — http://www.wtfpl.net/txt/copying/
+#
+# Depends: python3 python3-apt python3-json python3-yaml python3-requests
+
+import apt
+import sys
+import json
+import yaml
+import apt_pkg
+import requests
+
+reproducible_json = 'https://reproducible.debian.net/userContent/reproducible.json'
+# [{package: xxx, suite: sid, version: 0.0.0, status: reproducible}, {...}]
+
+notes_yaml = 'packages.yml'
+# {package_name: {things..} }
+
+def warning(*objs):
+ print("WARNING: ", *objs, file=sys.stderr)
+
+def load_reproducible_status():
+ try:
+ with open('reproducible.json') as fd:
+ r = json.load(fd)
+ except FileNotFoundError:
+ r = requests.get(reproducible_json, verify=False)
+ r = r.json()
+ return r
+
+def load_notes():
+ with open(notes_yaml) as fd:
+ notes = yaml.load(fd)
+ return notes
+
+def find_old_notes(testedpkgs, notes):
+ toremove = []
+ for pkg in sorted(notes, key=lambda x: str(x)):
+ if 'version' not in notes[pkg]:
+ warning("There is no version set for the package " + pkg)
+ continue
+ for item in testedpkgs:
+ if item['package'] == pkg and \
+ item['version'] == notes[pkg]['version'] and \
+ item['status'] == 'reproducible':
+ warning("The package " + pkg + " has a note for the version "
+ + item['version'] + " but that version is reproducible")
+ if item['package'] == pkg and \
+ item['status'] == 'reproducible' and \
+ apt_pkg.version_compare(str(item['version']),
+ str(notes[pkg]['version'])) > 0:
+ print("The package " + pkg + " it's now reproducible but still listed in the notes")
+ toremove.append(pkg)
+ if item['package'] == pkg and \
+ apt_pkg.version_compare(str(item['version']),
+ str(notes[pkg]['version'])) > 0:
+ print("The package " + pkg + " has a new tested version")
+ return toremove
+
+def cleanup_notes(notes, toremove):
+ for pkg in toremove:
+ del notes[pkg]
+ return notes
+
+def write_out(notes):
+ out = ''
+ for pkg, values in sorted(notes.items(), key=lambda x: str(x)):
+ if pkg[0:2] == '0x': # otherwise something will convert 0xffff to 65535
+ out += ("!!str " + str(pkg) + ":\n")
+ else:
+ out += (str(pkg) + ":\n")
+ try:
+ out += (" version: " + str(values['version']) + "\n")
+ except KeyError:
+ warning("There is no version set for the package " + pkg + ".")
+ if 'comments' in values:
+ out += (" comments: |\n")
+ for line in values['comments'].split('\n'):
+ out += (" " + line + "\n")
+ if 'issues' in values:
+ out += (" issues:\n")
+ for issue in values['issues']:
+ out += (" - " + issue + "\n")
+ if 'bugs' in values:
+ out += (" bugs:\n")
+ for bug in values['bugs']:
+ out += (" - " + str(bug) + "\n")
+ with open('notes.yml', 'w') as fd:
+ fd.write(out)
+
+if __name__ == '__main__':
+ testedpkgs = load_reproducible_status()
+ notes = load_notes()
+ toremove = find_old_notes(testedpkgs, notes)
+ notes = cleanup_notes(notes, toremove)
+ write_out(notes)
+
--
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