Skip to content

Commit 8e0a02f

Browse files
authored
Merge pull request #3758 from lexming/fix-chksum-dict
Consider sources provided as dict in EasyBlock.check_checksums_for
2 parents a5345e1 + 865f1e5 commit 8e0a02f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

easybuild/framework/easyblock.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,12 @@ def check_checksums_for(self, ent, sub='', source_cnt=None):
20262026

20272027
for fn, checksum in zip(sources + patches, checksums):
20282028
if isinstance(checksum, dict):
2029-
checksum = checksum.get(fn)
2029+
# sources entry may be a dictionary rather than just a string value with filename
2030+
if isinstance(fn, dict):
2031+
filename = fn['filename']
2032+
else:
2033+
filename = fn
2034+
checksum = checksum.get(filename)
20302035

20312036
# take into account that we may encounter a tuple of valid SHA256 checksums
20322037
# (see https://github.com/easybuilders/easybuild-framework/pull/2958)

test/framework/easyblock.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,21 @@ def run_checks():
20732073
# no checksum issues
20742074
self.assertEqual(eb.check_checksums(), [])
20752075

2076+
# checksums as dict for some files
2077+
eb.cfg['checksums'] = [
2078+
{
2079+
'toy-0.0.tar.gz': '44332000aa33b99ad1e00cbd1a7da769220d74647060a10e807b916d73ea27bc',
2080+
'toy-0.1.tar.gz': '123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234',
2081+
},
2082+
'81a3accc894592152f81814fbf133d39afad52885ab52c25018722c7bda92487', # toy-*.patch
2083+
'4196b56771140d8e2468fb77f0240bc48ddbf5dabafe0713d612df7fafb1e458', # toy-extra.txt
2084+
]
2085+
self.assertEqual(eb.check_checksums(), [])
2086+
2087+
# sources can also have dict entries
2088+
eb.cfg['sources'] = [{'filename': 'toy-0.0.tar.gz', 'download_fileame': 'toy.tar.gz'}]
2089+
self.assertEqual(eb.check_checksums(), [])
2090+
20762091
def test_this_is_easybuild(self):
20772092
"""Test 'this_is_easybuild' function (and get_git_revision function used by it)."""
20782093
# make sure both return a non-Unicode string

0 commit comments

Comments
 (0)