From patchwork Mon Nov 30 01:13:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Orling X-Patchwork-Id: 106334 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.23719.1796001253190620925 for ; Sun, 29 Nov 2026 17:14:13 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@konsulko.com header.s=google header.b=eRPxzoOf; spf=pass (domain: konsulko.com, ip: 209.85.214.177, mailfrom: tim.orling@konsulko.com) Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2f066274caeso47537715ad.2 for ; Sun, 29 Nov 2026 17:14:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1796001252; x=1796606052; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=D2vlSqAvc+vC13fvW3W5Z4aqaP9vdEF0TKxepi29bTQ=; b=eRPxzoOfUkDvX/fKV71yU1HBbSviAeg7BpEC7mKiZRk6aZS4yfftYFX7ErwEnGkSZu WzaJFV+mNxFW1jdDLmKUl6eh7p9PlblAt6ZtvWF2P+zCtTfgS0F2JlyvkAZhFBgLpXM1 NDd944gG67zMaDR7W+y7Y0CW7NcZLZ8gVGgjI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796001252; x=1796606052; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=D2vlSqAvc+vC13fvW3W5Z4aqaP9vdEF0TKxepi29bTQ=; b=DEeBwlVoL4wQgnIRNx3Sc4QwyYswZSTtUUklemuQ4jdMvOTZWZ0mTy8y8dSq3DIu/G D1h4izzaASN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vmTJuP7s7nYMM4TiwfvqQJR+M2NL6ASS1Non4UPRJ6gCi5rdRqE3XrDYJ2tly2jP1c= X-Received: by 2002:a17:903:298d:b0:2e9:740c:36c with SMTP id d9443c01a7336-2f03f1ba67amr324154965ad.41.1796001252401; Sun, 29 Nov 2026 17:14:12 -0800 (PST) Return-Path: Received: from localhost (c-24-20-171-118.hsd1.or.comcast.net. [24.20.171.118]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f0c6e50sm156163475ad.13.2026.11.29.17.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 17:14:12 -0800 (PST) From: Tim Orling To: openembedded-core@lists.openembedded.org Cc: Tim Orling Subject: [PATCH 3/5] classes/insane: add perl-rdeps QA check Date: Sun, 29 Nov 2026 17:13:59 -0800 Message-ID: <20261130011401.68860-4-tim.orling@konsulko.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130011401.68860-1-tim.orling@konsulko.com> References: <20261130011401.68860-1-tim.orling@konsulko.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Mon, 30 Nov 2026 01:14:22 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251564 Perl runtime dependencies are maintained by hand, and gaps usually only show up at runtime or in ptests. Add an opt-in perl-rdeps check which runs perl.req over each package's Perl files and warns about perl(Module::Name) requirements not provided by the package or its transitive RDEPENDS, suggesting the pkgdata package that provides them. Requirements with no provider in pkgdata are only logged. Not enabled by default: perl.req cannot tell optional requirements apart, and results depend on what is already in pkgdata. Enable with WARN_QA:append = " perl-rdeps". Tested on qemux86-64 with perl and the perl module recipes in oe-core; it finds real gaps in e.g. groff, texinfo, git-perltools and libxml-perl. [YOCTO #13376] AI-Generated: Uses Claude Code (Claude Opus 5.5) Signed-off-by: Tim Orling --- meta/classes-global/insane.bbclass | 128 +++++++++++++++++++++++++++++ meta/lib/oe/package.py | 22 +++++ 2 files changed, 150 insertions(+) diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass index 350e1f83c2..b78e95b659 100644 --- a/meta/classes-global/insane.bbclass +++ b/meta/classes-global/insane.bbclass @@ -1004,6 +1004,130 @@ def package_qa_check_unlisted_pkg_lics(package, d): oe.qa.handle_error("obsolete-license", "LICENSE:%s includes obsolete licenses %s" % (package, ' '.join(obsolete)), d) +def perl_rdeps_provider_index(d): + """ + Map each perl(Module::Name) found in the FILERPROVIDES of pkgdata to the + first (sorted) package providing it. Only used to suggest a fix, so it is + built lazily and cached for the rest of the task. + """ + index = d.getVar("__perl_rdeps_provider_index", False) + if index is not None: + return index + + index = {} + rundir = os.path.join(d.getVar("PKGDATA_DIR"), "runtime") + for name in sorted(os.listdir(rundir)): + fn = os.path.join(rundir, name) + # ptest packages provide test fixture modules, not real ones + if name.endswith((".packaged", "-ptest")) or not os.path.isfile(fn): + continue + with open(fn, "r") as f: + for line in f: + if line.startswith("FILERPROVIDES:") and "perl(" in line: + for dep in bb.utils.explode_deps(line.split(": ", 1)[1]): + index.setdefault(dep, name) + d.setVar("__perl_rdeps_provider_index", index) + return index + +# This check was written with the help of an AI tool (Claude Code). +QAPKGTEST[perl-rdeps] = "package_qa_check_perl_rdeps" +def package_qa_check_perl_rdeps(pkg, d): + """ + Check that the perl(Module::Name) requirements of the Perl files in a + package are provided by the package itself or its (transitive) RDEPENDS, + using FILERPROVIDES and FILES_INFO in pkgdata. perl.req cannot tell + optional requirements apart, so reports can be false positives. + """ + import json + import oe.package + import oe.packagedata + + # Not runtime code: debug data, sources, and examples shipped as docs + if pkg.endswith(("-dbg", "-src", "-doc")): + return + + perl_files = [] + for path in pkgfiles[pkg]: + if os.path.islink(path): + continue + if path.endswith((".pm", ".pl", ".t")): + perl_files.append(path) + elif os.access(path, os.X_OK): + try: + with open(path, "rb") as f: + line = f.readline(128) + except OSError: + continue + if line.startswith(b"#!") and b"perl" in line: + perl_files.append(path) + if not perl_files: + return + + required = oe.package.perl_requires(d, perl_files) + + # Walk the runtime dependency graph until every requirement is provided, + # either as a perl() FILERPROVIDES or, for files without a matching + # "package" statement, as a shipped Foo/Bar.pm + def module_path(dep): + return "/" + dep[5:-1].replace("::", "/") + ".pm" + + # Cache parsed pkgdata across the packages of the recipe + cache = d.getVar("__perl_rdeps_pkgdata", False) + if cache is None: + cache = {} + d.setVar("__perl_rdeps_pkgdata", cache) + + rprovides_dir = os.path.join(d.getVar("PKGDATA_DIR"), "runtime-rprovides") + + def providers(rdep): + try: + return set(os.listdir(os.path.join(rprovides_dir, rdep))) | {rdep} + except OSError: + return {rdep} + + def pkg_info(name): + if name not in cache: + data = oe.packagedata.read_subpkgdata(name, d) + provides = set() + for key, value in data.items(): + if key.startswith("FILERPROVIDES:"): + provides.update(bb.utils.explode_deps(value)) + elif key.startswith("FILES_INFO:"): + # Every "/Foo/Bar.pm" suffix of each shipped .pm file + for f in json.loads(value): + if f.endswith(".pm"): + parts = f.split("/") + provides.update("/" + "/".join(parts[i:]) for i in range(1, len(parts))) + cache[name] = (provides, bb.utils.explode_deps(data.get("RDEPENDS:" + name) or "")) + return cache[name] + + seen = set() + todo = [pkg] + missing = set(required) + while todo and missing: + for name in providers(todo.pop()) - seen: + seen.add(name) + provides, rdepends = pkg_info(name) + missing = set(dep for dep in missing if dep not in provides and module_path(dep) not in provides) + todo.extend(rdepends) + if not missing: + return + + # Only report requirements with a known provider, which are actionable. + # The rest are mostly test fixtures defined inline or optional modules. + index = perl_rdeps_provider_index(d) + unknown = sorted(dep for dep in missing if dep not in index) + if unknown: + bb.note("%s uses Perl modules with no provider in pkgdata: %s" % (pkg, " ".join(unknown))) + known = sorted(dep for dep in missing if dep in index) + if not known: + return + + suggested = dict.fromkeys(index[dep] for dep in known) + msg = "%s uses Perl modules not provided by its RDEPENDS: %s\nConsider: RDEPENDS:%s += \"%s\"" % \ + (pkg, " ".join(known), pkg, " ".join(suggested)) + oe.qa.handle_error("perl-rdeps", msg, d) + QAPKGTEST[empty-dirs] = "package_qa_check_empty_dirs" def package_qa_check_empty_dirs(pkg, d): """ @@ -1208,6 +1332,10 @@ python() { pkgs = (d.getVar('PACKAGES') or '').split() for pkg in pkgs: d.appendVarFlag("do_package_qa", "vardeps", " INSANE_SKIP:{}".format(pkg)) + # perl-rdeps runs perl.req; do_package may have come from sstate so the + # recipe sysroot is not guaranteed to have it already + if pkgs and "perl-rdeps" in ((d.getVar("WARN_QA") or "") + " " + (d.getVar("ERROR_QA") or "")).split(): + d.appendVarFlag("do_package_qa", "depends", " perl-generators-native:do_populate_sysroot") funcs = d.getVarFlags("QAPATHTEST") funcs.update(d.getVarFlags("QAPKGTEST")) funcs.update(d.getVarFlags("QARECIPETEST")) diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py index a0bde50ed6..a759cd6c46 100644 --- a/meta/lib/oe/package.py +++ b/meta/lib/oe/package.py @@ -268,6 +268,28 @@ def filedeprunner(pkg, pkgfiles, rpmdeps, pkgdest): return (pkg, provides, requires) +# The perl_* helpers were written with the help of an AI tool (Claude Code). +def perl_generator(d, script, files, env=None): + """ + Run perl.prov or perl.req (perl-generators-native) over files and return + the dependency names reported, without versions. + """ + script = os.path.join(d.getVar("STAGING_LIBDIR_NATIVE"), "rpm", script) + deps = [] + for i in range(0, len(files), 500): + output = subprocess.check_output([script] + files[i:i + 500], text=True, env=env) + deps += [line.split(" ", 1)[0] for line in output.splitlines()] + return deps + +def perl_requires(d, files, env=None): + """ + Return the perl(Module::Name) requirements of files. Same filtering as + filedeprunner(), plus perl version requirements and Win32 modules. + """ + return set(dep for dep in perl_generator(d, "perl.req", files, env) + if dep.startswith("perl(") and not dep.endswith(".pl)") + and not dep.startswith(("perl(:", "perl(VMS::", "perl(Mac::", "perl(Win32"))) + def read_shlib_providers(d): import re