From: Antonin Godard <antonin.godard@bootlin.com>
To: docs@lists.yoctoproject.org
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Antonin Godard <antonin.godard@bootlin.com>
Subject: [PATCH 1/4] tools/obsolete-variables: add script
Date: Thu, 27 Aug 2026 09:46:57 +0200 [thread overview]
Message-ID: <20260827-missing-variables-v1-1-7ec8b525b23b@bootlin.com> (raw)
In-Reply-To: <20260827-missing-variables-v1-0-7ec8b525b23b@bootlin.com>
Add a script that outputs missing variables from
OE-Core/meta-yocto/BitBake, i.e. for which grepping returned nothing.
There are a few exceptions, which are listed in VAR_EXCEPTIONS.
The script currently returns:
ERROR: Variable CVSDIR not found anywhere
ERROR: Variable FIT_KERNEL_COMP_ALG_EXTENSION not found anywhere
ERROR: Variable USERMOD_PARAMS not found anywhere
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
documentation/tools/obsolete-variables | 142 +++++++++++++++++++++++++++++++++
1 file changed, 142 insertions(+)
diff --git a/documentation/tools/obsolete-variables b/documentation/tools/obsolete-variables
new file mode 100755
index 000000000..bc97cbb71
--- /dev/null
+++ b/documentation/tools/obsolete-variables
@@ -0,0 +1,142 @@
+#!/usr/bin/env python3
+#
+# SPDX-License-Identifier: MIT
+#
+# Author: Antonin Godard <antonin.godard@bootlin.com>
+#
+# Copyright (C) 2026 Bootlin
+#
+
+import argparse
+import logging
+import subprocess
+import sys
+
+from pathlib import Path
+from sphinx.util.inventory import InventoryFile
+from typing import List
+
+
+DOCS_DIR = Path(__file__).parent.parent
+# False positives:
+# - variables we know exist but have a specific syntax
+# - we keep documentation for it here, already saying it is obsolete
+VAR_EXCEPTIONS = (
+ "CONFLICT_IMAGE_FEATURES",
+ "CONFLICT_TUNE_FEATURES",
+ "FEATURE_PACKAGES",
+ "LAYERRECOMMENDS",
+ "REQUIRED_IMAGE_FEATURES",
+ "VIRTUAL-RUNTIME",
+ "module_autoload",
+ "module_conf",
+)
+ERR_MSG = "Variable %s not found in OE-Core, meta-yocto, or BitBake"
+
+
+def parse_arguments() -> argparse.Namespace:
+ parser = argparse.ArgumentParser(description="Use the Sphinx's inventory to "
+ "check for variables not present in "
+ "OE-Core/meta-yocto/BitBake")
+
+ parser.add_argument("--debug",
+ action="store_true",
+ help="Print debug messages")
+
+ parser.add_argument("--yocto-docs-inv",
+ type=Path,
+ default=DOCS_DIR / "_build/html/objects.inv",
+ help="Input yocto-docs inventory file")
+
+ parser.add_argument("--bitbake-inv",
+ type=Path,
+ default=DOCS_DIR / "_build/doctrees/__intersphinx_cache__/bitbake_objects.inv",
+ help="Input bitbake inventory file")
+
+ parser.add_argument("oecore_dir",
+ type=Path,
+ help="Path to openembedded-core")
+
+ parser.add_argument("meta_yocto_dir",
+ type=Path,
+ help="Path to meta-yocto")
+
+ parser.add_argument("bitbake_dir",
+ type=Path,
+ help="Path to bitbake")
+
+ return parser.parse_args()
+
+
+def var_exists_in(var: str, gitdir: Path) -> bool:
+ """
+ In gitdir, check if a grepping for "<var>" return something (then return
+ True, False otherwise).
+
+ Special case where in OE-Core we can have:
+ BB_RENAMED_VARIABLES[<var>] = "..."
+ Then exclude that.
+ """
+ cmd = [
+ "git", "-C", gitdir, "grep", "--extended-regexp", fr"\<{var}\>",
+ ]
+ _out = ""
+ try:
+ _out = subprocess.check_output(cmd, encoding="utf-8")
+ except subprocess.CalledProcessError:
+ pass
+
+ out = ""
+ for line in _out.splitlines():
+ if not line.startswith(f"BB_RENAMED_VARIABLES[{var}]"):
+ out += f"{line}\n"
+
+ if out:
+ logging.debug(f"{var} found in {gitdir.name}:\n{out}")
+ return True
+
+ return False
+
+
+def var_exists(var: str, repos: List[Path]):
+ return any(var_exists_in(var, d) for d in repos)
+
+
+def check_inventory(inv_p: Path, uri: str, repos: List[Path]) -> int:
+ exit_code = 0
+ inv = InventoryFile.loads(inv_p.read_bytes(), uri="")
+ for entry, inv_item in sorted(inv.data["std:term"].items()):
+ if inv_item.uri.startswith(uri) \
+ and entry not in VAR_EXCEPTIONS \
+ and not var_exists(entry, repos):
+ exit_code = 1
+ logging.error(ERR_MSG % entry)
+ return exit_code
+
+
+def main():
+ exit_code = 0
+ args = parse_arguments()
+
+ if args.debug:
+ logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.DEBUG)
+ else:
+ logging.basicConfig(format="%(levelname)s: %(message)s")
+
+ if not (args.yocto_docs_inv.exists() and args.bitbake_inv.exists()):
+ logging.error(f"yocto-docs and bitbake inventories not found at {args.yocto_docs_inv}/"
+ f"{args.bitbake_inv}. Build the documentation or use the "
+ "--yocto-docs-inv/--bitbake-inv options")
+ sys.exit(1)
+
+ exit_code = check_inventory(args.yocto_docs_inv, "ref-manual/variables.html#term-",
+ (args.oecore_dir, args.meta_yocto_dir, args.bitbake_dir))
+
+ exit_code = check_inventory(args.bitbake_inv, "bitbake-user-manual/bitbake-user-manual-ref-variables.html#term-",
+ (args.oecore_dir, args.meta_yocto_dir, args.bitbake_dir))
+
+ sys.exit(exit_code)
+
+
+if __name__ == "__main__":
+ main()
--
2.55.0
next prev parent reply other threads:[~2026-08-27 7:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 7:46 [PATCH 0/4] New script to detect obsolete variables Antonin Godard
2026-08-27 7:46 ` Antonin Godard [this message]
2026-08-27 7:46 ` [PATCH 2/4] docs-wide: fix USERMOD_PARAMS -> USERMOD_PARAM Antonin Godard
2026-09-07 8:30 ` Antonin Godard
2026-08-27 7:46 ` [PATCH 3/4] ref-manual/variables.rst: remove CVSDIR Antonin Godard
2026-08-27 7:47 ` [PATCH 4/4] ref-manual/variables.rst: drop documentation for FIT_KERNEL_COMP_ALG_EXTENSION Antonin Godard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260827-missing-variables-v1-1-7ec8b525b23b@bootlin.com \
--to=antonin.godard@bootlin.com \
--cc=docs@lists.yoctoproject.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.