set_versions.py: Use remote bitake mappings
cover set_versions.py: Use remote bitake mappings
The bitbake mapping were added to the remote releases.json file[1].
Use them instead of maintaining static values here.
This series also includes some codestyle cleanups for the set_versions.py file.
---
Antonin Godard (3):
set_versions.py: use bitbake mappings from remote releases.json set_versions.py: move the poky_mapping dict where it is used set_versions.py: fix codestyle/formatting issues
documentation/set_versions.py | 86 +++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 45 deletions(-)
---
base-commit: a337c16d7608664c9d6f0f8a4727593c0a18437d
change-id: 20260317-use-remote-bitbake-version-mappings-96fea0514d2f
PATCH 1/3 set_versions.py: use bitbake mappings from remote releases.json
After [1] we can now use the bitbake version mappings maintained in the remote releases.json file, allowing to reduce maintenance effort here.
[1]:
--- documentation/set_versions.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
documentation/set_versions.py +9 -16
@@ -31,6 +31,12 @@ release_series = collections.OrderedDict({ "scarthgap": "5.0", "kirkstone": "4.0", }) +bitbake_mapping = collections.OrderedDict({ + "wrynose": "2.18", + "whinlatter": "2.16", + "scarthgap": "2.8", + "kirkstone": "2.0", +}) releases_from_json = {}
@@ -57,6 +63,7 @@ if releases_from_json: activereleases = [] devbranch = "" ltsseries = [] + bitbake_mapping = collections.OrderedDict() for release in releases_from_json: codename = release["release_codename"].lower()
@@ -67,6 +74,8 @@ if releases_from_json: activereleases.append(codename) if "LTS until" in release["status"]: ltsseries.append(codename) + if release["bitbake_version"]: + bitbake_mapping[codename] = release["bitbake_version"] activereleases.remove(devbranch)
@@ -79,22 +88,6 @@ print(f"activereleases calculated to be {activereleases}") print(f"devbranch calculated to be {devbranch}") print(f"ltsseries calculated to be {ltsseries}") -bitbake_mapping = { - "wrynose" : "2.18", - "whinlatter" : "2.16", - "walnascar" : "2.12", - "styhead" : "2.10", - "scarthgap" : "2.8", - "nanbield" : "2.6", - "mickledore" : "2.4", - "langdale" : "2.2", - "kirkstone" : "2.0", - "honister" : "1.52", - "hardknott" : "1.50", - "gatesgarth" : "1.48", - "dunfell" : "1.46", -} - # 3.4 onwards doesn't have poky version # Early 3.4 release docs do reference it though poky_mapping = {
Signature · 1 line
2.53.0
PATCH 2/3 set_versions.py: move the poky_mapping dict where it is used
In reply to Antonin GodardThe poky_mapping dict isn't used until after the replacements dict is created. Move it's definitions to where it's used. Also fix a codestyle issue while we're at it (whitespace before ":").
--- documentation/set_versions.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
documentation/set_versions.py +9 -9
@@ -88,15 +88,6 @@ print(f"activereleases calculated to be {activereleases}") print(f"devbranch calculated to be {devbranch}") print(f"ltsseries calculated to be {ltsseries}") -# 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
@@ -237,6 +228,15 @@ replacements = { "BITBAKE_SERIES" : bitbakeversion, } +# 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", +} + if release_series[ourseries] in poky_mapping: pokyversion = poky_mapping[release_series[ourseries]] if ourversion != release_series[ourseries]:
Signature · 1 line
2.53.0
PATCH 3/3 set_versions.py: fix codestyle/formatting issues
In reply to Antonin GodardFix issues reported by pycodestyle (long lines, spurious or missing whitespaces, underindented lines), and add the missing description of the get_abbrev_hash() function.
--- documentation/set_versions.py | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-)
documentation/set_versions.py +23 -20
@@ -98,7 +98,8 @@ is_branch_tip = False # Test that we are building from a Git repository try: - subprocess.run(["git", "rev-parse", "--is-inside-work-tree"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) + subprocess.run(["git", "rev-parse", "--is-inside-work-tree"], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) except subprocess.CalledProcessError: sys.exit("Building yocto-docs must be done from its Git repository.\n" "Clone the documentation repository with the following command:\n"
@@ -106,12 +107,14 @@ except subprocess.CalledProcessError: # Test tags exist and inform the user to fetch if not try: - subprocess.run(["git", "show", "yocto-%s" % release_series[activereleases[0]]], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) + subprocess.run(["git", "show", "yocto-%s" % release_series[activereleases[0]]], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) except subprocess.CalledProcessError: sys.exit("Please run 'git fetch --tags' before building the documentation") # Try and figure out what we are -tags = subprocess.run(["git", "tag", "--points-at", "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout +tags = subprocess.run(["git", "tag", "--points-at", "HEAD"], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout for t in tags.split(): if t.startswith("yocto-"): ourversion = t[6:]
@@ -167,8 +170,8 @@ if ourversion is None: stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout.strip() branch_commit = subprocess.run(["git", "rev-parse", "--short", branch], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, - universal_newlines=True).stdout.strip() + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=True).stdout.strip() if head_commit != branch_commit: ourversion += f"-{head_commit}" else:
@@ -176,10 +179,11 @@ if ourversion is None: ourversion += "-tip" series = [k for k in release_series] -previousseries = series[series.index(ourseries)+1:] or [""] +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-*"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout +latestreltag = subprocess.run(["git", "describe", "--abbrev=0", "--tags", "--match", "yocto-*"], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout latestreltag = latestreltag.strip() if latestreltag: if latestreltag.startswith("yocto-"):
@@ -216,16 +220,16 @@ elif distro in ["dev", "next"]: print(f"DISTRO calculated to be {distro}") replacements = { - "DISTRO" : distro, + "DISTRO": distro, "DISTRO_LATEST_TAG": latesttag, "DISTRO_RELEASE_SERIES": release_series[ourseries], - "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, - "DOCCONF_VERSION" : ourversion, - "BITBAKE_SERIES" : bitbakeversion, + "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, + "DOCCONF_VERSION": ourversion, + "BITBAKE_SERIES": bitbakeversion, } # 3.4 onwards doesn't have poky version
@@ -266,7 +270,7 @@ def get_latest_tag(branch: str) -> str: stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout.split() branch_versions = sorted( - [v.replace("yocto-" + release_series[branch] + ".", "")\ + [v.replace("yocto-" + release_series[branch] + ".", "") .replace("yocto-" + release_series[branch], "0") for v in branch_versions], key=int) if not branch_versions:
@@ -279,7 +283,7 @@ def get_latest_tag(branch: str) -> str: def get_abbrev_hash(ref: str) -> str: """ - Get the abbreviated hash of + Get the abbreviated hash of a ref using a call to git rev-parse. """ return subprocess.run(["git", "rev-parse", "--short", ref], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
@@ -310,7 +314,8 @@ print("switchers.js generated from switchers.js.in") # generate releases.rst -yocto_tags = subprocess.run(["git", "tag", "--list", "--sort=version:refname", "yocto-*"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout.split() +yocto_tags = subprocess.run(["git", "tag", "--list", "--sort=version:refname", "yocto-*"], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).stdout.split() tags = [tag[6:] for tag in yocto_tags] with open('releases.rst', 'w') as f:
@@ -354,5 +359,3 @@ 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 </%s>`\n' % (tag, tag)) f.write('\n') - -
Signature · 1 line
2.53.0