commit: e2bca7ae46a92bd68f9335ac8b809364ff7f4814
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 11:26:24 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Wed Jun 24 12:13:26 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=e2bca7ae
scripts/gen_archlist: Move dev style configuration to argparse
This commit actually breaks the script since some functions do not have
proper arguments to handle configuration from main entry-point.
scripts/gen_archlist.py | 71 ++++++++++++++++++++++---------------------------
1 file changed, 32 insertions(+), 39 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index e41b20d..1a57fe2 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -23,6 +23,7 @@
from __future__ import division
+import argparse
import os
import sys
@@ -50,36 +51,19 @@ EXTREME_DEBUG = False
CHECK_DEPS = False
APPEND_SLOTS = False
# Check for stable keywords
+# This is intended to switch between keywordreq (for ~arch)
+# and stablereq (for moving from ~arch to arch)
STABLE = True
+# if not STABLE:
+# print 'Currently broken for anything except STABLEREQ'
+# print 'Please set STABLE to True'
+# sys.exit(1)
+
###############
# Preparation #
###############
ALL_CPV_KWS = []
-OLD_REL = None
-NEW_REL = None
-
-if __name__ == "__main__":
- try:
- CP_FILE = sys.argv[1] # File which has the cp list
- except IndexError:
- print """Usage: %s <file> [old_rel] [new_rel]
-
-Where <file> is a file with a category/package list
- [old_rel] is an optional argument for specifying which release cycle
- to use to get the cpv which has the keyword we need
- i.e., which cpvs will we get the list of keywords from?
- [new_rel] is an optional argument for specifying which release cycle
- to use to get the latest cpv on which we want keywords
- i.e., which cpvs will go in the list?
-WARNING: the logic for old_rel & new_rel is very incomplete. See TODO
-""" % sys.argv[0]
- sys.exit(0)
-
-if len(sys.argv) > 2:
- OLD_REL = sys.argv[2]
- if len(sys.argv) > 3:
- NEW_REL = sys.argv[3]
ARCHES = None
if STABLE:
@@ -87,17 +71,6 @@ if STABLE:
else:
ARCHES = UNSTABLE_ARCHES
-if 'CHECK_DEPS' in os.environ:
- CHECK_DEPS = os.environ['CHECK_DEPS']
-
-if 'APPEND_SLOTS' in os.environ:
- APPEND_SLOTS = os.environ['APPEND_SLOTS']
-
-if not STABLE:
- print 'Currently broken for anything except STABLEREQ'
- print 'Please set STABLE to True'
- sys.exit(1)
-
####################
# Define Functions #
@@ -495,7 +468,26 @@ def prettify(cpv_kws):
# cpvs that will make it to the final list
def main():
"""Where the magic happens!"""
- for i in open(CP_FILE).readlines():
+ parser = argparse.ArgumentParser(
+ description='Generate a stabilization request for multiple packages'
+ )
+ parser.add_argument('-d', '--debug', help='Make output more verbose')
+ parser.add_argument('--extreme-debug',
+ help='Make output even more verbose')
+ parser.add_argument('--check-dependencies', help='')
+ parser.add_argument('--append-slots', help='Append slots to CPVs output')
+ parser.add_argument('file', help='File to read CP from')
+ parser.add_argument('old_version', nargs='?',
+ help='An optional argument specifying which release'
+ ' cycle to use to get CPVs which has the'
+ ' reference keywords for stabilization.')
+ parser.add_argument('new_version', nargs='?',
+ help='An optional argument specifying which release'
+ ' cycle to use to get the latest CPVs that needs'
+ ' to be stabilized')
+ args = parser.parse_args()
+
+ for i in open(args.file).readlines():
cp = i[:-1]
if cp.startswith('#') or cp.isspace() or not cp:
ALL_CPV_KWS.append(cp)
@@ -507,13 +499,14 @@ def main():
atoms = [cp]
else:
# Get all the atoms matching the given cp
- cpvs = match_wanted_atoms(cp, release=NEW_REL)
+ cpvs = match_wanted_atoms(cp, release=args.new_version)
for cpv in get_per_slot_cpvs(cpvs):
if not cpv:
debug('%s: Invalid cpv' % cpv)
continue
- kws_missing = max_kws(cpv, release=OLD_REL)
+
+ kws_missing = max_kws(cpv, release=args.old_version)
if kws_missing == []:
# Current cpv has the max keywords => nothing to do
nothing_to_be_done(cpv)
@@ -524,7 +517,7 @@ def main():
arches = make_unstable(ARCHES)
kws_missing = [kw[1:] for kw in get_kws(cpv, arches)]
ALL_CPV_KWS += fix_nesting(gen_cpv_kws(cpv, kws_missing, set()))
- if CHECK_DEPS:
+ if args.check_dependencies:
ALL_CPV_KWS.append(LINE_SEP)
ALL_CPV_KWS = consolidate_dupes(ALL_CPV_KWS)