summaryrefslogtreecommitdiffstats
path: root/documentation/set_versions.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-03-18 16:28:32 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-03-23 12:08:56 +0000
commitd51fb3c8b950f504351b3642986d1a0be629c398 (patch)
tree99a55bee8cc2518f58ebfaf62734356cf17a1bce /documentation/set_versions.py
parent8827704443363068db7181bc0698cbda5d35b01d (diff)
downloadpoky-d51fb3c8b950f504351b3642986d1a0be629c398.tar.gz
set_versions: Various improvements
- 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. (From yocto-docs rev: f2b069be8c307e3efe518f5d9bb1e6e705b96554) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/set_versions.py')
-rwxr-xr-xdocumentation/set_versions.py117
1 files changed, 88 insertions, 29 deletions
diff --git a/documentation/set_versions.py b/documentation/set_versions.py
index 94e2704a50..9f0d794292 100755
--- a/documentation/set_versions.py
+++ b/documentation/set_versions.py
@@ -12,6 +12,12 @@
12import subprocess 12import subprocess
13import collections 13import collections
14import sys 14import sys
15import os
16import itertools
17
18ourversion = None
19if len(sys.argv) == 2:
20 ourversion = sys.argv[1]
15 21
16ourversion = None 22ourversion = None
17if len(sys.argv) == 2: 23if len(sys.argv) == 2:
@@ -29,6 +35,27 @@ release_series["honister"] = "3.4"
29release_series["hardknott"] = "3.3" 35release_series["hardknott"] = "3.3"
30release_series["gatesgarth"] = "3.2" 36release_series["gatesgarth"] = "3.2"
31release_series["dunfell"] = "3.1" 37release_series["dunfell"] = "3.1"
38release_series["zeus"] = "3.0"
39release_series["warrior"] = "2.7"
40release_series["thud"] = "2.6"
41release_series["sumo"] = "2.5"
42release_series["rocko"] = "2.4"
43release_series["pyro"] = "2.3"
44release_series["morty"] = "2.2"
45release_series["krogoth"] = "2.1"
46release_series["jethro"] = "2.0"
47release_series["jethro-pre"] = "1.9"
48release_series["fido"] = "1.8"
49release_series["dizzy"] = "1.7"
50release_series["daisy"] = "1.6"
51release_series["dora"] = "1.5"
52release_series["dylan"] = "1.4"
53release_series["danny"] = "1.3"
54release_series["denzil"] = "1.2"
55release_series["edison"] = "1.1"
56release_series["bernard"] = "1.0"
57release_series["laverne"] = "0.9"
58
32 59
33# "langdale" : "2.2", 60# "langdale" : "2.2",
34bitbake_mapping = { 61bitbake_mapping = {
@@ -40,13 +67,14 @@ bitbake_mapping = {
40} 67}
41 68
42# 3.4 onwards doesn't have poky version 69# 3.4 onwards doesn't have poky version
70# Early 3.4 release docs do reference it though
43poky_mapping = { 71poky_mapping = {
72 "3.4" : "26.0",
44 "3.3" : "25.0", 73 "3.3" : "25.0",
45 "3.2" : "24.0", 74 "3.2" : "24.0",
46 "3.1" : "23.0", 75 "3.1" : "23.0",
47} 76}
48 77
49ourversion = None
50ourseries = None 78ourseries = None
51ourbranch = None 79ourbranch = None
52bitbakeversion = None 80bitbakeversion = None
@@ -73,31 +101,38 @@ if ourversion:
73 if release_series[i] == baseversion: 101 if release_series[i] == baseversion:
74 ourseries = i 102 ourseries = i
75 ourbranch = i 103 ourbranch = i
76 bitbakeversion = bitbake_mapping[i] 104 if i in bitbake_mapping:
105 bitbakeversion = bitbake_mapping[i]
77else: 106else:
78 # We're floating on a branch 107 # We're floating on a branch
79 branch = subprocess.run(["git", "branch", "--show-current"], capture_output=True, text=True).stdout.strip() 108 branch = subprocess.run(["git", "branch", "--show-current"], capture_output=True, text=True).stdout.strip()
80 ourbranch = branch 109 ourbranch = branch
81 if branch != "master" and branch not in release_series: 110 if branch != "master" and branch not in release_series:
82 possible_branches = [] 111 # We're not on a known release branch so we have to guess. Compare the numbers of commits
83 for b in release_series.keys(): 112 # from each release branch and assume the smallest number of commits is the one we're based off
84 result = subprocess.run(["git", "show-ref", "heads/" + b], capture_output=True, text=True) 113 possible_branch = None
114 branch_count = 0
115 for b in itertools.chain(release_series.keys(), ["master"]):
116 result = subprocess.run(["git", "log", "--format=oneline", "HEAD..origin/" + b], capture_output=True, text=True)
85 if result.returncode == 0: 117 if result.returncode == 0:
86 possible_branches.append(b) 118 count = result.stdout.count('\n')
87 continue 119 if not possible_branch or count < branch_count:
88 result = subprocess.run(["git", "show-ref", "origin/" + b], capture_output=True, text=True) 120 print("Branch %s has count %s" % (b, count))
89 if result.returncode == 0: 121 possible_branch = b
90 possible_branches.append("origin/" + b) 122 branch_count = count
91 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 123 if possible_branch:
92 branch = nearestbranch.split('[')[1].split('~')[0] 124 branch = possible_branch
93 print("Nearest release branch esimtated to be %s" % branch) 125 else:
126 branch = "master"
127 print("Nearest release branch estimated to be %s" % branch)
94 if branch == "master": 128 if branch == "master":
95 ourseries = devbranch 129 ourseries = devbranch
96 docconfver = "dev" 130 docconfver = "dev"
97 bitbakeversion = "" 131 bitbakeversion = ""
98 elif branch in release_series: 132 elif branch in release_series:
99 ourseries = branch 133 ourseries = branch
100 bitbakeversion = bitbake_mapping[branch] 134 if branch in bitbake_mapping:
135 bitbakeversion = bitbake_mapping[branch]
101 else: 136 else:
102 sys.exit("Unknown series for branch %s" % branch) 137 sys.exit("Unknown series for branch %s" % branch)
103 138
@@ -115,8 +150,8 @@ else:
115 docconfver = ourversion 150 docconfver = ourversion
116 151
117series = [k for k in release_series] 152series = [k for k in release_series]
118previousseries = series[series.index(ourseries)+1:] 153previousseries = series[series.index(ourseries)+1:] or [""]
119lastlts = [k for k in previousseries if k in ltsseries] 154lastlts = [k for k in previousseries if k in ltsseries] or "dunfell"
120 155
121print("Version calculated to be %s" % ourversion) 156print("Version calculated to be %s" % ourversion)
122print("Release series calculated to be %s" % ourseries) 157print("Release series calculated to be %s" % ourseries)
@@ -134,21 +169,40 @@ replacements = {
134} 169}
135 170
136if release_series[ourseries] in poky_mapping: 171if release_series[ourseries] in poky_mapping:
137 pokyversion = poky_mapping[release_series[ourseries]] + "." + ourversion.rsplit(".", 1)[1] 172 pokyversion = poky_mapping[release_series[ourseries]]
173 if ourversion != release_series[ourseries]:
174 pokyversion = pokyversion + "." + ourversion.rsplit(".", 1)[1]
175 else:
176 pokyversion = pokyversion + ".0"
138 replacements["POKYVERSION"] = pokyversion 177 replacements["POKYVERSION"] = pokyversion
139 178
140with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w: 179if os.path.exists("poky.yaml.in"):
141 lines = r.readlines() 180 with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w:
142 for line in lines: 181 lines = r.readlines()
143 data = line.split(":") 182 for line in lines:
144 k = data[0].strip() 183 data = line.split(":")
145 if k in replacements: 184 k = data[0].strip()
146 w.write("%s : \"%s\"\n" % (k, replacements[k])) 185 if k in replacements:
147 else: 186 w.write("%s : \"%s\"\n" % (k, replacements[k]))
148 w.write(line) 187 else:
149 188 w.write(line)
150print("poky.yaml generated from poky.yaml.in") 189
151 190 print("poky.yaml generated from poky.yaml.in")
191
192
193# In the switcher list of versions we display:
194# - latest dev
195# - latest stable release
196# - latest LTS
197# - latest for each releases listed as active
198# - latest doc version in current series
199# - current doc version
200# (with duplicates removed)
201
202if ourseries not in activereleases:
203 activereleases.append(ourseries)
204
205versions = []
152with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switchers.js", "w") as w: 206with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switchers.js", "w") as w:
153 lines = r.readlines() 207 lines = r.readlines()
154 for line in lines: 208 for line in lines:
@@ -159,10 +213,15 @@ with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switch
159 continue 213 continue
160 versions = subprocess.run('git tag --list yocto-%s*' % (release_series[branch]), shell=True, capture_output=True, text=True).stdout.split() 214 versions = subprocess.run('git tag --list yocto-%s*' % (release_series[branch]), shell=True, capture_output=True, text=True).stdout.split()
161 versions = sorted([v.replace("yocto-" + release_series[branch] + ".", "").replace("yocto-" + release_series[branch], "0") for v in versions], key=int) 215 versions = sorted([v.replace("yocto-" + release_series[branch] + ".", "").replace("yocto-" + release_series[branch], "0") for v in versions], key=int)
216 if not versions:
217 continue
162 version = release_series[branch] 218 version = release_series[branch]
163 if versions[-1] != "0": 219 if versions[-1] != "0":
164 version = version + "." + versions[-1] 220 version = version + "." + versions[-1]
221 versions.append(version)
165 w.write(" '%s': '%s',\n" % (version, version)) 222 w.write(" '%s': '%s',\n" % (version, version))
223 if ourversion not in versions:
224 w.write(" '%s': '%s',\n" % (ourversion, ourversion))
166 else: 225 else:
167 w.write(line) 226 w.write(line)
168 227