Skip to content

Commit 7bd0e84

Browse files
cfriedtkartben
authored andcommitted
west: commands: blobs: fail on checksum error
If a blob checksum does not match what is recorded in the associated module.yml file, `west blobs fetch` should (eventually) fail. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
1 parent 563f1f9 commit 7bd0e84

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scripts/west_commands/blobs.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def fetch_blob(self, url, path):
120120

121121
# Compare the checksum of a file we've just downloaded
122122
# to the digest in blob metadata, warn user if they differ.
123-
def verify_blob(self, blob):
123+
def verify_blob(self, blob) -> bool:
124124
self.dbg('Verifying blob {module}: {abspath}'.format(**blob))
125125

126126
status = zephyr_module.get_blob_status(blob['abspath'], blob['sha256'])
@@ -140,16 +140,24 @@ def verify_blob(self, blob):
140140
Blob: {blob['path']}
141141
URL: {blob['url']}
142142
Info: {blob['description']}'''))
143+
return False
144+
return True
143145

144146
def fetch(self, args):
147+
bad_checksum_count = 0
145148
blobs = self.get_blobs(args)
146149
for blob in blobs:
147150
if blob['status'] == zephyr_module.BLOB_PRESENT:
148151
self.dbg('Blob {module}: {abspath} is up to date'.format(**blob))
149152
continue
150153
self.inf('Fetching blob {module}: {abspath}'.format(**blob))
151154
self.fetch_blob(blob['url'], blob['abspath'])
152-
self.verify_blob(blob)
155+
if not self.verify_blob(blob):
156+
bad_checksum_count += 1
157+
158+
if bad_checksum_count:
159+
self.err(f"{bad_checksum_count} blobs have bad checksums")
160+
sys.exit(os.EX_DATAERR)
153161

154162
def clean(self, args):
155163
blobs = self.get_blobs(args)

0 commit comments

Comments
 (0)