conf.py/set_versions/poky.yaml: Set version in conf.py from poky.yaml

Message ID 20220318141719.1068821-1-richard.purdie@linuxfoundation.org
State New
Headers show
Series conf.py/set_versions/poky.yaml: Set version in conf.py from poky.yaml | expand

Commit Message

Richard Purdie March 18, 2022, 2:17 p.m. UTC
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.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 documentation/conf.py         | 11 +++++++++--
 documentation/poky.yaml.in    |  2 ++
 documentation/set_versions.py | 22 +++++++++++++++++++++-
 3 files changed, 32 insertions(+), 3 deletions(-)

Patch

diff --git a/documentation/conf.py b/documentation/conf.py
index 3015892d2..4bbe9b574 100644
--- a/documentation/conf.py
+++ b/documentation/conf.py
@@ -16,8 +16,15 @@  import os
 import sys
 import datetime
 
-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:
+    for line in data.readlines():
+        if line.startswith("DOCCONF_VERSION"):
+            current_version = line.split(":")[1].strip().replace('"', '')
+        if line.startswith("BITBAKE_SERIES"):
+            bitbake_version = line.split(":")[1].strip().replace('"', '')
 
 # String used in sidebar
 version = 'Version: ' + current_version
diff --git a/documentation/poky.yaml.in b/documentation/poky.yaml.in
index 89a059ef1..a346b7623 100644
--- a/documentation/poky.yaml.in
+++ b/documentation/poky.yaml.in
@@ -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;"
diff --git a/documentation/set_versions.py b/documentation/set_versions.py
index cdcfd6bb0..a8c0980a7 100755
--- a/documentation/set_versions.py
+++ b/documentation/set_versions.py
@@ -25,9 +25,20 @@  release_series["hardknott"] = "3.3"
 release_series["gatesgarth"] = "3.2"
 release_series["dunfell"] = "3.1"
 
+bitbake_mapping = {
+    "langdale" : "2.2",
+    "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:
@@ -45,18 +56,23 @@  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()
     ourbranch = branch
-    if branch == "master":
+    if branch == "master" or branch == "master-next":
         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)
 
@@ -70,6 +86,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:]
@@ -86,6 +104,8 @@  replacements = {
     "DISTRO_NAME_NO_CAP_LTS" : lastlts[0],
     "YOCTO_DOC_VERSION" : ourversion,
     "DISTRO_REL_TAG" : "yocto-" + ourversion,
+    "DOCCONF_VERSION" : docconfver,
+    "BITBAKE_VERSION" : bitbakeversion,
 }
 
 with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w: