[Reproducible-commits] [misc] 01/03: reports: newly-reproducible: automatically read "week" from variables file

Ximin Luo infinity0 at debian.org
Tue May 17 14:08:49 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 7f164bb7f6eac2f516dd30a4c999961a75e2dc7b
Author: Ximin Luo <infinity0 at debian.org>
Date:   Tue May 17 14:49:52 2016 +0200

    reports: newly-reproducible: automatically read "week" from variables file
---
 reports/README                 |  4 ++--
 reports/bin/get-latest-data    |  2 +-
 reports/bin/newly-reproducible | 28 +++++++++++++++++-----------
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/reports/README b/reports/README
index 597d2b9..d639840 100644
--- a/reports/README
+++ b/reports/README
@@ -22,9 +22,9 @@ Process
 1. Look at packages that became reproducible in that week.
 
    There's a script that will use the history in the
-   reproducible.debian.net database to figure this out. Usage:
+   reproducible.debian.net database to figure this out.
 
-       $ bin/newly-reproducible -w 77	# for week 77 of the reports…
+       $ bin/newly-reproducible
 
    The output needs to be manually verified. Some packages will
    be fixed by a change in the toolchain and be marked as fixed in
diff --git a/reports/bin/get-latest-data b/reports/bin/get-latest-data
index a90a684..6eaa7ea 100755
--- a/reports/bin/get-latest-data
+++ b/reports/bin/get-latest-data
@@ -55,7 +55,7 @@ echo >&2 "- changelogs of newly-reproducible packages"
 mkdir -p changelogs
 rm -f changelogs-failed && touch changelogs-failed
 
-for url in $("$scriptdir/newly-reproducible" -w "$week" | sed -n -e 's,.*<,,;s,>.*,,p' | sort -u); do
+for url in $("$scriptdir/newly-reproducible" | sed -n -e 's,.*<,,;s,>.*,,p' | sort -u); do
 	p=${url%/*}; p=${p##*/};
 	echo -n "  * $p"
 	$TORSOCKS wget -q -O changelogs/$p "$url" || ( echo $url >> changelogs-failed ; echo -n " failed." )
diff --git a/reports/bin/newly-reproducible b/reports/bin/newly-reproducible
index 74a64d1..2f0673c 100755
--- a/reports/bin/newly-reproducible
+++ b/reports/bin/newly-reproducible
@@ -11,20 +11,26 @@ import sqlite3
 import time
 import getopt
 
-week_1 = 1430611200 # May 3 2015, 00:00 UTC, Sunday
-
-opts, args = getopt.getopt(sys.argv[1:], 'w:')
 query_add = ''
-if len(args) > 0:
-    query_add = "AND name IN ({})".format(', '.join(map(repr, args)))
+if len(sys.argv) > 1:
+    query_add = "AND name IN ({})".format(', '.join(map(repr, sys.argv[1:])))
+
+db_path = os.environ.get('REPRODUCIBLE_DB', 'latest/reproducible.db')
+variables_path = os.path.join(os.path.dirname(db_path), 'variables')
+
+if os.path.isfile(variables_path):
+    with open(variables_path) as fp:
+        for line in fp.readlines():
+            matches = re.match("export (.*?)=(.*)\n", line)
+            if matches:
+                os.environ[matches.group(1)] = matches.group(2)
+
+if "RB_REPORT_WEEK_START" not in os.environ or "RB_REPORT_WEEK_END" not in os.environ:
+    raise ValueError("RB_REPORT_WEEK_{START,END} not set")
 
-if len(opts) > 0:
-    query_date_end = week_1 + (int(opts[0][1]) - 1)*7*24*3600
-else:
-    query_date_end = int(time.time())
-query_date_begin = query_date_end - 7*24*3600
+query_date_begin = int(os.environ["RB_REPORT_WEEK_START"])
+query_date_end = int(os.environ["RB_REPORT_WEEK_END"])
 
-db_path = os.environ.get('REPRODUCIBLE_DB', 'reproducible.db')
 conn = sqlite3.connect(db_path)
 
 c = conn.cursor()

-- 
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