Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/equery/
Date: Sat, 02 Jun 2012 18:01:29
Message-Id: 1338659989.2a0d53373fb0b7e1bae370725472822d94096f61.dol-sen@gentoo
1 commit: 2a0d53373fb0b7e1bae370725472822d94096f61
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jun 2 17:59:49 2012 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Sat Jun 2 17:59:49 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=2a0d5337
7
8 add a -S, --stablereq option to equery meta to list the arch cc's to add to STABLEREQ bug on b.g.o.
9
10 ---
11 pym/gentoolkit/equery/meta.py | 55 +++++++++++++++++++++++++++++++++++++++-
12 1 files changed, 53 insertions(+), 2 deletions(-)
13
14 diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
15 index f617cfa..2e331c5 100644
16 --- a/pym/gentoolkit/equery/meta.py
17 +++ b/pym/gentoolkit/equery/meta.py
18 @@ -42,11 +42,27 @@ QUERY_OPTS = {
19 'herd': False,
20 'keywords': False,
21 'maintainer': False,
22 + 'stablereq': False,
23 'useflags': False,
24 'upstream': False,
25 'xml': False
26 }
27
28 +STABLEREQ_arches = {
29 + 'alpha': 'alpha@g.o',
30 + 'amd64': 'amd64@g.o',
31 + 'arm': 'arm@g.o',
32 + 'hppa': 'hppa@g.o',
33 + 'ia64': 'ia64@g.o',
34 + 'm68k': 'm68k@g.o',
35 + 'ppc64': 'ppc64@g.o',
36 + 'ppc': 'ppc@g.o',
37 + 's390': 's390@g.o',
38 + 'sh': 'sh@g.o',
39 + 'sparc': 'sparc@g.o',
40 + 'x86': 'x86@g.o',
41 +}
42 +
43 # =========
44 # Functions
45 # =========
46 @@ -71,11 +87,31 @@ def print_help(with_description=True, with_usage=True):
47 (" -H, --herd", "show the herd(s) for the package"),
48 (" -k, --keywords", "show keywords for all matching package versions"),
49 (" -m, --maintainer", "show the maintainer(s) for the package"),
50 + (" -S, --stablreq", "show STABLEREQ arches (cc's) for all matching package versions"),
51 (" -u, --useflags", "show per-package USE flag descriptions"),
52 (" -U, --upstream", "show package's upstream information"),
53 (" -x, --xml", "show the plain metadata.xml file")
54 )))
55
56 +def stablereq(matches):
57 + """Produce the list of cc's for a STABLREQ bug
58 + @type matches: array
59 + @param matches: set of L{gentoolkit.package.Package} instances whose
60 + 'key' are all the same.
61 + @rtype: dict
62 + @return: a dict with L{gentoolkit.package.Package} instance keys and
63 + 'array of cc's to be added to a STABLEREQ bug.
64 + """
65 + result = {}
66 + for pkg in matches:
67 + keywords_str = pkg.environment(('KEYWORDS'), prefer_vdb=False)
68 + # get any unstable keywords
69 + keywords = set([x.lstrip('~') for x in keywords_str.split() if'~' in x])
70 + stable_arches = set(list(STABLEREQ_arches))
71 + cc_keywords = stable_arches.intersection(keywords)
72 + # add cc's
73 + result[pkg] = [STABLEREQ_arches[x] for x in cc_keywords]
74 + return result
75
76 def filter_keywords(matches):
77 """Filters non-unique keywords per slot.
78 @@ -329,6 +365,19 @@ def call_format_functions(best_match, matches):
79 useflags = format_useflags(best_match.metadata.use())
80 print_sequence(format_list(useflags))
81
82 + if QUERY_OPTS["stablereq"]:
83 + # Get {<Package 'dev-libs/glib-2.20.5'>: [u'ia64', u'm68k', ...], ...}
84 + stablereq_map = stablereq(matches)
85 + for match in matches:
86 + slot = match.environment('SLOT')
87 + verstr_len = len(match.fullversion) + len(slot)
88 + fmtd_ccs = ','.join(sorted(stablereq_map[match]))
89 + stablereq_line = format_keywords_line(
90 + match, fmtd_ccs, slot, verstr_len
91 + )
92 + #print("STABLEREQ:", )
93 + pp.uprint(stablereq_line)
94 +
95 if QUERY_OPTS["xml"]:
96 print_file(os.path.join(best_match.package_path(), 'metadata.xml'))
97
98 @@ -448,6 +497,8 @@ def parse_module_options(module_opts):
99 QUERY_OPTS["maintainer"] = True
100 elif opt in ('-k', '--keywords'):
101 QUERY_OPTS["keywords"] = True
102 + elif opt in ('-S', '--stablereq'):
103 + QUERY_OPTS["stablereq"] = True
104 elif opt in ('-u', '--useflags'):
105 QUERY_OPTS["useflags"] = True
106 elif opt in ('-U', '--upstream'):
107 @@ -459,9 +510,9 @@ def parse_module_options(module_opts):
108 def main(input_args):
109 """Parse input and run the program."""
110
111 - short_opts = "hdHkmuUx"
112 + short_opts = "hdHkmSuUx"
113 long_opts = ('help', 'description', 'herd', 'keywords', 'maintainer',
114 - 'useflags', 'upstream', 'xml')
115 + 'stablereq', 'useflags', 'upstream', 'xml')
116
117 try:
118 module_opts, queries = gnu_getopt(input_args, short_opts, long_opts)