Skip to content

Commit 57ba2bb

Browse files
thomas-roosgithub-actions[bot]
authored andcommitted
jailer-bin: add checksum gen for devtool upgrade
(cherry picked from commit e51d04c)
1 parent 041b019 commit 57ba2bb

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

recipes-containers/firecracker-bin/jailer-bin_1.10.1.bb

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ SRC_URI = "https://github.com/firecracker-microvm/firecracker/releases/download/
2121
SRC_URI[x86_64.sha256sum] = "36112969952b0e34fadcfca769d48a55dc22cbba99af17e02bd0e24fc35adc77"
2222
SRC_URI[aarch64.sha256sum] = "9e3641071de140979afaac0c52fdc107baeba398bdb5709c12f77ee469207fcd"
2323

24+
UPGRADE_ARCHS = "x86_64 aarch64"
25+
RECIPE_UPGRADE_EXTRA_TASKS = "update_other_arch_checksum"
26+
2427
UPSTREAM_CHECK_REGEX ?= "releases/tag/v?(?P<pver>\d+(\.\d+)+)"
2528

2629
UPSTREAM_CHECK_URI = "https://github.com/firecracker-microvm/firecracker/releases"
@@ -51,4 +54,49 @@ do_install() {
5154
}
5255

5356
# https://bugzilla.yoctoproject.org/show_bug.cgi?id=15227
54-
PACKAGE_DEPENDS:append:class-target = " virtual/cross-binutils"
57+
PACKAGE_DEPENDS:append:class-target = " virtual/cross-binutils"
58+
59+
python do_update_other_arch_checksum() {
60+
import urllib.request
61+
import hashlib
62+
import re
63+
64+
pv = d.getVar('PV')
65+
recipe_file = d.getVar('FILE')
66+
upgrade_archs = d.getVar('UPGRADE_ARCHS').split()
67+
current_arch = d.getVar('ARCH_DIR')
68+
69+
with open(recipe_file, 'r') as f:
70+
content = f.read()
71+
72+
# Update checksums for other architectures (exclude current one)
73+
for arch in upgrade_archs:
74+
if arch != current_arch:
75+
url = f"https://github.com/firecracker-microvm/firecracker/releases/download/v{pv}/firecracker-v{pv}-{arch}.tgz"
76+
77+
with urllib.request.urlopen(url) as response:
78+
data = response.read()
79+
sha256_hash = hashlib.sha256(data).hexdigest()
80+
81+
# Add or update checksum line
82+
pattern = rf'^SRC_URI\[{arch}\.sha256sum\] = ".*"$'
83+
replacement = f'SRC_URI[{arch}.sha256sum] = "{sha256_hash}"'
84+
85+
if re.search(pattern, content, re.MULTILINE):
86+
content = re.sub(pattern, replacement, content, flags=re.MULTILINE)
87+
else:
88+
# Add new line after existing checksums
89+
content = re.sub(
90+
r'(SRC_URI\[\w+\.sha256sum\] = ".*")',
91+
rf'\1\n{replacement}',
92+
content,
93+
count=1
94+
)
95+
96+
bb.note(f"Updated {arch} SHA256: {sha256_hash}")
97+
98+
with open(recipe_file, 'w') as f:
99+
f.write(content)
100+
}
101+
addtask do_update_other_arch_checksum
102+
do_update_other_arch_checksum[network] = "1"

0 commit comments

Comments
 (0)