From patchwork Mon Nov 30 17:18:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Orling X-Patchwork-Id: 106576 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.37359.1796059318237426664 for ; Mon, 30 Nov 2026 09:21:58 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@konsulko.com header.s=google header.b=CDIbZ69t; spf=pass (domain: konsulko.com, ip: 209.85.214.170, mailfrom: tim.orling@konsulko.com) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2f02ee04378so83970515ad.1 for ; Mon, 30 Nov 2026 09:21:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1796059317; x=1796664117; 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=iGWshkYr3V2yvgLM15Vx+gpdj6MuQgMDhETAeuDk+sw=; b=CDIbZ69tuPrQJ+hLnVtZbxCpkhMDjDlbUkX1AKEjZKaStIvO75NRoBPv8xbmxjLKm9 iEobGlXPQIOwSm5N6Xg5b3xJfaEhK4xIyVhzji2r2BGpgWnUPgz5BZVE1OK83XxPnbyB xKH1JXDMp9eLW4rfTDNwQpGZnuAuYrY6uA3bc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796059317; x=1796664117; 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=iGWshkYr3V2yvgLM15Vx+gpdj6MuQgMDhETAeuDk+sw=; b=iJTHYwDhnsCqVf9qrVxGrMhsh6TKuefz8NNFdEhB8k2blMppSVoReUROrI0SlQUT9K 35xqOxh5h2KJukak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DfQaXya142oAsC3KO K6d+7M/1dbWJBVQrwufgNE6uPDO0= X-Received: by 2002:a17:903:19cb:b0:2ed:2856:6442 with SMTP id d9443c01a7336-2f03f1eaa0fmr368235155ad.28.1796059317586; Mon, 30 Nov 2026 09:21:57 -0800 (PST) Return-Path: Received: from thetis.home.local ([2606:c800:6024:2000:862d:8947:aa7d:fb9c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f0c1a74sm172155815ad.12.2026.11.30.09.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 09:21:57 -0800 (PST) From: Tim Orling To: openembedded-core@lists.openembedded.org Cc: Tim Orling Subject: [PATCH v2 4/8] classes/insane: add perl-rdeps QA check Date: Mon, 30 Nov 2026 09:18:45 -0800 Message-ID: <20261130172147.791861-5-tim.orling@konsulko.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130172147.791861-1-tim.orling@konsulko.com> References: <20261130011401.68860-1-tim.orling@konsulko.com> <20261130172147.791861-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 17:22:07 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251635 Perl runtime dependencies are maintained by hand, and gaps usually only show up at runtime or in ptests [YOCTO #13376]. 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. 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