Skip to content

Commit ba413cf

Browse files
committed
checksum tuple value may also be (<checksum type>, <checksum value>)
1 parent ecac148 commit ba413cf

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

easybuild/framework/easyblock.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ def checksum_step(self):
18301830

18311831
def check_checksums_for(self, ent, sub='', source_cnt=None):
18321832
"""
1833-
Utility method: check whether checksums for all sources/patches are available, for given entity
1833+
Utility method: check whether SHA256 checksums for all sources/patches are available, for given entity
18341834
"""
18351835
ec_fn = os.path.basename(self.cfg.path)
18361836
checksum_issues = []
@@ -1857,10 +1857,14 @@ def check_checksums_for(self, ent, sub='', source_cnt=None):
18571857
if isinstance(checksum, dict):
18581858
checksum = checksum.get(fn)
18591859

1860-
# take into account that we may encounter a tuuple of valid checksums
1860+
# take into account that we may encounter a tuple of valid SHA256 checksums
18611861
# (see https://github.com/easybuilders/easybuild-framework/pull/2958)
18621862
if isinstance(checksum, tuple):
1863-
valid_checksums = checksum
1863+
# 1st tuple item may indicate checksum type, must be SHA256 or else it's blatently ignored here
1864+
if len(checksum) == 2 and checksum[0] == CHECKSUM_TYPE_SHA256:
1865+
valid_checksums = (checksum[1],)
1866+
else:
1867+
valid_checksums = checksum
18641868
else:
18651869
valid_checksums = (checksum,)
18661870

test/framework/easyblock.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,15 @@ def run_checks():
17231723
# no checksum issues
17241724
self.assertEqual(eb.check_checksums(), [])
17251725

1726+
# SHA256 checksum with type specifier: OK
1727+
eb.cfg['checksums'] = [
1728+
('sha256', '44332000aa33b99ad1e00cbd1a7da769220d74647060a10e807b916d73ea27bc'), # toy-0.0.tar.gz
1729+
'45b5e3f9f495366830e1869bb2b8f4e7c28022739ce48d9f9ebb159b439823c5', # toy-*.patch
1730+
('sha256', '4196b56771140d8e2468fb77f0240bc48ddbf5dabafe0713d612df7fafb1e458'), # toy-extra.txt]
1731+
]
1732+
# no checksum issues
1733+
self.assertEqual(eb.check_checksums(), [])
1734+
17261735
# tuple of two alternate SHA256 checksums: OK
17271736
eb.cfg['checksums'] = [
17281737
(

0 commit comments

Comments
 (0)