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 14C8F138CEE for ; Fri, 26 Jun 2015 22:32:25 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 40BC7E086D; Fri, 26 Jun 2015 22:32:12 +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 AC537E084B for ; Fri, 26 Jun 2015 22:32:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B92CA340A30 for ; Fri, 26 Jun 2015 22:32:07 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id EBD2573B 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: <1435356880.c33a3166cd55a0245663cbb1472ef04fda4c44f8.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: c33a3166cd55a0245663cbb1472ef04fda4c44f8 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: 0d02238d-78b9-41e1-bd3c-5a66b27e1229 X-Archives-Hash: 6eb0005369cb33c5a7743b465969a4d3 commit: c33a3166cd55a0245663cbb1472ef04fda4c44f8 Author: Gilles Dartiguelongue gentoo org> AuthorDate: Thu Jun 25 13:31:07 2015 +0000 Commit: Gilles Dartiguelongue gentoo 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)