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.

(From yocto-docs rev: bfe74c67f327f0c6445cb4129ee0c32db022b95a)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2022-03-18 14:16:24 +00:00
parent 8d3e9aaede
commit b04eda7447
3 changed files with 42 additions and 2 deletions

View File

@ -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

View File

@ -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;"

View File

@ -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: