From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 5910F138CEE for ; Fri, 26 Jun 2015 22:32:16 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B74D4E0858; Fri, 26 Jun 2015 22:32:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3360AE084B for ; Fri, 26 Jun 2015 22:32:07 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3842C340A60 for ; Fri, 26 Jun 2015 22:32:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 6F3A6734 for ; Fri, 26 Jun 2015 22:32:03 +0000 (UTC) From: "Gilles Dartiguelongue" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Gilles Dartiguelongue" Message-ID: <1435236379.813f7fbce53580a4e7302f9d4ce6f40e5410d965.eva@gentoo> Subject: [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/ X-VCS-Repository: proj/gnome X-VCS-Files: scripts/gen_archlist.py X-VCS-Directories: scripts/ X-VCS-Committer: eva X-VCS-Committer-Name: Gilles Dartiguelongue X-VCS-Revision: 813f7fbce53580a4e7302f9d4ce6f40e5410d965 X-VCS-Branch: gen_archlist_cleanup Date: Fri, 26 Jun 2015 22:32:03 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 995d91cc-53b4-418d-99bc-fb1d8b295994 X-Archives-Hash: 9aec94ae15de4ed04d0459c05fc9c5e8 commit: 813f7fbce53580a4e7302f9d4ce6f40e5410d965 Author: Gilles Dartiguelongue gentoo org> AuthorDate: Wed Jun 24 13:17:47 2015 +0000 Commit: Gilles Dartiguelongue gentoo 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)