Makefile/set_versions: Allow poky.yaml to be autogenerated
PATCH 1/5 Makefile/set_versions: Allow poky.yaml to be autogenerated
Use a script to generate the branch/tag information inside poky.yaml.
If the branch isn't a known release branch, include git magic to find the closest matching release branch we know about.
---
documentation/.gitignore | 1 +
documentation/Makefile | 1 +
documentation/{poky.yaml => poky.yaml.in} | 0
documentation/set_versions.py | 120 ++++++++++++++++++++++
4 files changed, 122 insertions(+)
rename documentation/{poky.yaml => poky.yaml.in} (100%)
create mode 100755 documentation/set_versions.pydocumentation/.gitignore +1 -0
@@ -1,5 +1,6 @@ _build/ Pipfile.lock +poky.yaml .vscode/ */svg/*.png */svg/*.pdf
documentation/Makefile +1 -0
@@ -57,4 +57,5 @@ all: html epub latexpdf # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: + $(SOURCEDIR)/set_versions.py @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
documentation/poky.yaml.in renamed from documentation/poky.yaml +0 -0
documentation/set_versions.py new file +120 -0
120 lines not on this page · raw message
Signature · 1 line
2.32.0
PATCH 2/5 conf.py/set_versions/poky.yaml: Set version in conf.py from poky.yaml
Allow conf.py to read the versions it needs from poky.yaml and have set_versions.py write this out. This means we don't have to change as many files when making new releases.
--- documentation/conf.py | 22 ++++++++++++++++++++-- documentation/poky.yaml.in | 2 ++ documentation/set_versions.py | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-)
documentation/conf.py +20 -2
@@ -15,9 +15,27 @@ import os import sys import datetime +try: + import yaml +except ImportError: + sys.stderr.write("The Yocto Project Sphinx documentation requires PyYAML.\ + \nPlease make sure to install pyyaml python package.\n") + sys.exit(1) -current_version = "dev" -bitbake_version = "" # Leave empty for development branch +# current_version = "dev" +# bitbake_version = "" # Leave empty for development branch +# Obtain versions from poky.yaml instead +with open("poky.yaml") as data: + buff = data.read() + subst_vars = yaml.safe_load(buff) + if "DOCCONF_VERSION" not in subst_vars: + sys.stderr.write("Please set DOCCONF_VERSION in poky.yaml") + sys.exit(1) + current_version = subst_vars["DOCCONF_VERSION"] + if "BITBAKE_SERIES" not in subst_vars: + sys.stderr.write("Please set BITBAKE_SERIES in poky.yaml") + sys.exit(1) + bitbake_version = subst_vars["BITBAKE_SERIES"] # String used in sidebar version = 'Version: ' + current_version
documentation/poky.yaml.in +2 -0
@@ -5,6 +5,8 @@ DISTRO_NAME_NO_CAP_MINUS_ONE : "hardknott" DISTRO_NAME_NO_CAP_LTS : "dunfell" YOCTO_DOC_VERSION : "3.4.2" DISTRO_REL_TAG : "yocto-3.4.2" +DOCCONF_VERSION : "dev" +BITBAKE_SERIES : "" YOCTO_DL_URL : "https://downloads.yoctoproject.org" YOCTO_AB_URL : "https://autobuilder.yoctoproject.org" YOCTO_RELEASE_DL_URL : "&YOCTO_DL_URL;/releases/yocto/yocto-&DISTRO;"
documentation/set_versions.py +20 -0
@@ -30,9 +30,20 @@ release_series["hardknott"] = "3.3" release_series["gatesgarth"] = "3.2" release_series["dunfell"] = "3.1" +# "langdale" : "2.2", +bitbake_mapping = { + "kirkstone" : "2.0", + "honister" : "1.52", + "hardknott" : "1.50", + "gatesgarth" : "1.48", + "dunfell" : "1.46", +} + ourversion = None ourseries = None ourbranch = None +bitbakeversion = None +docconfver = None # Test tags exist and inform the user to fetch if not try:
@@ -50,10 +61,12 @@ if ourversion: # We're a tagged release components = ourversion.split(".") baseversion = components[0] + "." + components[1] + docconfver = ourversion for i in release_series: if release_series[i] == baseversion: ourseries = i ourbranch = i + bitbakeversion = bitbake_mapping[i] else: # We're floating on a branch branch = subprocess.run(["git", "branch", "--show-current"], capture_output=True, text=True).stdout.strip()
@@ -73,8 +86,11 @@ else: print("Nearest release branch esimtated to be %s" % branch) if branch == "master": ourseries = devbranch + docconfver = "dev" + bitbakeversion = "" elif branch in release_series: ourseries = branch + bitbakeversion = bitbake_mapping[branch] else: sys.exit("Unknown series for branch %s" % branch)
@@ -88,6 +104,8 @@ else: ourversion = previoustags[-1] + ".999" else: ourversion = release_series[ourseries] + ".999" + if not docconfver: + docconfver = ourversion series = [k for k in release_series] previousseries = series[series.index(ourseries)+1:]
@@ -104,6 +122,8 @@ replacements = { "DISTRO_NAME_NO_CAP_LTS" : lastlts[0], "YOCTO_DOC_VERSION" : ourversion, "DISTRO_REL_TAG" : "yocto-" + ourversion, + "DOCCONF_VERSION" : docconfver, + "BITBAKE_SERIES" : bitbakeversion, } with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w:
Signature · 1 line
2.32.0
PATCH 3/5 set_versions: Add support for setting POKYVERSION found in older releases
In reply to Richard Purdie--- documentation/set_versions.py | 11 +++++++++++ 1 file changed, 11 insertions(+)
documentation/set_versions.py +11 -0
@@ -39,6 +39,13 @@ bitbake_mapping = { "dunfell" : "1.46", } +# 3.4 onwards doesn't have poky version +poky_mapping = { + "3.3" : "25.0", + "3.2" : "24.0", + "3.1" : "23.0", +} + ourversion = None ourseries = None ourbranch = None
@@ -126,6 +133,10 @@ replacements = { "BITBAKE_SERIES" : bitbakeversion, } +if release_series[ourseries] in poky_mapping: + pokyversion = poky_mapping[release_series[ourseries]] + "." + ourversion.rsplit(".", 1)[1] + replacements["POKYVERSION"] = pokyversion + with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w: lines = r.readlines() for line in lines:
Signature · 1 line
2.32.0
PATCH 4/5 set_versions/switchers.js: Allow switchers.js version information to be autogenerated
In reply to Richard PurdieA horrible blunt hammer approach to updating the version information in switchers.js based on the available tag information.
To merge and work correctly, this will need a change to the autobuilder-helper docs generation code to pull the swicthers.js and script from master, then to run the script. That should hopefully remove the need for other patching even on old docs branches though.
---
documentation/.gitignore | 1 +
documentation/set_versions.py | 19 +++++++++++++++++++
.../{switchers.js => switchers.js.in} | 8 +-------
3 files changed, 21 insertions(+), 7 deletions(-)
rename documentation/sphinx-static/{switchers.js => switchers.js.in} (97%)documentation/.gitignore +1 -0
@@ -1,6 +1,7 @@ _build/ Pipfile.lock poky.yaml +sphinx-static/switchers.js .vscode/ */svg/*.png */svg/*.pdf
documentation/set_versions.py +19 -0
@@ -149,3 +149,22 @@ with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w: print("poky.yaml generated from poky.yaml.in") +with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switchers.js", "w") as w: + lines = r.readlines() + for line in lines: + if "VERSIONS_PLACEHOLDER" in line: + w.write(" 'dev': 'dev (%s)',\n" % release_series[devbranch]) + for branch in activereleases: + if branch == devbranch: + continue + versions = subprocess.run('git tag --list yocto-%s*' % (release_series[branch]), shell=True, capture_output=True, text=True).stdout.split() + versions = sorted([v.replace("yocto-" + release_series[branch] + ".", "").replace("yocto-" + release_series[branch], "0") for v in versions], key=int) + version = release_series[branch] + if versions[-1] != "0": + version = version + "." + versions[-1] + w.write(" '%s': '%s',\n" % (version, version)) + else: + w.write(line) + +print("switchers.js generated from switchers.js.in") +
documentation/sphinx-static/switchers.js.in renamed from documentation/sphinx-static/switchers.js +1 -7
@@ -10,13 +10,7 @@ by https://git.yoctoproject.org/yocto-autobuilder-helper/tree/scripts/run-docs-b 'use strict'; var all_versions = { - 'dev': 'dev (3.5)', - '3.4.2': '3.4.2', - '3.3.5': '3.3.5', - '3.2.4': '3.2.4', - '3.1.15': '3.1.15', - '3.0.4': '3.0.4', - '2.7.4': '2.7.4', + VERSIONS_PLACEHOLDER }; var all_doctypes = {
Signature · 1 line
2.32.0
PATCH 5/5 set_versions: Various improvements
In reply to Richard Purdie- Allow specifying the version from the commandline
- Add all previous release series/version mappings (to support transitions branch)
- Add poky mapping for 3.4 as some releases erronously use it
- Improve git branch 'guessing' code to work properly
- Handle poky '.0' release mappings correctly
- Only write poky.yaml if poky.yaml.in exists
- Ensure older non-active releases are shown in the switchers.js release list.
- Ensure current version and current release series are shown in switcher.
--- documentation/set_versions.py | 117 +++++++++++++++++++++++++--------- 1 file changed, 88 insertions(+), 29 deletions(-)
documentation/set_versions.py +88 -29
@@ -12,6 +12,12 @@ import subprocess import collections import sys +import os +import itertools + +ourversion = None +if len(sys.argv) == 2: + ourversion = sys.argv[1] ourversion = None if len(sys.argv) == 2:
@@ -29,6 +35,27 @@ release_series["honister"] = "3.4" release_series["hardknott"] = "3.3" release_series["gatesgarth"] = "3.2" release_series["dunfell"] = "3.1" +release_series["zeus"] = "3.0" +release_series["warrior"] = "2.7" +release_series["thud"] = "2.6" +release_series["sumo"] = "2.5" +release_series["rocko"] = "2.4" +release_series["pyro"] = "2.3" +release_series["morty"] = "2.2" +release_series["krogoth"] = "2.1" +release_series["jethro"] = "2.0" +release_series["jethro-pre"] = "1.9" +release_series["fido"] = "1.8" +release_series["dizzy"] = "1.7" +release_series["daisy"] = "1.6" +release_series["dora"] = "1.5" +release_series["dylan"] = "1.4" +release_series["danny"] = "1.3" +release_series["denzil"] = "1.2" +release_series["edison"] = "1.1" +release_series["bernard"] = "1.0" +release_series["laverne"] = "0.9" + # "langdale" : "2.2", bitbake_mapping = {
@@ -40,13 +67,14 @@ bitbake_mapping = { } # 3.4 onwards doesn't have poky version +# Early 3.4 release docs do reference it though poky_mapping = { + "3.4" : "26.0", "3.3" : "25.0", "3.2" : "24.0", "3.1" : "23.0", } -ourversion = None ourseries = None ourbranch = None bitbakeversion = None
@@ -73,31 +101,38 @@ if ourversion: if release_series[i] == baseversion: ourseries = i ourbranch = i - bitbakeversion = bitbake_mapping[i] + if i in bitbake_mapping: + bitbakeversion = bitbake_mapping[i] else: # We're floating on a branch branch = subprocess.run(["git", "branch", "--show-current"], capture_output=True, text=True).stdout.strip() ourbranch = branch if branch != "master" and branch not in release_series: - possible_branches = [] - for b in release_series.keys(): - result = subprocess.run(["git", "show-ref", "heads/" + b], capture_output=True, text=True) + # We're not on a known release branch so we have to guess. Compare the numbers of commits + # from each release branch and assume the smallest number of commits is the one we're based off + possible_branch = None + branch_count = 0 + for b in itertools.chain(release_series.keys(), ["master"]): + result = subprocess.run(["git", "log", "--format=oneline", "HEAD..origin/" + b], capture_output=True, text=True) if result.returncode == 0: - possible_branches.append(b) - continue - result = subprocess.run(["git", "show-ref", "origin/" + b], capture_output=True, text=True) - if result.returncode == 0: - possible_branches.append("origin/" + b) - nearestbranch = subprocess.run('git show-branch master ' + ' '.join(possible_branches) + ' | grep "*" | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1', shell=True, capture_output=True, text=True).stdout - branch = nearestbranch.split('[')[1].split('~')[0] - print("Nearest release branch esimtated to be %s" % branch) + count = result.stdout.count('\n') + if not possible_branch or count < branch_count: + print("Branch %s has count %s" % (b, count)) + possible_branch = b + branch_count = count + if possible_branch: + branch = possible_branch + else: + branch = "master" + print("Nearest release branch estimated to be %s" % branch) if branch == "master": ourseries = devbranch docconfver = "dev" bitbakeversion = "" elif branch in release_series: ourseries = branch - bitbakeversion = bitbake_mapping[branch] + if branch in bitbake_mapping: + bitbakeversion = bitbake_mapping[branch] else: sys.exit("Unknown series for branch %s" % branch)
@@ -115,8 +150,8 @@ else: docconfver = ourversion series = [k for k in release_series] -previousseries = series[series.index(ourseries)+1:] -lastlts = [k for k in previousseries if k in ltsseries] +previousseries = series[series.index(ourseries)+1:] or [""] +lastlts = [k for k in previousseries if k in ltsseries] or "dunfell" print("Version calculated to be %s" % ourversion) print("Release series calculated to be %s" % ourseries)
@@ -134,21 +169,40 @@ replacements = { } if release_series[ourseries] in poky_mapping: - pokyversion = poky_mapping[release_series[ourseries]] + "." + ourversion.rsplit(".", 1)[1] + pokyversion = poky_mapping[release_series[ourseries]] + if ourversion != release_series[ourseries]: + pokyversion = pokyversion + "." + ourversion.rsplit(".", 1)[1] + else: + pokyversion = pokyversion + ".0" replacements["POKYVERSION"] = pokyversion -with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w: - lines = r.readlines() - for line in lines: - data = line.split(":") - k = data[0].strip() - if k in replacements: - w.write("%s : \"%s\"\n" % (k, replacements[k])) - else: - w.write(line) - -print("poky.yaml generated from poky.yaml.in") - +if os.path.exists("poky.yaml.in"): + with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w: + lines = r.readlines() + for line in lines: + data = line.split(":") + k = data[0].strip() + if k in replacements: + w.write("%s : \"%s\"\n" % (k, replacements[k])) + else: + w.write(line) + + print("poky.yaml generated from poky.yaml.in") + + +# In the switcher list of versions we display: +# - latest dev +# - latest stable release +# - latest LTS +# - latest for each releases listed as active +# - latest doc version in current series +# - current doc version +# (with duplicates removed) + +if ourseries not in activereleases: + activereleases.append(ourseries) + +versions = [] with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switchers.js", "w") as w: lines = r.readlines() for line in lines:
@@ -159,10 +213,15 @@ with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switch continue versions = subprocess.run('git tag --list yocto-%s*' % (release_series[branch]), shell=True, capture_output=True, text=True).stdout.split() versions = sorted([v.replace("yocto-" + release_series[branch] + ".", "").replace("yocto-" + release_series[branch], "0") for v in versions], key=int) + if not versions: + continue version = release_series[branch] if versions[-1] != "0": version = version + "." + versions[-1] + versions.append(version) w.write(" '%s': '%s',\n" % (version, version)) + if ourversion not in versions: + w.write(" '%s': '%s',\n" % (ourversion, ourversion)) else: w.write(line)
Signature · 1 line
2.32.0