From patchwork Tue Oct 8 19:31:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 50066 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30A10CEFC51 for ; Tue, 8 Oct 2024 19:31:24 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.4701.1728415875840450543 for ; Tue, 08 Oct 2024 12:31:15 -0700 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1D3B5FEC for ; Tue, 8 Oct 2024 12:31:45 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.oss.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 082B83F73F for ; Tue, 8 Oct 2024 12:31:14 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 08/10] insane: micro-optimise the sweep of pkgfiles Date: Tue, 8 Oct 2024 20:31:01 +0100 Message-Id: <20241008193103.2429829-8-ross.burton@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241008193103.2429829-1-ross.burton@arm.com> References: <20241008193103.2429829-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 08 Oct 2024 19:31:24 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/205308 Don't actively do more work: - Exit early if there are no packages being generated - Don't iterate repeatedly when removing CONTROL and DEBIAN - Extend a list with another list instead of appending item by item - Remove unused variables Signed-off-by: Ross Burton --- meta/classes-global/insane.bbclass | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass index b165f111cec..686040f7a48 100644 --- a/meta/classes-global/insane.bbclass +++ b/meta/classes-global/insane.bbclass @@ -1084,13 +1084,8 @@ parse_test_matrix[vardepsexclude] = "ERROR_QA WARN_QA" # The PACKAGE FUNC to scan each package python do_package_qa () { - import subprocess import oe.packagedata - bb.note("DO PACKAGE QA") - - main_lic = d.getVar('LICENSE') - # Check for obsolete license references in main LICENSE (packages are checked below for any changes) main_licenses = oe.license.list_licenses(d.getVar('LICENSE')) obsolete = set(oe.license.obsolete_license_list()) & main_licenses @@ -1106,27 +1101,27 @@ python do_package_qa () { pn = d.getVar('PN') # Scan the packages... - pkgdest = d.getVar('PKGDEST') packages = set((d.getVar('PACKAGES') or '').split()) + # no packages should be scanned + if not packages: + return global pkgfiles pkgfiles = {} + pkgdest = d.getVar('PKGDEST') for pkg in packages: - pkgfiles[pkg] = [] pkgdir = os.path.join(pkgdest, pkg) + pkgfiles[pkg] = [] for walkroot, dirs, files in os.walk(pkgdir): # Don't walk into top-level CONTROL or DEBIAN directories as these # are temporary directories created by do_package. if walkroot == pkgdir: - for control in ("CONTROL", "DEBIAN"): - if control in dirs: - dirs.remove(control) - for file in files: - pkgfiles[pkg].append(os.path.join(walkroot, file)) - - # no packages should be scanned - if not packages: - return + try: + dirs.remove("CONTROL") + dirs.remove("DEBIAN") + except ValueError: + pass + pkgfiles[pkg].extend((os.path.join(walkroot, f) for f in files)) import re # The package name matches the [a-z0-9.+-]+ regular expression