Gentoo Archives: gentoo-commits

From: Gilles Dartiguelongue <eva@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
Date: Fri, 26 Jun 2015 22:32:16
Message-Id: 1435236360.5451ec12c9fc4363c7f812c2fc3da253d8ffa306.eva@gentoo
1 commit: 5451ec12c9fc4363c7f812c2fc3da253d8ffa306
2 Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jun 24 11:26:24 2015 +0000
4 Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
5 CommitDate: Thu Jun 25 12:46:00 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=5451ec12
7
8 scripts/gen_archlist: move dev style configuration to argparse
9
10 This commit actually breaks the script since some functions do not have
11 proper arguments to handle configuration from main entry-point.
12
13 scripts/gen_archlist.py | 78 ++++++++++++++++++++++++-------------------------
14 1 file changed, 38 insertions(+), 40 deletions(-)
15
16 diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
17 index 6369aa2..b21fba2 100755
18 --- a/scripts/gen_archlist.py
19 +++ b/scripts/gen_archlist.py
20 @@ -23,6 +23,7 @@
21
22 from __future__ import division
23
24 +import argparse
25 import os
26 import sys
27
28 @@ -50,36 +51,19 @@ EXTREME_DEBUG = False
29 CHECK_DEPS = False
30 APPEND_SLOTS = False
31 # Check for stable keywords
32 +# This is intended to switch between keywordreq (for ~arch)
33 +# and stablereq (for moving from ~arch to arch)
34 STABLE = True
35
36 +# if not STABLE:
37 +# print 'Currently broken for anything except STABLEREQ'
38 +# print 'Please set STABLE to True'
39 +# sys.exit(1)
40 +
41 ###############
42 # Preparation #
43 ###############
44 ALL_CPV_KWS = []
45 -OLD_REL = None
46 -NEW_REL = None
47 -
48 -if __name__ == "__main__":
49 - try:
50 - CP_FILE = sys.argv[1] # File which has the cp list
51 - except IndexError:
52 - print """Usage: %s <file> [old_rel] [new_rel]
53 -
54 -Where <file> is a file with a category/package list
55 - [old_rel] is an optional argument for specifying which release cycle
56 - to use to get the cpv which has the keyword we need
57 - i.e., which cpvs will we get the list of keywords from?
58 - [new_rel] is an optional argument for specifying which release cycle
59 - to use to get the latest cpv on which we want keywords
60 - i.e., which cpvs will go in the list?
61 -WARNING: the logic for old_rel & new_rel is very incomplete. See TODO
62 -""" % sys.argv[0]
63 - sys.exit(0)
64 -
65 -if len(sys.argv) > 2:
66 - OLD_REL = sys.argv[2]
67 - if len(sys.argv) > 3:
68 - NEW_REL = sys.argv[3]
69
70 ARCHES = None
71 if STABLE:
72 @@ -87,17 +71,6 @@ if STABLE:
73 else:
74 ARCHES = UNSTABLE_ARCHES
75
76 -if 'CHECK_DEPS' in os.environ:
77 - CHECK_DEPS = os.environ['CHECK_DEPS']
78 -
79 -if 'APPEND_SLOTS' in os.environ:
80 - APPEND_SLOTS = os.environ['APPEND_SLOTS']
81 -
82 -if not STABLE:
83 - print 'Currently broken for anything except STABLEREQ'
84 - print 'Please set STABLE to True'
85 - sys.exit(1)
86 -
87
88 ####################
89 # Define Functions #
90 @@ -495,8 +468,32 @@ def prettify(cpv_kws):
91 # cpvs that will make it to the final list
92 def main():
93 """Where the magic happens!"""
94 + parser = argparse.ArgumentParser(
95 + description='Generate a stabilization request for multiple packages'
96 + )
97 + parser.add_argument('-d', '--debug', action='store_true', default=False,
98 + help='Make output more verbose')
99 + parser.add_argument('--extreme-debug', action='store_true', default=False,
100 + help='Make output even more verbose')
101 + parser.add_argument('--check-dependencies',
102 + action='store_true', default=False,
103 + help='Check dependencies are keyworded and if not,'
104 + ' add them to the list')
105 + parser.add_argument('--append-slots', action='store_true', default=False,
106 + help='Append slots to CPVs output')
107 + parser.add_argument('file', help='File to read CP from')
108 + parser.add_argument('old_version', nargs='?',
109 + help='An optional argument specifying which release'
110 + ' cycle to use to get CPVs which has the'
111 + ' reference keywords for stabilization.')
112 + parser.add_argument('new_version', nargs='?',
113 + help='An optional argument specifying which release'
114 + ' cycle to use to get the latest CPVs that needs'
115 + ' to be stabilized')
116 + args = parser.parse_args()
117 +
118 ALL_CPV_KWS = []
119 - for i in open(CP_FILE).readlines():
120 + for i in open(args.file).readlines():
121 cp = i[:-1]
122 if cp.startswith('#') or cp.isspace() or not cp:
123 ALL_CPV_KWS.append(cp)
124 @@ -508,13 +505,14 @@ def main():
125 atoms = [cp]
126 else:
127 # Get all the atoms matching the given cp
128 - cpvs = match_wanted_atoms(cp, release=NEW_REL)
129 + cpvs = match_wanted_atoms(cp, release=args.new_version)
130
131 for cpv in get_per_slot_cpvs(cpvs):
132 if not cpv:
133 debug('%s: Invalid cpv' % cpv)
134 continue
135 - kws_missing = max_kws(cpv, release=OLD_REL)
136 +
137 + kws_missing = max_kws(cpv, release=args.old_version)
138 if kws_missing == []:
139 # Current cpv has the max keywords => nothing to do
140 nothing_to_be_done(cpv)
141 @@ -525,11 +523,11 @@ def main():
142 arches = make_unstable(ARCHES)
143 kws_missing = [kw[1:] for kw in get_kws(cpv, arches)]
144 ALL_CPV_KWS += fix_nesting(gen_cpv_kws(cpv, kws_missing, set()))
145 - if CHECK_DEPS:
146 + if args.check_dependencies:
147 ALL_CPV_KWS.append(LINE_SEP)
148
149 ALL_CPV_KWS = consolidate_dupes(ALL_CPV_KWS)
150 - if APPEND_SLOTS:
151 + if args.append_slots:
152 ALL_CPV_KWS = append_slots(ALL_CPV_KWS)
153
154 for i in prettify(ALL_CPV_KWS):