diff mbox series

[3/3] set_versions.py: set a more accurate DISTRO value

Message ID 20260212-fix-switchers-js-v1-3-16d95c74c328@bootlin.com
State New
Headers show
Series Rework the logic of the switcher menu and improve it | expand

Commit Message

Antonin Godard Feb. 12, 2026, 8:37 a.m. UTC
The changes from the previous commit make the current value inaccurate
in some situations, especially since this variable is used in some
commands. Take these situations into account and compute a more accurate
value for DISTRO.

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 documentation/set_versions.py | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/documentation/set_versions.py b/documentation/set_versions.py
index 66e845c97..56cf3d34d 100755
--- a/documentation/set_versions.py
+++ b/documentation/set_versions.py
@@ -186,8 +186,30 @@  print("Latest release tag found is %s" % latestreltag)
 print("Release series calculated to be %s" % ourseries)
 print("Bitbake version calculated to be %s" % bitbakeversion)
 
+# The &DISTRO; replacement will be mostly right when just equaling ourversion.
+distro = ourversion
+# Few exceptions though:
+if "(latest)" in distro:
+    # we're on a branch tip, in that case the closest match is the latest tag
+    # from that branch. Some instructions rely on DISTRO to provide tag names,
+    # etc. so it makes sense provide the latest tag from that branch.
+    distro = latesttag
+elif distro in ["dev", "next"]:
+    # When building on master or master-next, make the distro the version of the
+    # devbranch.
+    distro = release_series[devbranch]
+elif head_commit:
+    # or we're on a random commit, in that case create a DISTRO value that
+    # contains the hash. this would for example be "5.3-4d2acc043".
+    # This will not happen when publishing the documentation from the
+    # autobuilder as we don't build specific commits - this should only happen
+    # for development.
+    distro = distro.split()[0] + f"-{head_commit}"
+
+print(f"DISTRO calculated to be {distro}")
+
 replacements = {
-    "DISTRO" : ourversion,
+    "DISTRO" : distro,
     "DISTRO_LATEST_TAG": latesttag,
     "DISTRO_RELEASE_SERIES": release_series[ourseries],
     "DISTRO_NAME_NO_CAP" : ourseries,