Skip to content

Commit 2e1c3ba

Browse files
committed
[KRU] Allow rolling release to be used across centos
Previously the tooling would find the common RESF tag but when upgrading minor versions it would not search across centos versions.
1 parent c3845ac commit 2e1c3ba

File tree

1 file changed

+50
-26
lines changed

1 file changed

+50
-26
lines changed

rolling-release-update.py

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def find_common_tag(old_tags, new_tags):
2525
return None
2626

2727

28-
def get_branch_tag_sha_list(repo, branch):
28+
def get_branch_tag_sha_list(repo, branch, minor_version=False):
2929
print("[rolling release update] Checking out branch: ", branch)
3030
repo.git.checkout(branch)
3131
results = subprocess.run(
@@ -37,8 +37,17 @@ def get_branch_tag_sha_list(repo, branch):
3737

3838
print("[rolling release update] Gathering all the RESF kernel Tags")
3939
tags = []
40+
last_resf_tag = b""
4041
for line in results.stdout.split(b"\n"):
4142
if b"tag: resf_kernel" in line:
43+
if DEBUG:
44+
print(line)
45+
tags.append(line.split(b" ")[0])
46+
if last_resf_tag == b"":
47+
last_resf_tag = line.split(b" ")[0]
48+
if minor_version and b"tag: kernel-" in line:
49+
if DEBUG:
50+
print(line)
4251
tags.append(line.split(b" ")[0])
4352

4453
# Print summary instead of all tags
@@ -48,7 +57,7 @@ def get_branch_tag_sha_list(repo, branch):
4857
for line_tag in tags:
4958
print(f" {line_tag.decode()}")
5059

51-
return tags
60+
return tags, last_resf_tag
5261

5362

5463
def check_for_fips_protected_changes(repo, branch, common_tag):
@@ -142,6 +151,12 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
142151
parser.add_argument(
143152
"--verbose-git-show", help="When SHAs are detected for removal do the full git show <sha>", action="store_true"
144153
)
154+
parser.add_argument(
155+
"--new_minor_version",
156+
help="Do not stop at the RESF tags continue down the CENTOS / ROCKY MAIN branch."
157+
" This is used for the new minor version releases",
158+
action="store_true",
159+
)
145160
parser.add_argument(
146161
"--demo", help="DEMO mode, will make a new set of branches with demo_ prepended", action="store_true"
147162
)
@@ -164,42 +179,51 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
164179
rolling_product = args.old_rolling_branch.split("/")[0]
165180
print("[rolling release update] Rolling Product: ", rolling_product)
166181

167-
old_rolling_branch_tags = get_branch_tag_sha_list(repo, args.old_rolling_branch)
182+
if args.new_minor_version:
183+
print("[rolling release update] New Minor Version: ", args.new_minor_version)
184+
185+
old_rolling_branch_tags, old_rolling_resf_tag_sha = get_branch_tag_sha_list(
186+
repo, args.old_rolling_branch, args.new_minor_version
187+
)
168188
if DEBUG:
169189
print("[rolling release update] Old Rolling Branch Tags: ", old_rolling_branch_tags)
170190

171-
new_base_branch_tags = get_branch_tag_sha_list(repo, args.new_base_branch)
191+
new_base_branch_tags, new_base_resf_tag_sha = get_branch_tag_sha_list(
192+
repo, args.new_base_branch, args.new_minor_version
193+
)
172194
if DEBUG:
173195
print("[rolling release update] New Base Branch Tags: ", new_base_branch_tags)
174196

175-
latest_resf_sha = find_common_tag(old_rolling_branch_tags, new_base_branch_tags)
176-
print("[rolling release update] Latest RESF tag sha: ", latest_resf_sha)
177-
print(repo.git.show('--pretty="%H %s"', "-s", latest_resf_sha.decode()))
178-
179-
print("[rolling release update] Checking for FIPS protected changes between the common tag and HEAD")
180-
shas_to_check = check_for_fips_protected_changes(repo, args.new_base_branch, latest_resf_sha)
181-
if shas_to_check and args.fips_override is False:
182-
for sha, dir in shas_to_check.items():
183-
print(f"## Commit {sha.decode()}")
184-
print("'''")
185-
dir_list = []
186-
for d in dir:
187-
dir_list.append(d.decode())
188-
print(repo.git.show(sha.decode(), dir_list))
189-
print("'''")
190-
print("[rolling release update] FIPS protected changes found between the common tag and HEAD")
191-
print("[rolling release update] Please Contact the CIQ FIPS / Security team for further instructions")
192-
print("[rolling release update] Exiting")
193-
exit(1)
197+
common_sha = find_common_tag(old_rolling_branch_tags, new_base_branch_tags)
198+
print("[rolling release update] Common tag sha: ", common_sha)
199+
print(repo.git.show('--pretty="%H %s"', "-s", common_sha.decode()))
200+
201+
if "fips" in rolling_product:
202+
print("[rolling release update] Checking for FIPS protected changes between the common tag and HEAD")
203+
shas_to_check = check_for_fips_protected_changes(repo, args.new_base_branch, common_sha)
204+
if shas_to_check and args.fips_override is False:
205+
for sha, dir in shas_to_check.items():
206+
print(f"## Commit {sha.decode()}")
207+
print("'''")
208+
dir_list = []
209+
for d in dir:
210+
dir_list.append(d.decode())
211+
print(repo.git.show(sha.decode(), dir_list))
212+
print("'''")
213+
print("[rolling release update] FIPS protected changes found between the common tag and HEAD")
214+
print("[rolling release update] Please Contact the CIQ FIPS / Security team for further instructions")
215+
print("[rolling release update] Exiting")
216+
exit(1)
194217

195218
print("[rolling release update] Checking out old rolling branch: ", args.old_rolling_branch)
196219
repo.git.checkout(args.old_rolling_branch)
197220
print(
198221
"[rolling release update] Finding the CIQ Kernel and Associated Upstream commits between the last resf tag and HEAD"
199222
)
223+
print(f"[rolling release update] Getting SHAS {old_rolling_resf_tag_sha.decode()}..HEAD")
200224
rolling_commit_map = {}
201225
rollint_commit_map_rev = {}
202-
rolling_commits = repo.git.log(f"{latest_resf_sha.decode()}..HEAD")
226+
rolling_commits = repo.git.log(f"{old_rolling_resf_tag_sha.decode()}..HEAD")
203227
for line in rolling_commits.split("\n"):
204228
if line.startswith("commit "):
205229
ciq_commit = line.split("commit ")[1]
@@ -209,7 +233,7 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
209233
rolling_commit_map[ciq_commit] = upstream_commit
210234
rollint_commit_map_rev[upstream_commit] = ciq_commit
211235

212-
print("[rolling release update] Last RESF tag sha: ", latest_resf_sha)
236+
print("[rolling release update] Last RESF tag sha: ", common_sha)
213237

214238
print(f"[rolling release update] Total commits in old branch: {len(rolling_commit_map)}")
215239
if DEBUG:
@@ -284,7 +308,7 @@ def check_for_fips_protected_changes(repo, branch, common_tag):
284308
print("[rolling release update] Creating Map of all new commits from last rolling release fork")
285309
new_base_commit_map = {}
286310
new_base_commit_map_rev = {}
287-
new_base_commits = repo.git.log(f"{latest_resf_sha.decode()}..HEAD")
311+
new_base_commits = repo.git.log(f"{common_sha.decode()}..HEAD")
288312
for line in new_base_commits.split("\n"):
289313
if line.startswith("commit "):
290314
ciq_commit = line.split("commit ")[1]

0 commit comments

Comments
 (0)