* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 6ce2657c1052fa500cc5e84b51ce88b06b96098f
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 26 22:29:42 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:29:42 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=6ce2657c
scripts/gen_archlist: remove dead code
scripts/gen_archlist.py | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index e6dc7bd..7f677b1 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -48,10 +48,7 @@ SYSTEM_PACKAGES = []
############
# Settings #
############
-DEBUG = False
-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)
@@ -76,24 +73,6 @@ else:
####################
# Define Functions #
####################
-def flatten(list, sep=' '):
- "Given a list, returns a flat string separated by 'sep'"
- return sep.join(list)
-
-
-def n_sep(n, sep=' '):
- tmp = ''
- for i in range(0, n):
- tmp += sep
- return tmp
-
-
-def debug(*strings):
- from portage.output import EOutput
- ewarn = EOutput().ewarn
- ewarn(flatten(strings))
-
-
def make_unstable(kws):
"""Transform `kws` into a list of unstable keywords."""
return set([
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-09-06 16:53 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-09-06 16:53 UTC (permalink / raw
To: gentoo-commits
commit: 98f46bb384749baf895d520c5c8051e6e86e0abc
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 6 16:51:27 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Sun Sep 6 16:51:27 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=98f46bb3
scripts/gen_archlist: drop some stable keywords
As requested by Pacho in bug #559706, drop keywords of arches that are
not considered for stabilization anymore.
Gentoo-Bug: https://bugs.gentoo.org/559706
scripts/gen_archlist.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 7f677b1..a9fdb87 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -37,8 +37,8 @@ logger = logging.getLogger('gen_archlist')
#############
# GNOME_OVERLAY = PORTDB.getRepositoryPath('gnome')
portage.portdb.porttrees = [portage.settings['PORTDIR']]
-STABLE_ARCHES = ('alpha', 'amd64', 'arm', 'hppa', 'ia64', 'm68k', 'ppc',
- 'ppc64', 's390', 'sh', 'sparc', 'x86')
+STABLE_ARCHES = ('alpha', 'amd64', 'arm', 'hppa', 'ia64', 'ppc', 'ppc64',
+ 'sparc', 'x86')
UNSTABLE_ARCHES = ('~alpha', '~amd64', '~arm', '~hppa', '~ia64', '~m68k',
'~ppc', '~ppc64', '~s390', '~sh', '~sparc', '~x86',
'~x86-fbsd')
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 8590d8da1adf4445f928c940c2959d2a6035bdd8
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 26 22:08:58 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:14:42 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=8590d8da
scripts/gen_archlist: cosmetics
scripts/gen_archlist.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index e4597c6..7c41a9c 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -376,7 +376,11 @@ def consolidate_dupes(cpv_kws):
def get_per_slot_cpvs(cpvs):
- "Classify the given cpvs into slots, and yield the best atom for each slot"
+ """Return best CPV per slot.
+
+ Classify the CPVs into slots, and yield the best atom for each slot.
+ This only works with a pre-sorted list as returned by `match_wanted_atoms`.
+ """
slots = set()
for cpv in cpvs:
slot = portage.portage.portdb.aux_get(cpv, ['SLOT'])[0]
@@ -387,9 +391,9 @@ def get_per_slot_cpvs(cpvs):
def append_slots(cpv_kws):
- "Append slots at the end of cpv atoms"
+ """Append slots at the end of cpv atoms"""
slotifyed_cpv_kws = []
- for (cpv, kws) in cpv_kws:
+ for cpv, kws in cpv_kws:
slot = portage.portage.portdb.aux_get(cpv, ['SLOT'])[0]
cpv = "%s:%s" % (cpv, slot)
slotifyed_cpv_kws.append([cpv, kws])
@@ -489,11 +493,13 @@ def main():
continue
if cp.find('#') is not -1:
raise Exception('Inline comments are not supported')
+
+ # Convert line to CPV(s)
if portage.catpkgsplit(cp):
# cat/pkg is already a categ/pkg-ver
cpvs = [cp]
else:
- # Get all the atoms matching the given cp
+ # Get all the atoms matching the given CP
cpvs = match_wanted_atoms(cp, release=args.new_version)
for cpv in get_per_slot_cpvs(cpvs):
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: a01ce56fddcd6b1f21233636b8661b4e4abdcd71
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 26 22:27:47 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:27:47 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=a01ce56f
scripts/gen_archlist: fix case of local variable
scripts/gen_archlist.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 21a196f..e6dc7bd 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -485,7 +485,7 @@ def main():
},
})
- ALL_CPV_KWS = []
+ all_cpv_kws = []
for line in open(args.file).readlines():
cp = line.strip()
@@ -522,16 +522,16 @@ def main():
'stable' if STABLE else 'keyworded')
continue
- ALL_CPV_KWS.append(
+ all_cpv_kws.append(
gen_cpv_kws(cpv, kws_missing, set([cpv]),
args.check_dependencies, args.new_version)
)
- ALL_CPV_KWS = consolidate_dupes(ALL_CPV_KWS)
+ all_cpv_kws = consolidate_dupes(all_cpv_kws)
if args.append_slots:
- ALL_CPV_KWS = append_slots(ALL_CPV_KWS)
+ all_cpv_kws = append_slots(all_cpv_kws)
- print_cpv_kws(ALL_CPV_KWS)
+ print_cpv_kws(all_cpv_kws)
if __name__ == '__main__':
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 1d87c4f414d5a231b9951246b97daee36d8190a7
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 25 14:27:31 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:14:41 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=1d87c4f4
scripts/gen_archlist: switch logging to logging module
The output changes a bit but thanks for dictConfig, it can be re-added
with a proper formatter class later on.
scripts/gen_archlist.py | 69 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 45 insertions(+), 24 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index b362a5d..1c4c027 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -25,11 +25,15 @@ from __future__ import division, print_function
import argparse
import collections
+import logging
+import logging.config
import os
import sys
import portage
+logger = logging.getLogger('gen_archlist')
+
#############
# Constants #
#############
@@ -92,13 +96,6 @@ def debug(*strings):
ewarn(flatten(strings))
-def nothing_to_be_done(atom, type='cpv'):
- if STABLE:
- debug('%s %s: already stable, ignoring...' % (type, atom))
- else:
- debug('%s %s: already keyworded, ignoring...' % (type, atom))
-
-
def make_unstable(kws):
"""Transform `kws` into a list of unstable keywords."""
return set([
@@ -182,8 +179,7 @@ def get_best_deps(cpv, kws, release=None):
cpvs = match_wanted_atoms(atom, release)
if not cpvs:
- if DEBUG:
- debug('We encountered an irrelevant atom: %s' % atom)
+ logger.debug('Encountered an irrelevant atom: %s', atom)
continue
best_cpv_kws = ['', []]
@@ -196,9 +192,8 @@ def get_best_deps(cpv, kws, release=None):
)
if cur_unstable_kws.intersection(unstable_kws) != unstable_kws:
best_cpv_kws[0] = 'none'
- if DEBUG:
- debug('Insufficient unstable keywords in: %s' %
- candidate_cpv)
+ logger.debug('Insufficiant unstable keywords in: %s',
+ candidate_cpv)
continue
candidate_kws = get_kws(candidate_cpv, arches=kws)
@@ -216,8 +211,8 @@ def get_best_deps(cpv, kws, release=None):
best_cpv_kws = [candidate_cpv, []]
if best_cpv_kws[0] == 'alreadythere':
- if DEBUG:
- nothing_to_be_done(atom, type='dep')
+ logger.debug('DEP %s is already %s, ignoring', atom,
+ 'stable' if STABLE else 'keyworded')
continue
elif best_cpv_kws[0] == 'none':
continue
@@ -324,8 +319,9 @@ def gen_cpv_kws(cpv, kws_aim, depgraph, check_dependencies, new_release):
# So... let's just stabilize it on all arches we can, and ignore for
# keywording since we have no idea about that.
if not STABLE:
- debug('MEH')
- nothing_to_be_done(cpv, type='dep')
+ logger.warn('MEH')
+ logger.info('DEP %s is already %s, ignoring', cpv,
+ 'stable' if STABLE else 'keyworded')
return None
wanted = get_kws(cpv, arches=make_unstable(kws_aim))
@@ -334,8 +330,7 @@ def gen_cpv_kws(cpv, kws_aim, depgraph, check_dependencies, new_release):
if check_dependencies and not issystempackage(cpv):
deps = get_best_deps(cpv, wanted, release=new_release)
- if EXTREME_DEBUG:
- debug('The deps of %s are %s' % (cpv, deps))
+ logger.debug('Dependencies of %s are: %s', cpv, deps)
for dep in deps:
if dep in depgraph:
@@ -442,10 +437,8 @@ def main():
parser = argparse.ArgumentParser(
description='Generate a stabilization request for multiple packages'
)
- parser.add_argument('-d', '--debug', action='store_true', default=False,
+ parser.add_argument('-v', '--verbose', action='count',
help='Make output more verbose')
- parser.add_argument('--extreme-debug', action='store_true', default=False,
- help='Make output even more verbose')
parser.add_argument('--check-dependencies',
action='store_true', default=False,
help='Check dependencies are keyworded and if not,'
@@ -463,6 +456,33 @@ def main():
' to be stabilized')
args = parser.parse_args()
+ args.verbose = min(max(args.verbose, 0), 2)
+ logging.config.dictConfig({
+ 'version': 1,
+ 'disable_existing_loggers': True,
+ 'formatters': {
+ 'brief': {'format': '%(message)s'},
+ },
+ 'handlers': {
+ 'console': {
+ 'class': 'logging.StreamHandler',
+ 'level': 'DEBUG',
+ 'formatter': 'brief',
+ 'stream': 'ext://sys.stdout',
+ },
+ },
+ 'loggers': {
+ 'gen_archlist': {
+ 'handlers': ['console'],
+ 'level': [logging.WARN, logging.INFO,
+ logging.DEBUG][args.verbose],
+ },
+ },
+ 'root': {
+ 'handler': ['console'],
+ },
+ })
+
ALL_CPV_KWS = []
for i in open(args.file).readlines():
cp = i[:-1]
@@ -480,19 +500,20 @@ def main():
for cpv in get_per_slot_cpvs(cpvs):
if not cpv:
- debug('%s: Invalid cpv' % cpv)
+ logger.warn('%s is an invalid CPV', cpv)
continue
kws_missing = max_kws(cpv, release=args.old_version)
if kws_missing is None:
- debug('No versions with stable keywords for %s' % cpv)
+ logger.info('No versions with stable keywords for %s', cpv)
# No cpv with stable keywords => select latest
arches = make_unstable(ARCHES)
kws_missing = [kw[1:] for kw in get_kws(cpv, arches)]
elif not kws_missing:
# Current cpv has the max keywords => nothing to do
- nothing_to_be_done(cpv)
+ logger.info('CPV %s is already %s, ignoring', cpv,
+ 'stable' if STABLE else 'keyworded')
continue
ALL_CPV_KWS.append(
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 598edbfe3303a0e59bb7b92d38f5693b0aae7007
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 25 14:27:43 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:14:42 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=598edbfe
scripts/gen_archlist: drop unused imports
scripts/gen_archlist.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 1c4c027..e4597c6 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -27,8 +27,6 @@ import argparse
import collections
import logging
import logging.config
-import os
-import sys
import portage
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: bb81b5c9415b3d70f508a77ba1f79f86c5b4a79c
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 26 22:09:54 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:14:43 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=bb81b5c9
scripts/gen_archlist: do not add skipped lines to ALL_CPV_KWS
Why in the world would we want to do that.
scripts/gen_archlist.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 7c41a9c..1633dfa 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -489,7 +489,6 @@ def main():
for i in open(args.file).readlines():
cp = i[:-1]
if cp.startswith('#') or cp.isspace() or not cp:
- ALL_CPV_KWS.append(cp)
continue
if cp.find('#') is not -1:
raise Exception('Inline comments are not supported')
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 86f443210464a83721be581cc00cfe08dc5632bd
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 26 22:10:42 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:14:43 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=86f44321
scripts/gen_archlist: simplify logic of file parsing
scripts/gen_archlist.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 1633dfa..21a196f 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -486,11 +486,14 @@ def main():
})
ALL_CPV_KWS = []
- for i in open(args.file).readlines():
- cp = i[:-1]
- if cp.startswith('#') or cp.isspace() or not cp:
+ for line in open(args.file).readlines():
+ cp = line.strip()
+
+ # Filter useless lines
+ if not cp or cp.startswith('#'):
continue
- if cp.find('#') is not -1:
+
+ if '#' in cp:
raise Exception('Inline comments are not supported')
# Convert line to CPV(s)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: c33a3166cd55a0245663cbb1472ef04fda4c44f8
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 25 13:31:07 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:14:40 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=c33a3166
scripts/gen_archlist: better names for get_best_deps variables
scripts/gen_archlist.py | 81 ++++++++++++++++++++++++++++---------------------
1 file changed, 46 insertions(+), 35 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 066b31e..b362a5d 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -169,50 +169,59 @@ def get_best_deps(cpv, kws, release=None):
Returns a list of the best deps of a cpv, optionally matching a release,
and with max of the specified keywords
"""
+ # Take raw dependency strings and convert it to a list of atoms
atoms = portage.portdb.aux_get(cpv, ['DEPEND', 'RDEPEND', 'PDEPEND'])
atoms = ' '.join(atoms).split() # consolidate atoms
atoms = list(set(atoms)) # de-duplicate
+
deps = set()
- tmp = []
+
for atom in atoms:
- if atom.find('/') is -1:
- # It's not a dep atom
+ if not portage.isvalidatom(atom):
continue
- ret = match_wanted_atoms(atom, release)
- if not ret:
+
+ cpvs = match_wanted_atoms(atom, release)
+ if not cpvs:
if DEBUG:
debug('We encountered an irrelevant atom: %s' % atom)
continue
- best_kws = ['', []]
- for i in ret:
+
+ best_cpv_kws = ['', []]
+ for candidate_cpv in cpvs:
if STABLE:
# Check that this version has unstable keywords
- ukws = make_unstable(kws)
- cur_ukws = make_unstable(get_kws(i, arches=kws | ukws))
- if cur_ukws.intersection(ukws) != ukws:
- best_kws = 'none'
+ unstable_kws = make_unstable(kws)
+ cur_unstable_kws = make_unstable(
+ get_kws(candidate_cpv, arches=kws | unstable_kws)
+ )
+ if cur_unstable_kws.intersection(unstable_kws) != unstable_kws:
+ best_cpv_kws[0] = 'none'
if DEBUG:
- debug('Insufficient unstable keywords in: %s' % i)
+ debug('Insufficient unstable keywords in: %s' %
+ candidate_cpv)
continue
- cur_match_kws = get_kws(i, arches=kws)
- if cur_match_kws == kws:
- # This dep already has all keywords
- best_kws = 'alreadythere'
+
+ candidate_kws = get_kws(candidate_cpv, arches=kws)
+ if candidate_kws == kws:
+ # This dep already has all requested keywords
+ best_cpv_kws[0] = 'alreadythere'
break
+
# Select the version which needs least new keywords
- if len(cur_match_kws) > len(best_kws[1]):
- best_kws = [i, cur_match_kws]
- elif not best_kws[0]:
+ if len(candidate_kws) > len(best_cpv_kws[1]):
+ best_cpv_kws = [candidate_cpv, candidate_kws]
+ elif not best_cpv_kws[0]:
# This means that none of the versions have any of the stable
# keywords that *we checked* (i.e. kws).
- best_kws = [i, []]
- if best_kws == 'alreadythere':
+ best_cpv_kws = [candidate_cpv, []]
+
+ if best_cpv_kws[0] == 'alreadythere':
if DEBUG:
nothing_to_be_done(atom, type='dep')
continue
- elif best_kws == 'none':
+ elif best_cpv_kws[0] == 'none':
continue
- elif not best_kws[0]:
+ elif not best_cpv_kws[0]:
# We get this when the if STABLE: block above rejects everything.
# This means that this atom does not have any versions with
# unstable keywords matching the unstable keywords of the cpv
@@ -220,8 +229,8 @@ def get_best_deps(cpv, kws, release=None):
# This mostly happens because an || or use dep exists. However, we
# make such deps strict while parsing
# XXX: We arbitrarily select the most recent version for this case
- deps.add(ret[0])
- elif not best_kws[1]:
+ deps.add(cpvs[0])
+ elif not best_cpv_kws[1]:
# This means that none of the versions have any of the stable
# keywords that *we checked* (i.e. kws). Hence, we do another pass;
# this time checking *all* keywords.
@@ -229,20 +238,22 @@ def get_best_deps(cpv, kws, release=None):
# XXX: We duplicate some of the things from the for loop above
# We don't need to duplicate anything that caused a 'continue' or
# a 'break' above
- ret = match_wanted_atoms(atom, release)
- best_kws = ['', []]
- for i in ret:
- cur_kws = get_kws(i)
- if len(cur_kws) > len(best_kws[1]):
- best_kws = [i, cur_kws]
- elif not best_kws[0]:
+ cpvs = match_wanted_atoms(atom, release)
+ best_cpv_kws = ['', []]
+ for candidate_cpv in cpvs:
+ cur_kws = get_kws(candidate_cpv)
+ if len(cur_kws) > len(best_cpv_kws[1]):
+ best_cpv_kws = [candidate_cpv, cur_kws]
+ elif not best_cpv_kws[0]:
# This means that none of the versions have any of
# the stable keywords *at all*. No choice but to
# arbitrarily select the latest version in that case.
- best_kws = [i, []]
- deps.add(best_kws[0])
+ best_cpv_kws = [candidate_cpv, []]
+
+ deps.add(best_cpv_kws[0])
else:
- deps.add(best_kws[0])
+ deps.add(best_cpv_kws[0])
+
return list(deps)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 4571219b191c1786d7ff4b0e5a6ade19e5c30875
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 25 11:26:43 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:14:39 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=4571219b
scripts/gen_archlist: add full CPV lines to our workset
Probably an overlooked rename.
scripts/gen_archlist.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index d595df3..f9cf432 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -479,8 +479,8 @@ def main():
if cp.find('#') is not -1:
raise Exception('Inline comments are not supported')
if portage.catpkgsplit(cp):
- # categ/pkg is already a categ/pkg-ver
- atoms = [cp]
+ # cat/pkg is already a categ/pkg-ver
+ cpvs = [cp]
else:
# Get all the atoms matching the given cp
cpvs = match_wanted_atoms(cp, release=args.new_version)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 3dd724f0698988b69d2c15aa502d181ca609943b
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 12:07:21 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Thu Jun 25 12:46:05 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=3dd724f0
scripts/gen_archlist: simplify functions and try to enhance documentation
scripts/gen_archlist.py | 60 ++++++++++++++++++++++---------------------------
1 file changed, 27 insertions(+), 33 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index b21fba2..3ac9f88 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -101,14 +101,11 @@ def nothing_to_be_done(atom, type='cpv'):
def make_unstable(kws):
- "Takes a keyword list, and returns a list with them all unstable"
- nkws = []
- for kw in kws:
- if not kw.startswith('~'):
- nkws.append('~'+kw)
- else:
- nkws.append(kw)
- return nkws
+ """Transform `kws` into a list of unstable keywords."""
+ return [
+ kwd if kwd.startswith('~') else '~' + kwd
+ for kwd in kws
+ ]
def belongs_release(cpv, release):
@@ -127,14 +124,11 @@ def issystempackage(cpv):
def get_kws(cpv, arches=ARCHES):
- """
- Returns an array of KEYWORDS matching 'arches'
- """
- kws = []
- for kw in portage.portdb.aux_get(cpv, ['KEYWORDS'])[0].split():
- if kw in arches:
- kws.append(kw)
- return kws
+ """Return keywords of `cpv` filtered by `arches`."""
+ return [
+ kwd for kwd in portage.portdb.aux_get(cpv, ['KEYWORDS'])[0].split()
+ if kwd in arches
+ ]
def do_not_want(cpv, release=None):
@@ -149,20 +143,20 @@ def do_not_want(cpv, release=None):
def match_wanted_atoms(atom, release=None):
+ """Return a list of CPV matching `atom`.
+
+ If `release` is provided, CPVs are filtered against it.
+
+ The list is sorted by descending order of version.
"""
- Given an atom and a release, return all matching wanted atoms ordered in
- descending order of version
- """
- atoms = []
# xmatch is stupid, and ignores ! in an atom...
if atom.startswith('!'):
return []
- for cpv in portage.portdb.xmatch('match-all', atom):
- if do_not_want(cpv, release):
- continue
- atoms.append(cpv)
- atoms.reverse()
- return atoms
+
+ return [
+ cpv for cpv in reversed(portage.portdb.xmatch('match-all', atom))
+ if not do_not_want(cpv, release)
+ ]
def get_best_deps(cpv, kws, release=None):
@@ -278,15 +272,15 @@ def max_kws(cpv, release=None):
# FIXME: This is broken
-def kws_wanted(cpv_kws, prev_cpv_kws):
- "Generate a list of kws that need to be updated"
+def kws_wanted(current_kws, target_kws):
+ """Generate a list of kws that need to be updated."""
wanted = []
- for kw in prev_cpv_kws:
- if kw not in cpv_kws:
- if STABLE and '~'+kw not in cpv_kws:
- # Ignore if no keywords at all
+ for kwd in target_kws:
+ if kwd not in current_kws:
+ if STABLE and '~' + kwd not in current_kws:
+ # Skip stable keywords with no corresponding unstable keyword
continue
- wanted.append(kw)
+ wanted.append(kwd)
return wanted
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 9e2189f5a6efd3c0ab7d1f386f532d3d42b18734
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 12:07:39 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Thu Jun 25 12:46:09 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=9e2189f5
scripts/gen_archlist: fix belongs_release
get_ver is undefined, I wonder how this could ever work.
scripts/gen_archlist.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 3ac9f88..9a74d21 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -109,11 +109,11 @@ def make_unstable(kws):
def belongs_release(cpv, release):
- "Check if the given cpv belongs to the given release"
+ """Check if `cpv` belongs to the release `release`."""
# FIXME: This failure function needs better logic
if CHECK_DEPS:
raise Exception('This function is utterly useless with RECURSIVE mode')
- return get_ver(cpv).startswith(release)
+ return portage.versions.cpv_getversion(cpv).startswith(release)
def issystempackage(cpv):
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: d1f4f46de1234dbf750ab8815dcf2aa6a827eb4d
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 09:35:49 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Thu Jun 25 12:45:47 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=d1f4f46d
scripts/gen_archlist: apply PEP8 rules
scripts/gen_archlist.py | 145 ++++++++++++++++++++++++++++++------------------
1 file changed, 90 insertions(+), 55 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index fa26b90..407ebbd 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -10,10 +10,10 @@
# You can use test-data/package-list to test the script out.
#
# NOTE: This script assumes that there are no broken keyword deps
-#
+#
# BUGS:
-# * belongs_release() is a very primitive function, which means usage of old/new
-# release numbers gives misleading output
+# * belongs_release() is a very primitive function, which means usage of
+# old/new release numbers gives misleading output
# * Will show multiple versions of the same package in the output sometimes.
# This happens when a cp is specified in the cpv list, and is resolved as
# a dependency as well.
@@ -22,25 +22,29 @@
#
from __future__ import division
-import os, sys
+
+import os
+import sys
+
import portage
-###############
-## Constants ##
-###############
-#GNOME_OVERLAY = PORTDB.getRepositoryPath('gnome')
+#############
+# Constants #
+#############
+# GNOME_OVERLAY = PORTDB.getRepositoryPath('gnome')
portage.portdb.porttrees = [portage.settings['PORTDIR']]
STABLE_ARCHES = ('alpha', 'amd64', 'arm', 'hppa', 'ia64', 'm68k', 'ppc',
- 'ppc64', 's390', 'sh', 'sparc', 'x86')
-UNSTABLE_ARCHES = ('~alpha', '~amd64', '~arm', '~hppa', '~ia64', '~m68k', '~ppc',
- '~ppc64', '~s390', '~sh', '~sparc', '~x86', '~x86-fbsd')
-ALL_ARCHES = STABLE_ARCHES+UNSTABLE_ARCHES
+ 'ppc64', 's390', 'sh', 'sparc', 'x86')
+UNSTABLE_ARCHES = ('~alpha', '~amd64', '~arm', '~hppa', '~ia64', '~m68k',
+ '~ppc', '~ppc64', '~s390', '~sh', '~sparc', '~x86',
+ '~x86-fbsd')
+ALL_ARCHES = STABLE_ARCHES + UNSTABLE_ARCHES
SYSTEM_PACKAGES = []
LINE_SEP = ''
-##############
-## Settings ##
-##############
+############
+# Settings #
+############
DEBUG = False
EXTREME_DEBUG = False
CHECK_DEPS = False
@@ -48,40 +52,45 @@ APPEND_SLOTS = False
# Check for stable keywords
STABLE = True
-#################
-## Preparation ##
-#################
+###############
+# 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
+ CP_FILE = sys.argv[1] # File which has the cp list
except IndexError:
- print 'Usage: %s <file> [old_rel] [new_rel]' % sys.argv[0]
- print 'Where <file> is a file with a category/package list'
- print ' [old_rel] is an optional argument for specifying which release cycle'
- print ' to use to get the cpv which has the keyword we need'
- print ' i.e., which cpvs will we get the list of keywords from?'
- print ' [new_rel] is an optional argument for specifying which release cycle'
- print ' to use to get the latest cpv on which we want keywords'
- print ' i.e., which cpvs will go in the list?'
- print 'WARNING: the logic for old_rel & new_rel is very incomplete. See TODO'
+ 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:
ARCHES = STABLE_ARCHES
else:
ARCHES = UNSTABLE_ARCHES
-if os.environ.has_key('CHECK_DEPS'):
+if 'CHECK_DEPS' in os.environ:
CHECK_DEPS = os.environ['CHECK_DEPS']
-if os.environ.has_key('APPEND_SLOTS'):
+if 'APPEND_SLOTS' in os.environ:
APPEND_SLOTS = os.environ['APPEND_SLOTS']
if not STABLE:
@@ -89,30 +98,35 @@ if not STABLE:
print 'Please set STABLE to True'
sys.exit(1)
-######################
-## Define Functions ##
-######################
+
+####################
+# Define Functions #
+####################
def flatten(list, sep=' '):
"Given a list, returns a flat string separated by 'sep'"
return sep.join(list)
+
def n_sep(n, sep=' '):
tmp = ''
for i in range(0, n):
tmp += sep
return tmp
+
def debug(*strings):
from portage.output import EOutput
ewarn = EOutput().ewarn
ewarn(flatten(strings))
+
def nothing_to_be_done(atom, type='cpv'):
if STABLE:
debug('%s %s: already stable, ignoring...' % (type, atom))
else:
debug('%s %s: already keyworded, ignoring...' % (type, atom))
+
def make_unstable(kws):
"Takes a keyword list, and returns a list with them all unstable"
nkws = []
@@ -123,6 +137,7 @@ def make_unstable(kws):
nkws.append(kw)
return nkws
+
def belongs_release(cpv, release):
"Check if the given cpv belongs to the given release"
# FIXME: This failure function needs better logic
@@ -130,12 +145,14 @@ def belongs_release(cpv, release):
raise Exception('This function is utterly useless with RECURSIVE mode')
return get_ver(cpv).startswith(release)
+
def issystempackage(cpv):
for i in SYSTEM_PACKAGES:
if cpv.startswith(i):
return True
return False
+
def get_kws(cpv, arches=ARCHES):
"""
Returns an array of KEYWORDS matching 'arches'
@@ -146,6 +163,7 @@ def get_kws(cpv, arches=ARCHES):
kws.append(kw)
return kws
+
def do_not_want(cpv, release=None):
"""
Check if a package atom is p.masked or has empty keywords, or does not
@@ -156,6 +174,7 @@ def do_not_want(cpv, release=None):
return True
return False
+
def match_wanted_atoms(atom, release=None):
"""
Given an atom and a release, return all matching wanted atoms ordered in
@@ -163,7 +182,8 @@ def match_wanted_atoms(atom, release=None):
"""
atoms = []
# xmatch is stupid, and ignores ! in an atom...
- if atom.startswith('!'): return []
+ if atom.startswith('!'):
+ return []
for cpv in portage.portdb.xmatch('match-all', atom):
if do_not_want(cpv, release):
continue
@@ -171,14 +191,15 @@ def match_wanted_atoms(atom, release=None):
atoms.reverse()
return atoms
+
def get_best_deps(cpv, kws, release=None):
"""
- Returns a list of the best deps of a cpv, optionally matching a release, and
- with max of the specified keywords
+ Returns a list of the best deps of a cpv, optionally matching a release,
+ and with max of the specified keywords
"""
atoms = portage.portdb.aux_get(cpv, ['DEPEND', 'RDEPEND', 'PDEPEND'])
- atoms = ' '.join(atoms).split() # consolidate atoms
- atoms = list(set(atoms)) # de-duplicate
+ atoms = ' '.join(atoms).split() # consolidate atoms
+ atoms = list(set(atoms)) # de-duplicate
deps = set()
tmp = []
for atom in atoms:
@@ -187,7 +208,8 @@ def get_best_deps(cpv, kws, release=None):
continue
ret = match_wanted_atoms(atom, release)
if not ret:
- if DEBUG: debug('We encountered an irrelevant atom: %s' % atom)
+ if DEBUG:
+ debug('We encountered an irrelevant atom: %s' % atom)
continue
best_kws = ['', []]
for i in ret:
@@ -197,7 +219,8 @@ def get_best_deps(cpv, kws, release=None):
cur_ukws = set(make_unstable(get_kws(i, arches=kws+ukws)))
if cur_ukws.intersection(ukws) != set(ukws):
best_kws = 'none'
- if DEBUG: debug('Insufficient unstable keywords in: %s' % i)
+ if DEBUG:
+ debug('Insufficient unstable keywords in: %s' % i)
continue
cur_match_kws = get_kws(i, arches=kws)
if set(cur_match_kws) == set(kws):
@@ -212,14 +235,16 @@ def get_best_deps(cpv, kws, release=None):
# keywords that *we checked* (i.e. kws).
best_kws = [i, []]
if best_kws == 'alreadythere':
- if DEBUG: nothing_to_be_done(atom, type='dep')
+ if DEBUG:
+ nothing_to_be_done(atom, type='dep')
continue
elif best_kws == 'none':
continue
elif not best_kws[0]:
# We get this when the if STABLE: block above rejects everything.
- # This means that this atom does not have any versions with unstable
- # keywords matching the unstable keywords of the cpv that pulls it.
+ # This means that this atom does not have any versions with
+ # unstable keywords matching the unstable keywords of the cpv
+ # that pulls it.
# This mostly happens because an || or use dep exists. However, we
# make such deps strict while parsing
# XXX: We arbitrarily select the most recent version for this case
@@ -239,15 +264,16 @@ def get_best_deps(cpv, kws, release=None):
if len(cur_kws) > len(best_kws[1]):
best_kws = [i, cur_kws]
elif not best_kws[0]:
- # This means that none of the versions have any of the stable
- # keywords *at all*. No choice but to arbitrarily select the
- # latest version in that case.
+ # This means that none of the versions have any of
+ # the stable keywords *at all*. No choice but to
+ # arbitrarily select the latest version in that case.
best_kws = [i, []]
deps.add(best_kws[0])
else:
deps.add(best_kws[0])
return list(deps)
+
def max_kws(cpv, release=None):
"""
Given a cpv, find the intersection of "most keywords it can have" and
@@ -259,7 +285,7 @@ def max_kws(cpv, release=None):
Returns None if no cpv has keywords
"""
current_kws = get_kws(cpv, arches=ALL_ARCHES)
- maximum_kws = [] # Maximum keywords that a cpv has
+ maximum_kws = [] # Maximum keywords that a cpv has
missing_kws = []
for atom in match_wanted_atoms('<='+cpv, release):
kws = get_kws(atom)
@@ -277,6 +303,7 @@ def max_kws(cpv, release=None):
# No cpv has the keywords we need
return None
+
# FIXME: This is broken
def kws_wanted(cpv_kws, prev_cpv_kws):
"Generate a list of kws that need to be updated"
@@ -289,13 +316,15 @@ def kws_wanted(cpv_kws, prev_cpv_kws):
wanted.append(kw)
return wanted
+
def gen_cpv_kws(cpv, kws_aim, depgraph):
depgraph.add(cpv)
cpv_kw_list = [[cpv, kws_wanted(get_kws(cpv, arches=ALL_ARCHES), kws_aim)]]
if not cpv_kw_list[0][1]:
# This happens when cpv has less keywords than kws_aim
- # Usually happens when a dep was an || dep, or under a USE-flag which is
- # masked in some profiles. We make all deps strict in get_best_deps()
+ # Usually happens when a dep was an || dep, or under a USE-flag
+ # which is masked in some profiles. We make all deps strict in
+ # get_best_deps()
# So... let's just stabilize it on all arches we can, and ignore for
# keywording since we have no idea about that.
if not STABLE:
@@ -322,6 +351,7 @@ def gen_cpv_kws(cpv, kws_aim, depgraph):
cpv_kw_list.reverse()
return cpv_kw_list
+
def fix_nesting(nested_list):
"""Takes a list of unknown nesting depth, and gives a nice list with each
element of the form [cpv, [kws]]"""
@@ -340,6 +370,7 @@ def fix_nesting(nested_list):
index += 1
return nice_list
+
def consolidate_dupes(cpv_kws):
"""
Consolidate duplicate cpvs with differing keywords
@@ -355,7 +386,7 @@ def consolidate_dupes(cpv_kws):
if type(each) is not list:
continue
else:
- if not cpv_indices.has_key(each[0]):
+ if each[0] not in cpv_indices:
cpv_indices[each[0]] = []
cpv_indices[each[0]].append(cpv_kws.index(each))
@@ -388,6 +419,7 @@ def consolidate_dupes(cpv_kws):
return deduped_cpv_kws
+
def get_per_slot_cpvs(cpvs):
"Classify the given cpvs into slots, and yield the best atom for each slot"
slots = set()
@@ -398,6 +430,7 @@ def get_per_slot_cpvs(cpvs):
slots.add(slot)
yield cpv
+
def append_slots(cpv_kws):
"Append slots at the end of cpv atoms"
slotifyed_cpv_kws = []
@@ -407,6 +440,7 @@ def append_slots(cpv_kws):
slotifyed_cpv_kws.append([cpv, kws])
return slotifyed_cpv_kws
+
# FIXME: This is broken
def prettify(cpv_kws):
"Takes a list of [cpv, [kws]] and prettifies it"
@@ -454,9 +488,10 @@ def prettify(cpv_kws):
pretty_list.append([each[0], each[1]])
return pretty_list
-#######################
-## Use the Functions ##
-#######################
+
+#####################
+# Use the Functions #
+#####################
# cpvs that will make it to the final list
if __name__ == "__main__":
index = 0
@@ -485,8 +520,8 @@ if __name__ == "__main__":
# Current cpv has the max keywords => nothing to do
nothing_to_be_done(cpv)
continue
- elif kws_missing == None:
- debug ('No versions with stable keywords for %s' % cpv)
+ elif kws_missing is None:
+ debug('No versions with stable keywords for %s' % cpv)
# No cpv with stable keywords => select latest
arches = make_unstable(ARCHES)
kws_missing = [kw[1:] for kw in get_kws(cpv, arches)]
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 19c52766c8ca16879f8b03b3f6a9b85c0865a04f
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 25 12:47:22 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:14:40 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=19c52766
scripts/gen_archlist: make prettify the print function
No need for another function call at this point, everything that happens
in prettify is only intended for output.
scripts/gen_archlist.py | 75 ++++++++++++++++++-------------------------------
1 file changed, 28 insertions(+), 47 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index f9cf432..066b31e 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -21,7 +21,7 @@
# * Support recursive checking of needed keywords in deps
#
-from __future__ import division
+from __future__ import division, print_function
import argparse
import collections
@@ -392,52 +392,34 @@ def append_slots(cpv_kws):
return slotifyed_cpv_kws
-# FIXME: This is broken
-def prettify(cpv_kws):
- "Takes a list of [cpv, [kws]] and prettifies it"
+def print_cpv_kws(cpv_kws):
+ """Takes a list of [cpv, [kws]] and prettifies it"""
max_len = 0
- kws_all = []
- pretty_list = []
- cpv_block_size = 0
+ kws_all = set()
- for each in cpv_kws:
- # Ignore comments/whitespace carried over from original list
- if type(each) is not list:
- continue
- # Find the atom with max length (for output formatting)
- if len(each[0]) > max_len:
- max_len = len(each[0])
- # Find the set of all kws listed
- for kw in each[1]:
- if kw not in kws_all:
- kws_all.append(kw)
- kws_all.sort()
-
- for each in cpv_kws:
- # Handle comments/whitespace carried over from original list
- if type(each) is not list:
- # If the prev cpv block has just one line, don't print an extra \n
- # XXX: This code relies on blocks of dep-cpvs being separated by \n
- if CHECK_DEPS and cpv_block_size is 1:
- cpv_block_size = 0
- continue
- pretty_list.append([each, []])
- cpv_block_size = 0
- continue
- # The size of the current cpv list block
- cpv_block_size += 1
- # Pad the cpvs with space
- each[0] += n_sep(max_len - len(each[0]))
- for i in range(0, len(kws_all)):
- if i == len(each[1]):
- # Prevent an IndexError
- # This is a problem in the algo I selected
- each[1].append('')
- if each[1][i] != kws_all[i]:
- # If no arch, insert space
- each[1].insert(i, n_sep(len(kws_all[i])))
- pretty_list.append([each[0], each[1]])
- return pretty_list
+ for dep_set in cpv_kws:
+ for cpv, kws in dep_set:
+ # Find the atom with max length (for output formatting)
+ max_len = max(max_len, len(cpv))
+ # Find the set of all kws listed
+ kws_all.update(kws)
+
+ for dep_set in cpv_kws:
+ for cpv, kws in dep_set:
+ pretty_line = cpv + ' ' * (max_len - len(cpv))
+
+ for kwd in sorted(kws_all):
+ if kwd in kws:
+ pretty_line += ' ' + kwd
+ else:
+ pretty_line += ' ' + ' ' * len(kwd)
+
+ print(pretty_line)
+
+ if len(dep_set) > 1:
+ print()
+
+ return
#####################
@@ -511,8 +493,7 @@ def main():
if args.append_slots:
ALL_CPV_KWS = append_slots(ALL_CPV_KWS)
- for i in prettify(ALL_CPV_KWS):
- print i[0], flatten(i[1])
+ print_cpv_kws(ALL_CPV_KWS)
if __name__ == '__main__':
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: e7d972f07e900247f39cdf0ae0e3b03d6e4f9eb4
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 11:23:40 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Thu Jun 25 12:45:55 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=e7d972f0
scripts/gen_archlist: create a clear main function
scripts/gen_archlist.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 407ebbd..6369aa2 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -493,10 +493,9 @@ def prettify(cpv_kws):
# Use the Functions #
#####################
# cpvs that will make it to the final list
-if __name__ == "__main__":
- index = 0
- array = []
-
+def main():
+ """Where the magic happens!"""
+ ALL_CPV_KWS = []
for i in open(CP_FILE).readlines():
cp = i[:-1]
if cp.startswith('#') or cp.isspace() or not cp:
@@ -535,3 +534,7 @@ if __name__ == "__main__":
for i in prettify(ALL_CPV_KWS):
print i[0], flatten(i[1])
+
+
+if __name__ == '__main__':
+ main()
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 30e08cc1e869e0234aaacd56ed93242ba138b31d
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 25 11:22:34 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Thu Jun 25 12:46:24 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=30e08cc1
scripts/gen_archlist: remove fix_nesting function
Could not figure out if this was needed at all. At least it appears it
is not useful anymore. Kill its weird logic with fire.
scripts/gen_archlist.py | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index f2a68e5..659c84e 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -347,25 +347,6 @@ def gen_cpv_kws(cpv, kws_aim, depgraph, check_dependencies, new_release):
return cpv_kw_list
-def fix_nesting(nested_list):
- """Takes a list of unknown nesting depth, and gives a nice list with each
- element of the form [cpv, [kws]]"""
- index = 0
- cpv_index = -1
- nice_list = []
- # Has an unpredictable nesting of lists; so we flatten it...
- flat_list = portage.flatten(nested_list)
- # ... and re-create a nice list for us to use
- while index < len(flat_list):
- if portage.catpkgsplit(flat_list[index]):
- cpv_index += 1
- nice_list.append([flat_list[index], []])
- else:
- nice_list[cpv_index][1].append(flat_list[index])
- index += 1
- return nice_list
-
-
def consolidate_dupes(cpv_kws):
"""
Consolidate duplicate cpvs with differing keywords
@@ -546,7 +527,7 @@ def main():
nothing_to_be_done(cpv)
continue
- ALL_CPV_KWS += fix_nesting(
+ ALL_CPV_KWS.append(
gen_cpv_kws(cpv, kws_missing, set([cpv]),
args.check_dependencies, args.new_version)
)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 4542a3fc2042bb029e0a7b124724c6af41d6ff87
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 12:08:20 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Thu Jun 25 12:46:14 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=4542a3fc
scripts/gen_archlist: rename do_not_want function
Give it a better name of split logic down in multiple lines, it is
easier to read that a kilometric if line.
Logic was inverted to avoid double negation in match_wanted_atoms
function.
scripts/gen_archlist.py | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 9a74d21..9b60f03 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -131,15 +131,21 @@ def get_kws(cpv, arches=ARCHES):
]
-def do_not_want(cpv, release=None):
- """
- Check if a package atom is p.masked or has empty keywords, or does not
- belong to a release
+def can_stabilize_cpv(cpv, release=None):
+ """Whether `cpv` matches stabilization criteria.
+
+ `cpv` must:
+ * belong to the release
+ * not be p.masked
+ * have keywords
"""
- if release and not belongs_release(cpv, release) or not \
- portage.portdb.visible([cpv]) or not get_kws(cpv, arches=ALL_ARCHES):
- return True
- return False
+ if release and not belongs_release(cpv, release):
+ return False
+ if not portage.portdb.visible([cpv]):
+ return False
+ if not get_kws(cpv, arches=ALL_ARCHES):
+ return False
+ return True
def match_wanted_atoms(atom, release=None):
@@ -155,7 +161,7 @@ def match_wanted_atoms(atom, release=None):
return [
cpv for cpv in reversed(portage.portdb.xmatch('match-all', atom))
- if not do_not_want(cpv, release)
+ if can_stabilize_cpv(cpv, release)
]
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 9a712ebe4e2495134421a3df88ebe9962b6fa50e
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 14:39:56 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Thu Jun 25 12:46:23 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=9a712ebe
scripts/gen_archlist: fix gen_cpv_kws to use arguments from command line
* Change the cpv_kw format to a tuple, there is no point in using a list.
* Move/edit some lines around to expose logic in a clearer way.
* Retrieve arguments from command line.
* Add some comments.
scripts/gen_archlist.py | 47 ++++++++++++++++++++++++++++++++---------------
1 file changed, 32 insertions(+), 15 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 15d5b02..6e00ec1 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -63,7 +63,6 @@ STABLE = True
###############
# Preparation #
###############
-ALL_CPV_KWS = []
ARCHES = None
if STABLE:
@@ -299,10 +298,15 @@ def kws_wanted(current_kws, target_kws):
return wanted
-def gen_cpv_kws(cpv, kws_aim, depgraph):
- depgraph.add(cpv)
- cpv_kw_list = [[cpv, kws_wanted(get_kws(cpv, arches=ALL_ARCHES), kws_aim)]]
- if not cpv_kw_list[0][1]:
+def gen_cpv_kws(cpv, kws_aim, depgraph, check_dependencies, new_release):
+ """Build a list of CPV-Keywords.
+
+ If `check_dependencies` is True, append dependencies that need to be
+ updated to the list.
+ """
+ wanted = kws_wanted(get_kws(cpv, arches=ALL_ARCHES), kws_aim)
+
+ if not wanted:
# This happens when cpv has less keywords than kws_aim
# Usually happens when a dep was an || dep, or under a USE-flag
# which is masked in some profiles. We make all deps strict in
@@ -313,23 +317,33 @@ def gen_cpv_kws(cpv, kws_aim, depgraph):
debug('MEH')
nothing_to_be_done(cpv, type='dep')
return None
+
wanted = get_kws(cpv, arches=make_unstable(kws_aim))
- cpv_kw_list = [[cpv, wanted]]
- if CHECK_DEPS and not issystempackage(cpv):
- deps = get_best_deps(cpv, cpv_kw_list[0][1], release=NEW_REL)
+
+ cpv_kw_list = [(cpv, wanted)]
+
+ if check_dependencies and not issystempackage(cpv):
+ deps = get_best_deps(cpv, wanted, release=new_release)
if EXTREME_DEBUG:
debug('The deps of %s are %s' % (cpv, deps))
+
for dep in deps:
if dep in depgraph:
+ # XXX: assumes that `kws_aim` of previously added cpv is
+ # larger than current
continue
+
depgraph.add(dep)
- # Assumes that keyword deps are OK if STABLE
- dep_deps = gen_cpv_kws(dep, cpv_kw_list[0][1], depgraph)
+ # XXX: Assumes that dependencies are keyworded the same than cpv
+ dep_deps = gen_cpv_kws(dep, wanted, depgraph, check_dependencies,
+ new_release)
dep_deps.reverse()
- for i in dep_deps:
- # Make sure we don't already have the same [cpv, [kws]]
- if i not in ALL_CPV_KWS and i not in cpv_kw_list:
- cpv_kw_list.append(i)
+
+ for cpv_kw_tuple in dep_deps:
+ # Make sure we don't already have the same [(cpv, kws)]
+ if cpv_kw_tuple not in cpv_kw_list:
+ cpv_kw_list.append(cpv_kw_tuple)
+
cpv_kw_list.reverse()
return cpv_kw_list
@@ -533,7 +547,10 @@ def main():
nothing_to_be_done(cpv)
continue
- ALL_CPV_KWS += fix_nesting(gen_cpv_kws(cpv, kws_missing, set()))
+ ALL_CPV_KWS += fix_nesting(
+ gen_cpv_kws(cpv, kws_missing, set([cpv]),
+ args.check_dependencies, args.new_version)
+ )
if args.check_dependencies:
ALL_CPV_KWS.append(LINE_SEP)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 5451ec12c9fc4363c7f812c2fc3da253d8ffa306
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: Thu Jun 25 12:46:00 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=5451ec12
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 | 78 ++++++++++++++++++++++++-------------------------
1 file changed, 38 insertions(+), 40 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 6369aa2..b21fba2 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,8 +468,32 @@ def prettify(cpv_kws):
# cpvs that will make it to the final list
def main():
"""Where the magic happens!"""
+ parser = argparse.ArgumentParser(
+ description='Generate a stabilization request for multiple packages'
+ )
+ parser.add_argument('-d', '--debug', action='store_true', default=False,
+ help='Make output more verbose')
+ parser.add_argument('--extreme-debug', action='store_true', default=False,
+ help='Make output even more verbose')
+ parser.add_argument('--check-dependencies',
+ action='store_true', default=False,
+ help='Check dependencies are keyworded and if not,'
+ ' add them to the list')
+ parser.add_argument('--append-slots', action='store_true', default=False,
+ 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()
+
ALL_CPV_KWS = []
- for i in open(CP_FILE).readlines():
+ for i in open(args.file).readlines():
cp = i[:-1]
if cp.startswith('#') or cp.isspace() or not cp:
ALL_CPV_KWS.append(cp)
@@ -508,13 +505,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)
@@ -525,11 +523,11 @@ 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)
- if APPEND_SLOTS:
+ if args.append_slots:
ALL_CPV_KWS = append_slots(ALL_CPV_KWS)
for i in prettify(ALL_CPV_KWS):
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 6d936200f6324e340e823b7925c910d3c340b226
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 25 11:22:16 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:14:39 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=6d936200
scripts/gen_archlist: rewrite consolidates_dupes using sets
scripts/gen_archlist.py | 63 ++++++++++++++-----------------------------------
1 file changed, 18 insertions(+), 45 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 659c84e..d595df3 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -24,6 +24,7 @@
from __future__ import division
import argparse
+import collections
import os
import sys
@@ -41,7 +42,6 @@ UNSTABLE_ARCHES = ('~alpha', '~amd64', '~arm', '~hppa', '~ia64', '~m68k',
'~x86-fbsd')
ALL_ARCHES = STABLE_ARCHES + UNSTABLE_ARCHES
SYSTEM_PACKAGES = []
-LINE_SEP = ''
############
# Settings #
@@ -348,52 +348,27 @@ def gen_cpv_kws(cpv, kws_aim, depgraph, check_dependencies, new_release):
def consolidate_dupes(cpv_kws):
- """
- Consolidate duplicate cpvs with differing keywords
+ """Consolidate duplicate CPVs with differing keywords.
- Cannot handle cps with different versions since we don't know if they are
- inter-changeable
+ Cannot handle CPs with different versions since we don't know if they are
+ inter-changeable.
"""
- cpv_indices = {}
-
- # Find all indices of each cpv
- for each in cpv_kws:
- # Comments/whitespace carried over from original list
- if type(each) is not list:
- continue
- else:
- if each[0] not in cpv_indices:
- cpv_indices[each[0]] = []
- cpv_indices[each[0]].append(cpv_kws.index(each))
+ # Build maximum requested keywords for each cpv
+ cpv_kws_dict = collections.defaultdict(set)
+ for dep_set in cpv_kws:
+ for cpv, kws in dep_set:
+ cpv_kws_dict[cpv].update(kws)
- # Replace the keywords of each cpv with the union of all keywords in the
- # list belonging to this cpv
- for each in cpv_kws:
- # Ignore comments/whitespace carried over from original list
- if type(each) is not list:
- continue
- kws = set()
- for index in cpv_indices[each[0]]:
- kws.update(cpv_kws[index][1])
- each[1] = list(kws)
- each[1].sort()
-
- index = 0
- deduped_cpv_kws = cpv_kws[:]
- deduped_cpv_kws.reverse()
- while index < len(deduped_cpv_kws):
- item = deduped_cpv_kws[index]
- if type(item) is not list:
- index += 1
- continue
- if deduped_cpv_kws.count(item) is 1:
- index += 1
- else:
- while deduped_cpv_kws.count(item) is not 1:
- deduped_cpv_kws.remove(item)
- deduped_cpv_kws.reverse()
+ # Update cpv with their maximum request keywords
+ clean_cpv_kws = []
+ for dep_set in cpv_kws:
+ clean_cpv_kws.append([
+ (cpv, cpv_kws_dict.pop(cpv))
+ # Keep only first occurence of cpv
+ for cpv, _ in dep_set if cpv in cpv_kws_dict
+ ])
- return deduped_cpv_kws
+ return clean_cpv_kws
def get_per_slot_cpvs(cpvs):
@@ -531,8 +506,6 @@ def main():
gen_cpv_kws(cpv, kws_missing, set([cpv]),
args.check_dependencies, args.new_version)
)
- if args.check_dependencies:
- ALL_CPV_KWS.append(LINE_SEP)
ALL_CPV_KWS = consolidate_dupes(ALL_CPV_KWS)
if args.append_slots:
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 813f7fbce53580a4e7302f9d4ce6f40e5410d965
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 13:17:47 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Thu Jun 25 12:46:19 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=813f7fbc
scripts/gen_archlist: rewrite max_kws logic
Not sure if everything is still the same but it got more comments and
looks easier to read.
scripts/gen_archlist.py | 53 +++++++++++++++++++++++++++++--------------------
1 file changed, 32 insertions(+), 21 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 9b60f03..15d5b02 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -248,8 +248,9 @@ def get_best_deps(cpv, kws, release=None):
def max_kws(cpv, release=None):
- """
- Given a cpv, find the intersection of "most keywords it can have" and
+ """Build `cpv` maximum expected keyword coverage.
+
+ Find the intersection of "most keywords it can have" and
"keywords it has", and returns a sorted list
If STABLE; makes sure it has unstable keywords right now
@@ -257,21 +258,29 @@ def max_kws(cpv, release=None):
Returns [] if current cpv has best keywords
Returns None if no cpv has keywords
"""
- current_kws = get_kws(cpv, arches=ALL_ARCHES)
- maximum_kws = [] # Maximum keywords that a cpv has
- missing_kws = []
- for atom in match_wanted_atoms('<='+cpv, release):
+ current_kws = set(get_kws(cpv, arches=ALL_ARCHES))
+ maximum_kws = set() # Maximum keywords that a cpv has
+ missing_kws = set()
+
+ # Build best keyword coverage for `cpv`
+ for atom in match_wanted_atoms('<=' + cpv, release):
kws = get_kws(atom)
- if len(kws) > len(maximum_kws):
- maximum_kws = kws
- for kw in kws:
- if kw not in missing_kws+current_kws:
- if STABLE and '~'+kw not in current_kws:
- continue
- missing_kws.append(kw)
- missing_kws.sort()
- if maximum_kws != []:
- return missing_kws
+
+ # Consider stable keywords only
+ if STABLE:
+ kws = [kwd for kwd in kws if not kwd.startswith('~')]
+
+ maximum_kws.update(set(kws))
+
+ # Build list of keywords missing to achieve best coverage
+ for kwd in maximum_kws:
+ # Skip stable keywords with no corresponding unstable keyword in `cpv`
+ if STABLE and '~' + kwd not in current_kws:
+ continue
+ missing_kws.add(kwd)
+
+ if maximum_kws:
+ return sorted(missing_kws)
else:
# No cpv has the keywords we need
return None
@@ -513,15 +522,17 @@ def main():
continue
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)
- continue
- elif kws_missing is None:
+ if kws_missing is None:
debug('No versions with stable keywords for %s' % cpv)
# No cpv with stable keywords => select latest
arches = make_unstable(ARCHES)
kws_missing = [kw[1:] for kw in get_kws(cpv, arches)]
+
+ elif not kws_missing:
+ # Current cpv has the max keywords => nothing to do
+ nothing_to_be_done(cpv)
+ continue
+
ALL_CPV_KWS += fix_nesting(gen_cpv_kws(cpv, kws_missing, set()))
if args.check_dependencies:
ALL_CPV_KWS.append(LINE_SEP)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-26 22:32 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-26 22:32 UTC (permalink / raw
To: gentoo-commits
commit: 24bd1b67e381e6aa5bff5e597bd3a96c98f4f4a7
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 25 07:57:48 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Thu Jun 25 12:46:23 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=24bd1b67
scripts/gen_archlist: use sets for manipulating keywords
Avoids logic like "if bla not in list then add it" when it is done by
sets already. Sorting can be applied when printing.
scripts/gen_archlist.py | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 6e00ec1..f2a68e5 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -101,10 +101,10 @@ def nothing_to_be_done(atom, type='cpv'):
def make_unstable(kws):
"""Transform `kws` into a list of unstable keywords."""
- return [
+ return set([
kwd if kwd.startswith('~') else '~' + kwd
for kwd in kws
- ]
+ ])
def belongs_release(cpv, release):
@@ -124,10 +124,10 @@ def issystempackage(cpv):
def get_kws(cpv, arches=ARCHES):
"""Return keywords of `cpv` filtered by `arches`."""
- return [
+ return set([
kwd for kwd in portage.portdb.aux_get(cpv, ['KEYWORDS'])[0].split()
if kwd in arches
- ]
+ ])
def can_stabilize_cpv(cpv, release=None):
@@ -188,14 +188,14 @@ def get_best_deps(cpv, kws, release=None):
if STABLE:
# Check that this version has unstable keywords
ukws = make_unstable(kws)
- cur_ukws = set(make_unstable(get_kws(i, arches=kws+ukws)))
- if cur_ukws.intersection(ukws) != set(ukws):
+ cur_ukws = make_unstable(get_kws(i, arches=kws | ukws))
+ if cur_ukws.intersection(ukws) != ukws:
best_kws = 'none'
if DEBUG:
debug('Insufficient unstable keywords in: %s' % i)
continue
cur_match_kws = get_kws(i, arches=kws)
- if set(cur_match_kws) == set(kws):
+ if cur_match_kws == kws:
# This dep already has all keywords
best_kws = 'alreadythere'
break
@@ -279,7 +279,7 @@ def max_kws(cpv, release=None):
missing_kws.add(kwd)
if maximum_kws:
- return sorted(missing_kws)
+ return missing_kws
else:
# No cpv has the keywords we need
return None
@@ -288,13 +288,12 @@ def max_kws(cpv, release=None):
# FIXME: This is broken
def kws_wanted(current_kws, target_kws):
"""Generate a list of kws that need to be updated."""
- wanted = []
+ wanted = set()
for kwd in target_kws:
- if kwd not in current_kws:
- if STABLE and '~' + kwd not in current_kws:
- # Skip stable keywords with no corresponding unstable keyword
- continue
- wanted.append(kwd)
+ if STABLE and '~' + kwd not in current_kws:
+ # Skip stable keywords with no corresponding unstable keyword
+ continue
+ wanted.add(kwd)
return wanted
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-24 12:14 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-24 12:14 UTC (permalink / raw
To: gentoo-commits
commit: 1ed9be28e1c70ea89f68d15cf7456ffd7721f352
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 12:07:21 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Wed Jun 24 12:13:27 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=1ed9be28
scripts/gen_archlist: Simplify functions and try to enhance documentation
scripts/gen_archlist.py | 46 ++++++++++++++++++++--------------------------
1 file changed, 20 insertions(+), 26 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 1a57fe2..8ec59c0 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -101,14 +101,11 @@ def nothing_to_be_done(atom, type='cpv'):
def make_unstable(kws):
- "Takes a keyword list, and returns a list with them all unstable"
- nkws = []
- for kw in kws:
- if not kw.startswith('~'):
- nkws.append('~'+kw)
- else:
- nkws.append(kw)
- return nkws
+ """Transform `kws` into a list of unstable keywords."""
+ return [
+ kwd if kw.startswith('~') else '~' + kwd
+ for kwd in kws
+ ]
def belongs_release(cpv, release):
@@ -127,14 +124,11 @@ def issystempackage(cpv):
def get_kws(cpv, arches=ARCHES):
- """
- Returns an array of KEYWORDS matching 'arches'
- """
- kws = []
- for kw in portage.portdb.aux_get(cpv, ['KEYWORDS'])[0].split():
- if kw in arches:
- kws.append(kw)
- return kws
+ """Return keywords of `cpv` filtered by `arches`."""
+ return [
+ for keyword in portage.portdb.aux_get(cpv, ['KEYWORDS'])[0].split()
+ if keyword in arches
+ ]
def do_not_want(cpv, release=None):
@@ -149,20 +143,20 @@ def do_not_want(cpv, release=None):
def match_wanted_atoms(atom, release=None):
+ """Return a list of CPV matching `atom`.
+
+ If `release` is provided, CPVs are filtered against it.
+
+ The list is sorted by descending order of version.
"""
- Given an atom and a release, return all matching wanted atoms ordered in
- descending order of version
- """
- atoms = []
# xmatch is stupid, and ignores ! in an atom...
if atom.startswith('!'):
return []
- for cpv in portage.portdb.xmatch('match-all', atom):
- if do_not_want(cpv, release):
- continue
- atoms.append(cpv)
- atoms.reverse()
- return atoms
+
+ return [
+ for cpv in reversed(portage.portdb.xmatch('match-all', atom)):
+ if not do_not_want(cpv, release)
+ ]
def get_best_deps(cpv, kws, release=None):
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-24 12:14 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-24 12:14 UTC (permalink / raw
To: gentoo-commits
commit: 1bd25971019ba10858560e79e3040b5d4101f61a
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 11:23:40 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Wed Jun 24 12:11:21 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=1bd25971
scripts/gen_archlist: Create a clear main function
scripts/gen_archlist.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 407ebbd..e41b20d 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -493,10 +493,8 @@ def prettify(cpv_kws):
# Use the Functions #
#####################
# cpvs that will make it to the final list
-if __name__ == "__main__":
- index = 0
- array = []
-
+def main():
+ """Where the magic happens!"""
for i in open(CP_FILE).readlines():
cp = i[:-1]
if cp.startswith('#') or cp.isspace() or not cp:
@@ -535,3 +533,7 @@ if __name__ == "__main__":
for i in prettify(ALL_CPV_KWS):
print i[0], flatten(i[1])
+
+
+if __name__ == '__main__':
+ main()
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-24 12:14 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-24 12:14 UTC (permalink / raw
To: gentoo-commits
commit: 628bef00999b4d6250169a5bf9b73dc7bc671015
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 12:07:39 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Wed Jun 24 12:13:27 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=628bef00
scripts/gen_archlist: Fix belongs_release
get_ver is undefined, I wonder how this could ever work.
scripts/gen_archlist.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 8ec59c0..a517ed8 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -109,11 +109,11 @@ def make_unstable(kws):
def belongs_release(cpv, release):
- "Check if the given cpv belongs to the given release"
+ """Check if `cpv` belongs to the release `release`."""
# FIXME: This failure function needs better logic
if CHECK_DEPS:
raise Exception('This function is utterly useless with RECURSIVE mode')
- return get_ver(cpv).startswith(release)
+ return portage.versions.cpv_get_version(cpv).startswith(release)
def issystempackage(cpv):
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-24 12:14 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-24 12:14 UTC (permalink / raw
To: gentoo-commits
commit: 06183b984bf5b65d00f3a48fc825019fdc40a524
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 12:08:20 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Wed Jun 24 12:13:28 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=06183b98
scripts/gen_archlist: Rename do_not_want function
Give it a better name of split logic down in multiple lines, it is
easier to read that a kilometric if line.
Logic was inverted to avoid double negation in match_wanted_atoms
function.
scripts/gen_archlist.py | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index a517ed8..a8b5fcf 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -131,15 +131,21 @@ def get_kws(cpv, arches=ARCHES):
]
-def do_not_want(cpv, release=None):
- """
- Check if a package atom is p.masked or has empty keywords, or does not
- belong to a release
+def can_stabilize_cpv(cpv, release=None):
+ """Whether `cpv` matches stabilization criteria.
+
+ `cpv` must:
+ * belong to the release
+ * not be p.masked
+ * have keywords
"""
- if release and not belongs_release(cpv, release) or not \
- portage.portdb.visible([cpv]) or not get_kws(cpv, arches=ALL_ARCHES):
- return True
- return False
+ if release and not belongs_release(cpv, release):
+ return False
+ if not portage.portdb.visible([cpv]):
+ return False
+ if not get_kws(cpv, arches=ALL_ARCHES):
+ return False
+ return True
def match_wanted_atoms(atom, release=None):
@@ -155,7 +161,7 @@ def match_wanted_atoms(atom, release=None):
return [
for cpv in reversed(portage.portdb.xmatch('match-all', atom)):
- if not do_not_want(cpv, release)
+ if can_stabilize_cpv(cpv, release)
]
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-24 12:14 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-24 12:14 UTC (permalink / raw
To: gentoo-commits
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)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
@ 2015-06-24 12:14 Gilles Dartiguelongue
0 siblings, 0 replies; 28+ messages in thread
From: Gilles Dartiguelongue @ 2015-06-24 12:14 UTC (permalink / raw
To: gentoo-commits
commit: 3e63b913e81f842dfac1b76bb9a5d1fdcbcd5236
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 24 09:35:49 2015 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Wed Jun 24 12:11:10 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=3e63b913
scripts/gen_archlist: Apply PEP8 rules
scripts/gen_archlist.py | 145 ++++++++++++++++++++++++++++++------------------
1 file changed, 90 insertions(+), 55 deletions(-)
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index fa26b90..407ebbd 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -10,10 +10,10 @@
# You can use test-data/package-list to test the script out.
#
# NOTE: This script assumes that there are no broken keyword deps
-#
+#
# BUGS:
-# * belongs_release() is a very primitive function, which means usage of old/new
-# release numbers gives misleading output
+# * belongs_release() is a very primitive function, which means usage of
+# old/new release numbers gives misleading output
# * Will show multiple versions of the same package in the output sometimes.
# This happens when a cp is specified in the cpv list, and is resolved as
# a dependency as well.
@@ -22,25 +22,29 @@
#
from __future__ import division
-import os, sys
+
+import os
+import sys
+
import portage
-###############
-## Constants ##
-###############
-#GNOME_OVERLAY = PORTDB.getRepositoryPath('gnome')
+#############
+# Constants #
+#############
+# GNOME_OVERLAY = PORTDB.getRepositoryPath('gnome')
portage.portdb.porttrees = [portage.settings['PORTDIR']]
STABLE_ARCHES = ('alpha', 'amd64', 'arm', 'hppa', 'ia64', 'm68k', 'ppc',
- 'ppc64', 's390', 'sh', 'sparc', 'x86')
-UNSTABLE_ARCHES = ('~alpha', '~amd64', '~arm', '~hppa', '~ia64', '~m68k', '~ppc',
- '~ppc64', '~s390', '~sh', '~sparc', '~x86', '~x86-fbsd')
-ALL_ARCHES = STABLE_ARCHES+UNSTABLE_ARCHES
+ 'ppc64', 's390', 'sh', 'sparc', 'x86')
+UNSTABLE_ARCHES = ('~alpha', '~amd64', '~arm', '~hppa', '~ia64', '~m68k',
+ '~ppc', '~ppc64', '~s390', '~sh', '~sparc', '~x86',
+ '~x86-fbsd')
+ALL_ARCHES = STABLE_ARCHES + UNSTABLE_ARCHES
SYSTEM_PACKAGES = []
LINE_SEP = ''
-##############
-## Settings ##
-##############
+############
+# Settings #
+############
DEBUG = False
EXTREME_DEBUG = False
CHECK_DEPS = False
@@ -48,40 +52,45 @@ APPEND_SLOTS = False
# Check for stable keywords
STABLE = True
-#################
-## Preparation ##
-#################
+###############
+# 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
+ CP_FILE = sys.argv[1] # File which has the cp list
except IndexError:
- print 'Usage: %s <file> [old_rel] [new_rel]' % sys.argv[0]
- print 'Where <file> is a file with a category/package list'
- print ' [old_rel] is an optional argument for specifying which release cycle'
- print ' to use to get the cpv which has the keyword we need'
- print ' i.e., which cpvs will we get the list of keywords from?'
- print ' [new_rel] is an optional argument for specifying which release cycle'
- print ' to use to get the latest cpv on which we want keywords'
- print ' i.e., which cpvs will go in the list?'
- print 'WARNING: the logic for old_rel & new_rel is very incomplete. See TODO'
+ 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:
ARCHES = STABLE_ARCHES
else:
ARCHES = UNSTABLE_ARCHES
-if os.environ.has_key('CHECK_DEPS'):
+if 'CHECK_DEPS' in os.environ:
CHECK_DEPS = os.environ['CHECK_DEPS']
-if os.environ.has_key('APPEND_SLOTS'):
+if 'APPEND_SLOTS' in os.environ:
APPEND_SLOTS = os.environ['APPEND_SLOTS']
if not STABLE:
@@ -89,30 +98,35 @@ if not STABLE:
print 'Please set STABLE to True'
sys.exit(1)
-######################
-## Define Functions ##
-######################
+
+####################
+# Define Functions #
+####################
def flatten(list, sep=' '):
"Given a list, returns a flat string separated by 'sep'"
return sep.join(list)
+
def n_sep(n, sep=' '):
tmp = ''
for i in range(0, n):
tmp += sep
return tmp
+
def debug(*strings):
from portage.output import EOutput
ewarn = EOutput().ewarn
ewarn(flatten(strings))
+
def nothing_to_be_done(atom, type='cpv'):
if STABLE:
debug('%s %s: already stable, ignoring...' % (type, atom))
else:
debug('%s %s: already keyworded, ignoring...' % (type, atom))
+
def make_unstable(kws):
"Takes a keyword list, and returns a list with them all unstable"
nkws = []
@@ -123,6 +137,7 @@ def make_unstable(kws):
nkws.append(kw)
return nkws
+
def belongs_release(cpv, release):
"Check if the given cpv belongs to the given release"
# FIXME: This failure function needs better logic
@@ -130,12 +145,14 @@ def belongs_release(cpv, release):
raise Exception('This function is utterly useless with RECURSIVE mode')
return get_ver(cpv).startswith(release)
+
def issystempackage(cpv):
for i in SYSTEM_PACKAGES:
if cpv.startswith(i):
return True
return False
+
def get_kws(cpv, arches=ARCHES):
"""
Returns an array of KEYWORDS matching 'arches'
@@ -146,6 +163,7 @@ def get_kws(cpv, arches=ARCHES):
kws.append(kw)
return kws
+
def do_not_want(cpv, release=None):
"""
Check if a package atom is p.masked or has empty keywords, or does not
@@ -156,6 +174,7 @@ def do_not_want(cpv, release=None):
return True
return False
+
def match_wanted_atoms(atom, release=None):
"""
Given an atom and a release, return all matching wanted atoms ordered in
@@ -163,7 +182,8 @@ def match_wanted_atoms(atom, release=None):
"""
atoms = []
# xmatch is stupid, and ignores ! in an atom...
- if atom.startswith('!'): return []
+ if atom.startswith('!'):
+ return []
for cpv in portage.portdb.xmatch('match-all', atom):
if do_not_want(cpv, release):
continue
@@ -171,14 +191,15 @@ def match_wanted_atoms(atom, release=None):
atoms.reverse()
return atoms
+
def get_best_deps(cpv, kws, release=None):
"""
- Returns a list of the best deps of a cpv, optionally matching a release, and
- with max of the specified keywords
+ Returns a list of the best deps of a cpv, optionally matching a release,
+ and with max of the specified keywords
"""
atoms = portage.portdb.aux_get(cpv, ['DEPEND', 'RDEPEND', 'PDEPEND'])
- atoms = ' '.join(atoms).split() # consolidate atoms
- atoms = list(set(atoms)) # de-duplicate
+ atoms = ' '.join(atoms).split() # consolidate atoms
+ atoms = list(set(atoms)) # de-duplicate
deps = set()
tmp = []
for atom in atoms:
@@ -187,7 +208,8 @@ def get_best_deps(cpv, kws, release=None):
continue
ret = match_wanted_atoms(atom, release)
if not ret:
- if DEBUG: debug('We encountered an irrelevant atom: %s' % atom)
+ if DEBUG:
+ debug('We encountered an irrelevant atom: %s' % atom)
continue
best_kws = ['', []]
for i in ret:
@@ -197,7 +219,8 @@ def get_best_deps(cpv, kws, release=None):
cur_ukws = set(make_unstable(get_kws(i, arches=kws+ukws)))
if cur_ukws.intersection(ukws) != set(ukws):
best_kws = 'none'
- if DEBUG: debug('Insufficient unstable keywords in: %s' % i)
+ if DEBUG:
+ debug('Insufficient unstable keywords in: %s' % i)
continue
cur_match_kws = get_kws(i, arches=kws)
if set(cur_match_kws) == set(kws):
@@ -212,14 +235,16 @@ def get_best_deps(cpv, kws, release=None):
# keywords that *we checked* (i.e. kws).
best_kws = [i, []]
if best_kws == 'alreadythere':
- if DEBUG: nothing_to_be_done(atom, type='dep')
+ if DEBUG:
+ nothing_to_be_done(atom, type='dep')
continue
elif best_kws == 'none':
continue
elif not best_kws[0]:
# We get this when the if STABLE: block above rejects everything.
- # This means that this atom does not have any versions with unstable
- # keywords matching the unstable keywords of the cpv that pulls it.
+ # This means that this atom does not have any versions with
+ # unstable keywords matching the unstable keywords of the cpv
+ # that pulls it.
# This mostly happens because an || or use dep exists. However, we
# make such deps strict while parsing
# XXX: We arbitrarily select the most recent version for this case
@@ -239,15 +264,16 @@ def get_best_deps(cpv, kws, release=None):
if len(cur_kws) > len(best_kws[1]):
best_kws = [i, cur_kws]
elif not best_kws[0]:
- # This means that none of the versions have any of the stable
- # keywords *at all*. No choice but to arbitrarily select the
- # latest version in that case.
+ # This means that none of the versions have any of
+ # the stable keywords *at all*. No choice but to
+ # arbitrarily select the latest version in that case.
best_kws = [i, []]
deps.add(best_kws[0])
else:
deps.add(best_kws[0])
return list(deps)
+
def max_kws(cpv, release=None):
"""
Given a cpv, find the intersection of "most keywords it can have" and
@@ -259,7 +285,7 @@ def max_kws(cpv, release=None):
Returns None if no cpv has keywords
"""
current_kws = get_kws(cpv, arches=ALL_ARCHES)
- maximum_kws = [] # Maximum keywords that a cpv has
+ maximum_kws = [] # Maximum keywords that a cpv has
missing_kws = []
for atom in match_wanted_atoms('<='+cpv, release):
kws = get_kws(atom)
@@ -277,6 +303,7 @@ def max_kws(cpv, release=None):
# No cpv has the keywords we need
return None
+
# FIXME: This is broken
def kws_wanted(cpv_kws, prev_cpv_kws):
"Generate a list of kws that need to be updated"
@@ -289,13 +316,15 @@ def kws_wanted(cpv_kws, prev_cpv_kws):
wanted.append(kw)
return wanted
+
def gen_cpv_kws(cpv, kws_aim, depgraph):
depgraph.add(cpv)
cpv_kw_list = [[cpv, kws_wanted(get_kws(cpv, arches=ALL_ARCHES), kws_aim)]]
if not cpv_kw_list[0][1]:
# This happens when cpv has less keywords than kws_aim
- # Usually happens when a dep was an || dep, or under a USE-flag which is
- # masked in some profiles. We make all deps strict in get_best_deps()
+ # Usually happens when a dep was an || dep, or under a USE-flag
+ # which is masked in some profiles. We make all deps strict in
+ # get_best_deps()
# So... let's just stabilize it on all arches we can, and ignore for
# keywording since we have no idea about that.
if not STABLE:
@@ -322,6 +351,7 @@ def gen_cpv_kws(cpv, kws_aim, depgraph):
cpv_kw_list.reverse()
return cpv_kw_list
+
def fix_nesting(nested_list):
"""Takes a list of unknown nesting depth, and gives a nice list with each
element of the form [cpv, [kws]]"""
@@ -340,6 +370,7 @@ def fix_nesting(nested_list):
index += 1
return nice_list
+
def consolidate_dupes(cpv_kws):
"""
Consolidate duplicate cpvs with differing keywords
@@ -355,7 +386,7 @@ def consolidate_dupes(cpv_kws):
if type(each) is not list:
continue
else:
- if not cpv_indices.has_key(each[0]):
+ if each[0] not in cpv_indices:
cpv_indices[each[0]] = []
cpv_indices[each[0]].append(cpv_kws.index(each))
@@ -388,6 +419,7 @@ def consolidate_dupes(cpv_kws):
return deduped_cpv_kws
+
def get_per_slot_cpvs(cpvs):
"Classify the given cpvs into slots, and yield the best atom for each slot"
slots = set()
@@ -398,6 +430,7 @@ def get_per_slot_cpvs(cpvs):
slots.add(slot)
yield cpv
+
def append_slots(cpv_kws):
"Append slots at the end of cpv atoms"
slotifyed_cpv_kws = []
@@ -407,6 +440,7 @@ def append_slots(cpv_kws):
slotifyed_cpv_kws.append([cpv, kws])
return slotifyed_cpv_kws
+
# FIXME: This is broken
def prettify(cpv_kws):
"Takes a list of [cpv, [kws]] and prettifies it"
@@ -454,9 +488,10 @@ def prettify(cpv_kws):
pretty_list.append([each[0], each[1]])
return pretty_list
-#######################
-## Use the Functions ##
-#######################
+
+#####################
+# Use the Functions #
+#####################
# cpvs that will make it to the final list
if __name__ == "__main__":
index = 0
@@ -485,8 +520,8 @@ if __name__ == "__main__":
# Current cpv has the max keywords => nothing to do
nothing_to_be_done(cpv)
continue
- elif kws_missing == None:
- debug ('No versions with stable keywords for %s' % cpv)
+ elif kws_missing is None:
+ debug('No versions with stable keywords for %s' % cpv)
# No cpv with stable keywords => select latest
arches = make_unstable(ARCHES)
kws_missing = [kw[1:] for kw in get_kws(cpv, arches)]
^ permalink raw reply related [flat|nested] 28+ messages in thread
end of thread, other threads:[~2015-09-06 16:53 UTC | newest]
Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-26 22:32 [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/ Gilles Dartiguelongue
-- strict thread matches above, loose matches on Subject: below --
2015-09-06 16:53 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox