diff mbox series

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

Message ID 20260223-fix-switchers-js-v2-3-296523996600@bootlin.com
State Superseded
Headers show
Series Rework the logic of the switcher menu and improve it | expand

Commit Message

Antonin Godard Feb. 23, 2026, 10:57 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 | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/documentation/set_versions.py b/documentation/set_versions.py
index fedbad00e..96903e14c 100755
--- a/documentation/set_versions.py
+++ b/documentation/set_versions.py
@@ -195,8 +195,28 @@  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.
+# When we're on a random commit, in that case the DISTRO value will
+# contain 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 = ourversion
+# Few exceptions though:
+if is_branch_tip:
+    # 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]
+
+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,