Message ID | 20220318154228.1071136-2-richard.purdie@linuxfoundation.org |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] Makefile/set_versions: Allow poky.yaml to be autogenerated | expand |
Hi Richard, On 3/18/22 16:42, Richard Purdie wrote: > 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 | 20 ++++++++++++++++++++ > 3 files changed, 31 insertions(+), 2 deletions(-) > > 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('"', '') > Please use yaml loading here. > # 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://urldefense.proofpoint.com/v2/url?u=https-3A__downloads.yoctoproject.org&d=DwIDAg&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=5bOZnDEv39WIAA9f1qL5vv-kisLv98s5Xz7QWJFkX3FdBZ_HIDjlbL1LB-0BWVp5&s=j5LkQTKxO-b4aoleGDRBUWLKGNHceTefO7vyV_X0MTg&e= " > YOCTO_AB_URL : "https://urldefense.proofpoint.com/v2/url?u=https-3A__autobuilder.yoctoproject.org&d=DwIDAg&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=5bOZnDEv39WIAA9f1qL5vv-kisLv98s5Xz7QWJFkX3FdBZ_HIDjlbL1LB-0BWVp5&s=bzAojsSaFdTWXYcTSVQ2Y2HNf4yAdaUPfAkLFgQvF2s&e= " > YOCTO_RELEASE_DL_URL : "&YOCTO_DL_URL;/releases/yocto/yocto-&DISTRO;" > diff --git a/documentation/set_versions.py b/documentation/set_versions.py > index 266ccf464..32259238e 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", This needs to be commented out otherwise the indices are wrong since based on release_series index (c.f. i variable below). I'm starting to think a dictionary would be a much better data structure for release name, version, lts status, and bitbake version than trying to maintain multiple lists or dicts and aaccessing them via the same index. Cheers, Quentin
On Mon, 2022-03-21 at 16:55 +0100, Quentin Schulz wrote: > Hi Richard, > > On 3/18/22 16:42, Richard Purdie wrote: > > 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 | 20 ++++++++++++++++++++ > > 3 files changed, 31 insertions(+), 2 deletions(-) > > > > 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('"', '') > > > > Please use yaml loading here. Agreed, that would be better. I'd just borrowed code I already knew worked without thinking about the context. > > # 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://urldefense.proofpoint.com/v2/url?u=https-3A__downloads.yoctoproject.org&d=DwIDAg&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=5bOZnDEv39WIAA9f1qL5vv-kisLv98s5Xz7QWJFkX3FdBZ_HIDjlbL1LB-0BWVp5&s=j5LkQTKxO-b4aoleGDRBUWLKGNHceTefO7vyV_X0MTg&e= " > > YOCTO_AB_URL : "https://urldefense.proofpoint.com/v2/url?u=https-3A__autobuilder.yoctoproject.org&d=DwIDAg&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=5bOZnDEv39WIAA9f1qL5vv-kisLv98s5Xz7QWJFkX3FdBZ_HIDjlbL1LB-0BWVp5&s=bzAojsSaFdTWXYcTSVQ2Y2HNf4yAdaUPfAkLFgQvF2s&e= " > > YOCTO_RELEASE_DL_URL : "&YOCTO_DL_URL;/releases/yocto/yocto-&DISTRO;" > > diff --git a/documentation/set_versions.py b/documentation/set_versions.py > > index 266ccf464..32259238e 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", > > This needs to be commented out otherwise the indices are wrong since > based on release_series index (c.f. i variable below). Ok, I think the code originally needed that but in later changes it probably can be commented out. > I'm starting to think a dictionary would be a much better data structure > for release name, version, lts status, and bitbake version than trying > to maintain multiple lists or dicts and aaccessing them via the same index. I went around in circles on that. Note that: * the bitbake version is only needed for a subset of the releases (dunfell onwards) * the poky version is only needed for dunfell->honister * the lts list is much smaller (once every 3 releases and no history) and the current form of access seemed easier to code this way. Cheers, Richard
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 266ccf464..32259238e 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,10 +56,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() @@ -68,8 +81,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) @@ -83,6 +99,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:] @@ -99,6 +117,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:
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 | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-)