From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1724032-garchives=archives.gentoo.org@lists.gentoo.org> Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 445B91582EF for <garchives@archives.gentoo.org>; Wed, 05 Mar 2025 11:20:40 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 2E667343005 for <garchives@archives.gentoo.org>; Wed, 05 Mar 2025 11:20:40 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 241521102D0; Wed, 05 Mar 2025 11:20:39 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 194991102D0 for <gentoo-commits@lists.gentoo.org>; Wed, 05 Mar 2025 11:20:39 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B5E61343005 for <gentoo-commits@lists.gentoo.org>; Wed, 05 Mar 2025 11:20:38 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 23D5E2853 for <gentoo-commits@lists.gentoo.org>; Wed, 05 Mar 2025 11:20:37 +0000 (UTC) From: "Sam James" <sam@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org> Message-ID: <1741173633.132c0d4cb5ae879ed1e125ab83c30cd4ce1a5274.sam@gentoo> Subject: [gentoo-commits] proj/qa-scripts:master commit in: / X-VCS-Repository: proj/qa-scripts X-VCS-Files: leaf-packages.py X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 132c0d4cb5ae879ed1e125ab83c30cd4ce1a5274 X-VCS-Branch: master Date: Wed, 05 Mar 2025 11:20:37 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 81a721dd-09e6-472e-9eff-5b790701c7c8 X-Archives-Hash: 06944e4caf7f1a42eb4e6a7e1f2d559a commit: 132c0d4cb5ae879ed1e125ab83c30cd4ce1a5274 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Wed Mar 5 11:20:33 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Wed Mar 5 11:20:33 2025 +0000 URL: https://gitweb.gentoo.org/proj/qa-scripts.git/commit/?id=132c0d4c leaf-packages.py: delete We now use dev-python/pkgcraft's pkgcraft-leaf-pkgs which takes far less time (1m or so) as opposed to several hours. Signed-off-by: Sam James <sam <AT> gentoo.org> leaf-packages.py | 118 ------------------------------------------------------- 1 file changed, 118 deletions(-) diff --git a/leaf-packages.py b/leaf-packages.py deleted file mode 100755 index 1454eb8..0000000 --- a/leaf-packages.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env python -# From Leo3418's GSoC 2021 work -# https://leo3418.github.io/2021/07/18/find-leaf-packages.html - -import concurrent.futures -import os -import re -import subprocess -import sys - -METHOD="pkgcore" -VERBOSE=int(os.getenv('VERBOSE') or os.getenv('V') or 0) # V=1..N to use - -def main() -> None: - if len(sys.argv) > 1: - repo = sys.argv[1] - else: - repo = 'gentoo' - zero_in_degree = create_ebuild_dict(repo) - with concurrent.futures.ThreadPoolExecutor(max_workers=os.cpu_count()) \ - as executor: - for ebuild in zero_in_degree: - # Let the executor run function call - # update_for_deps_of(ebuild, zero_in_degree) - if METHOD == "pkgcore": - executor.submit(update_for, ebuild, zero_in_degree, repo) - else: - executor.submit(update_for_deps_of, ebuild, zero_in_degree) - - # Print leaf ebuilds to standard output - for ebuild in zero_in_degree: - if zero_in_degree[ebuild]: - print(ebuild) - - -def update_for(ebuild: str, zero_in_degree: dict, repo: str) -> None: - """ - Update the boolean value for the specified ebuild in the given dictionary. - Reverse dependencies of the ebuild will be searched in the specified - repository only. - """ - # This spams infra cronjobs, only enable if there is a problem - if VERBOSE >= 1: - print(f"Processing {ebuild} ...", file=sys.stderr) - proc = subprocess.run(f'pquery --first --restrict-revdep ={ebuild} ' - f'--repo {repo} --raw --unfiltered', - capture_output=True, text=True, shell=True) - zero_in_degree[ebuild] = len(proc.stdout) == 0 - -def create_ebuild_dict(repo: str) -> dict: - """ - Create a dictionary with all ebuilds in the specified repository as keys - that maps each key to a boolean value indicating whether it is a leaf - ebuild with zero in-degree. - """ - zero_in_degree = {} - proc = subprocess.run(f'pquery --repo {repo} --raw --unfiltered', - capture_output=True, text=True, - shell=True, check=True) - ebuilds = proc.stdout.splitlines() - for ebuild in ebuilds: - zero_in_degree[ebuild] = True - return zero_in_degree - - -def update_for_deps_of(ebuild: str, zero_in_degree: dict) -> None: - """ - For ebuilds that can be pulled as the specified ebuild's dependencies, - update the boolean value for them in the given dictionary accordingly. - """ - - def get_dep_atoms() -> list: - """ - Return a list of all dependency specification atoms. - """ - dep_atoms = [] - equery_dep_atom_pattern = re.compile(r'\(.+/.+\)') - proc = subprocess.run(f'equery -CN depgraph -MUl {ebuild}', - capture_output=True, text=True, shell=True) - out_lines = proc.stdout.splitlines() - for line in out_lines: - dep_atom_match = equery_dep_atom_pattern.findall(line) - dep_atom = [dep.strip('()') for dep in dep_atom_match] - dep_atoms.extend(dep_atom) - return dep_atoms - - def find_matching_ebuilds(atom: str) -> list: - """ - Return a list of ebuilds that satisfy an atom. - """ - proc = subprocess.run(f"equery list -op -F '$cpv' '{atom}'", - capture_output=True, text=True, shell=True) - return proc.stdout.splitlines() - - if VERBOSE >= 2: - print(f"Processing {ebuild} ...", file=sys.stderr) - - # Get dependency specifications in the ebuild; - # equivalent to dep_graph[ebuild] in the examples above - dep_atoms = get_dep_atoms() - - # Convert list of atoms to list of ebuilds that satisfy them - dep_ebuilds = [] - for dep_atom in dep_atoms: - dep_ebuilds.extend(find_matching_ebuilds(dep_atom)) - - # Register dependency ebuilds as non-leaves - for dep_ebuild in dep_ebuilds: - # An ebuild in an overlay might depend on ebuilds from ::gentoo and/or - # other repositories, but we only care about ebuilds in the dictionary - # passed to this function - if dep_ebuild in zero_in_degree: - zero_in_degree[dep_ebuild] = False - - -if __name__ == '__main__': - main() -