[Reproducible-commits] [misc] 01/01: Make bin/newly-reproducible nicer to play with
Ximin Luo
infinity0 at debian.org
Mon Aug 8 18:13:19 UTC 2016
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository misc.
commit c2030c4521864081fde6025a65e6cebd83438232
Author: Ximin Luo <infinity0 at debian.org>
Date: Mon Aug 8 20:13:10 2016 +0200
Make bin/newly-reproducible nicer to play with
---
reports/README | 10 ++--
reports/bin/history | 12 +++--
reports/bin/newly-reproducible | 105 +++++++++++++++++++++++++++++++++++++----
3 files changed, 111 insertions(+), 16 deletions(-)
diff --git a/reports/README b/reports/README
index 657dfd3..e468e8c 100644
--- a/reports/README
+++ b/reports/README
@@ -19,7 +19,7 @@ Process
$ bin/get-latest-data
- If you are not a Debian developer, ask one to run
+ If you are not a Debian developer, ask one to run
bin/sync-to-alioth which will sync the mailboxes to alioth.
(bin/get-latest-data will still be able to get most of the data for
you, so you should still run it too…)
@@ -37,11 +37,15 @@ Process
might give some false positive: packages might have been
reproducible before, broken by a toolchain upload later fixed.
- One look at the history of the tests by typing:
+ Interactive mode:
+
+ $ bin/newly-reproducible --verify
+
+ Look at each package individually:
$ bin/history ghc # defaults to unstable
$ bin/history ghc experimental
- $ FULL=yes bin/history ghc # more details
+ $ bin/history -x ghc # more details
$ bin/history -c ghc # also show changelogs
2. Look at all relevant bug reports that have been modified this week.
diff --git a/reports/bin/history b/reports/bin/history
index 6506791..80684e3 100755
--- a/reports/bin/history
+++ b/reports/bin/history
@@ -5,12 +5,14 @@
# © 2015 Mattia Rizzolo <mattia at mapreri.org>
# Licensed under WTFPL — http://www.wtfpl.net/txt/copying/
-# Set `FULL=yes` in the environment to get full output.
-
changelog=false
less=false
-while getopts 'lc' opt; do
+full=false
+while getopts 'xlc' opt; do
case $opt in
+ x)
+ full=true
+ ;;
c)
changelog=true
less=true
@@ -43,7 +45,7 @@ SQLITE_OPTS="${SQLITE_OPTS:--column -header}"
main() {
-if [ "$FULL" ]; then
+if $full; then
QUERY="SELECT * FROM stats_build WHERE name='$PACKAGE' $SUITE ORDER BY build_date"
WIDTH="5 0 0 0 0 15 0 0 13"
else
@@ -52,7 +54,7 @@ else
fi
sqlite3 $SQLITE_OPTS -cmd ".width $WIDTH" "$DB" "$QUERY"
-test "$FULL" || exit 0
+$full || exit 0
printf "\n\n@@@@@ RESULTS @@@@@@\n"
QUERY="SELECT s.id as 'pkg id', s.name, s.version, s.suite, s.architecture as arch, s.notify_maintainer as notify, r.version as 'tested version', r.status, r.build_date, r.build_duration as duration, r.builder
diff --git a/reports/bin/newly-reproducible b/reports/bin/newly-reproducible
index 2f0673c..143e075 100755
--- a/reports/bin/newly-reproducible
+++ b/reports/bin/newly-reproducible
@@ -1,19 +1,93 @@
-#!/usr/bin/python3
+#!/usr/bin/python3 -u
# newly-reproducible: find packages that became reproducible in the past week
#
# Copyright © 2015 Lunar <lunar at debian.org>
+# Copyright © 2016 Ximin Luo <infinity0 at debian.org>
# Licensed under WTFPL — http://www.wtfpl.net/txt/copying/
+import argparse
import os
import re
+import subprocess
import sys
import sqlite3
+import termios
import time
-import getopt
+import tty
-query_add = ''
-if len(sys.argv) > 1:
- query_add = "AND name IN ({})".format(', '.join(map(repr, sys.argv[1:])))
+def read1charmode(fd):
+ mode = termios.tcgetattr(fd)
+ mode[tty.LFLAG] = mode[tty.LFLAG] & ~(tty.ICANON)
+ mode[tty.CC][tty.VMIN] = 1
+ mode[tty.CC][tty.VTIME] = 0
+ return mode
+
+def output(name, details):
+ detail_string = "; ".join("on %s %s" % (", ".join(v), k) for k, v in details.items())
+ print("[[!pkg %s]] is reproducible %s." % (name, detail_string))
+
+def verify(name, details, fd=sys.stdin, nextname=None, prevname=None):
+ oldattr = termios.tcgetattr(fd)
+ newattr = read1charmode(fd)
+ try:
+ termios.tcsetattr(fd, termios.TCSANOW, newattr)
+ full = []
+ suite = []
+ helptext = """
+h Show this help
+v View build logs
+c View Debian changelog for the latest version
+x Show/hide full details for "view build logs"
+t Filter "view build logs" to testing
+u Filter "view build logs" to testing
+e Filter "view build logs" to testing
+. Go to next item (%s)
+, Go to prev item (%s)
+Ctrl-C Quit
+Enter Go to next item or quit if last item
+""" % (nextname, prevname)
+ while True:
+ output(name, details)
+ print("What do you want to do? [h]elp or [vcftue.,] (will %s build log details%s) " % (
+ "show" if full else "hide",
+ ", filtered to %s" % suite[0] if suite else ""),
+ end='', flush=True)
+ c = fd.read(1)
+ print()
+ if c == "\n":
+ return None
+ elif c == ".":
+ return 1
+ elif c == ",":
+ return -1
+ elif c == "h":
+ print(helptext)
+ elif c == "v":
+ subprocess.check_call(["bin/history", "-l"] + full + [name] + suite)
+ elif c == "c":
+ subprocess.check_call(["less", os.path.join(os.path.dirname(db_path), "changelogs", name)])
+ elif c == "x":
+ full = ["-x"] if not full else []
+ elif c in "tue":
+ selected = dict((k[0], k) for k in ["testing", "unstable", "experimental"])[c]
+ suite = [selected] if suite != [selected] else []
+ else:
+ print(helptext)
+ return 1
+ finally:
+ termios.tcsetattr(fd, termios.TCSANOW, oldattr)
+
+parser = argparse.ArgumentParser(
+ description='find packages that became reproducible in the past week')
+parser.add_argument(
+ '--verify', action="store_true", default=False,
+ help='enter an interactive REPL to examine each package in more detail')
+parser.add_argument(
+ 'package', nargs="*",
+ help='only select these packages (if they became reproducible)')
+args = parser.parse_args()
+
+query_add = "AND name IN ({})".format(', '.join(map(repr, args.package))) if args.package else ""
db_path = os.environ.get('REPRODUCIBLE_DB', 'latest/reproducible.db')
variables_path = os.path.join(os.path.dirname(db_path), 'variables')
@@ -76,6 +150,21 @@ for package_id in sorted(now_reproducible.keys()):
name, architecture = package_id.split('/')
now_reproducible_by_arch.setdefault(name, {}).setdefault(now_reproducible[package_id], []).append(architecture)
-for name, details in sorted(now_reproducible_by_arch.items()):
- detail_string = "; ".join("on %s %s" % (", ".join(v), k) for k, v in details.items())
- print("[[!pkg %s]] is reproducible %s." % (name, detail_string))
+all_details = sorted(now_reproducible_by_arch.items())
+if args.verify:
+ i = 0
+ n = len(all_details)
+ while i < n:
+ name, details = all_details[i]
+ nextname = all_details[(i-1)%n][0]
+ prevname = all_details[(i+1)%n][0]
+ chg = verify(name, details, sys.stdin, nextname, prevname)
+ if chg is None:
+ if i == len(all_details) - 1:
+ break
+ else:
+ chg = 1
+ i = (i+chg)%n
+else:
+ for name, details in all_details:
+ output(name, details)
--
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