diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-03-18 16:28:32 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-03-23 12:08:56 +0000 |
commit | d51fb3c8b950f504351b3642986d1a0be629c398 (patch) | |
tree | 99a55bee8cc2518f58ebfaf62734356cf17a1bce /documentation/set_versions.py | |
parent | 8827704443363068db7181bc0698cbda5d35b01d (diff) | |
download | poky-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-x | documentation/set_versions.py | 117 |
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 @@ | |||
12 | import subprocess | 12 | import subprocess |
13 | import collections | 13 | import collections |
14 | import sys | 14 | import sys |
15 | import os | ||
16 | import itertools | ||
17 | |||
18 | ourversion = None | ||
19 | if len(sys.argv) == 2: | ||
20 | ourversion = sys.argv[1] | ||
15 | 21 | ||
16 | ourversion = None | 22 | ourversion = None |
17 | if len(sys.argv) == 2: | 23 | if len(sys.argv) == 2: |
@@ -29,6 +35,27 @@ release_series["honister"] = "3.4" | |||
29 | release_series["hardknott"] = "3.3" | 35 | release_series["hardknott"] = "3.3" |
30 | release_series["gatesgarth"] = "3.2" | 36 | release_series["gatesgarth"] = "3.2" |
31 | release_series["dunfell"] = "3.1" | 37 | release_series["dunfell"] = "3.1" |
38 | release_series["zeus"] = "3.0" | ||
39 | release_series["warrior"] = "2.7" | ||
40 | release_series["thud"] = "2.6" | ||
41 | release_series["sumo"] = "2.5" | ||
42 | release_series["rocko"] = "2.4" | ||
43 | release_series["pyro"] = "2.3" | ||
44 | release_series["morty"] = "2.2" | ||
45 | release_series["krogoth"] = "2.1" | ||
46 | release_series["jethro"] = "2.0" | ||
47 | release_series["jethro-pre"] = "1.9" | ||
48 | release_series["fido"] = "1.8" | ||
49 | release_series["dizzy"] = "1.7" | ||
50 | release_series["daisy"] = "1.6" | ||
51 | release_series["dora"] = "1.5" | ||
52 | release_series["dylan"] = "1.4" | ||
53 | release_series["danny"] = "1.3" | ||
54 | release_series["denzil"] = "1.2" | ||
55 | release_series["edison"] = "1.1" | ||
56 | release_series["bernard"] = "1.0" | ||
57 | release_series["laverne"] = "0.9" | ||
58 | |||
32 | 59 | ||
33 | # "langdale" : "2.2", | 60 | # "langdale" : "2.2", |
34 | bitbake_mapping = { | 61 | bitbake_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 | ||
43 | poky_mapping = { | 71 | poky_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 | ||
49 | ourversion = None | ||
50 | ourseries = None | 78 | ourseries = None |
51 | ourbranch = None | 79 | ourbranch = None |
52 | bitbakeversion = None | 80 | bitbakeversion = 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] | ||
77 | else: | 106 | else: |
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 | ||
117 | series = [k for k in release_series] | 152 | series = [k for k in release_series] |
118 | previousseries = series[series.index(ourseries)+1:] | 153 | previousseries = series[series.index(ourseries)+1:] or [""] |
119 | lastlts = [k for k in previousseries if k in ltsseries] | 154 | lastlts = [k for k in previousseries if k in ltsseries] or "dunfell" |
120 | 155 | ||
121 | print("Version calculated to be %s" % ourversion) | 156 | print("Version calculated to be %s" % ourversion) |
122 | print("Release series calculated to be %s" % ourseries) | 157 | print("Release series calculated to be %s" % ourseries) |
@@ -134,21 +169,40 @@ replacements = { | |||
134 | } | 169 | } |
135 | 170 | ||
136 | if release_series[ourseries] in poky_mapping: | 171 | if 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 | ||
140 | with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w: | 179 | if 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) | |
150 | print("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 | |||
202 | if ourseries not in activereleases: | ||
203 | activereleases.append(ourseries) | ||
204 | |||
205 | versions = [] | ||
152 | with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switchers.js", "w") as w: | 206 | with 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 | ||