From c0e00b017f9755bb3c797718a9bda9e629d27770 Mon Sep 17 00:00:00 2001 From: Antonin Godard Date: Wed, 9 Apr 2025 11:55:41 +0200 Subject: [PATCH] poky.yaml: introduce DISTRO_LATEST_TAG Introduce the DISTRO_LATEST_TAG macro, which should always point to the latest existing tag in the documentation, unlike DISTRO which may point to A.B.999 to represent the tip of a branch. This variable is needed to fix dead links in the documentation that currently use the DISTRO macro. Also, make DISTRO_REL_TAG use the DISTRO macro directly, to avoid repetition, and add a DISTRO_REL_LATEST_TAG macro that has the same role as DISTRO_LATEST_TAG but with "yocto-" prepended to it. In set_versions.py, run the "git describe --abbrev=0 --tags --match='yocto-*'" command to get the latest existing tag on the currently checked out commit. Fallback to ourversion in case we didn't find any. (From yocto-docs rev: 6554f50b3fb424a746ba4136fad7510e950f4b3b) Signed-off-by: Antonin Godard (cherry picked from commit a85b0e500c94921f77fa7b7dbb877e4945f96d1e) Signed-off-by: Antonin Godard Signed-off-by: Richard Purdie --- documentation/poky.yaml.in | 11 ++++++++++- documentation/set_versions.py | 16 +++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/documentation/poky.yaml.in b/documentation/poky.yaml.in index d045ff596e..e03cdbfff6 100644 --- a/documentation/poky.yaml.in +++ b/documentation/poky.yaml.in @@ -2,13 +2,22 @@ # Macros used in the documentation # +# The DISTRO variable represents the current docs version. It should be used +# when referring to the current docs version. See also DISTRO_LATEST_TAG. DISTRO : "5.1" +# The DISTRO_LATEST_TAG represents the latest tag on the current branch. It +# should be used in HTTP link referring to the current docs version. In these +# cases, the DISTRO may point to A.B.999 which does not exist (just used to +# represent the latest HEAD revision on the branch). DISTRO_LATEST_TAG should +# always point to an existing tag. +DISTRO_LATEST_TAG : "5.1" DISTRO_NAME_NO_CAP : "styhead" DISTRO_NAME : "Styhead" DISTRO_NAME_NO_CAP_MINUS_ONE : "scarthgap" DISTRO_NAME_NO_CAP_LTS : "scarthgap" YOCTO_DOC_VERSION : "5.1" -DISTRO_REL_TAG : "yocto-5.1" +DISTRO_REL_TAG : "yocto-$DISTRO;" +DISTRO_REL_LATEST_TAG : "yocto-&DISTRO_LATEST_TAG;" DOCCONF_VERSION : "dev" BITBAKE_SERIES : "" YOCTO_DL_URL : "https://downloads.yoctoproject.org" diff --git a/documentation/set_versions.py b/documentation/set_versions.py index 376337e7b5..076a131ebc 100755 --- a/documentation/set_versions.py +++ b/documentation/set_versions.py @@ -170,17 +170,29 @@ series = [k for k in release_series] previousseries = series[series.index(ourseries)+1:] or [""] lastlts = [k for k in previousseries if k in ltsseries] or "dunfell" +latestreltag = subprocess.run(["git", "describe", "--abbrev=0", "--tags", "--match", "yocto-*"], capture_output=True, text=True).stdout +latestreltag = latestreltag.strip() +if latestreltag: + if latestreltag.startswith("yocto-"): + latesttag = latestreltag[6:] +else: + # fallback on the calculated version + print("Did not find a tag with 'git describe', falling back to %s" % ourversion) + latestreltag = "yocto-" + ourversion + latesttag = ourversion + print("Version calculated to be %s" % ourversion) +print("Latest release tag found is %s" % latestreltag) print("Release series calculated to be %s" % ourseries) replacements = { "DISTRO" : ourversion, + "DISTRO_LATEST_TAG": latesttag, "DISTRO_NAME_NO_CAP" : ourseries, "DISTRO_NAME" : ourseries.capitalize(), "DISTRO_NAME_NO_CAP_MINUS_ONE" : previousseries[0], "DISTRO_NAME_NO_CAP_LTS" : lastlts[0], "YOCTO_DOC_VERSION" : ourversion, - "DISTRO_REL_TAG" : "yocto-" + ourversion, "DOCCONF_VERSION" : docconfver, "BITBAKE_SERIES" : bitbakeversion, } @@ -318,3 +330,5 @@ with open('releases.rst', 'w') as f: if tag == release_series[series] or tag.startswith('%s.' % release_series[series]): f.write('- :yocto_docs:`%s Documentation `\n' % (tag, tag)) f.write('\n') + +