Skip to content

Commit ecac148

Browse files
committed
take into account that a checksum value may be a tuple of valid checksum in EasyBlock.check_checksums
1 parent 4f59a29 commit ecac148

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

easybuild/framework/easyblock.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,8 +1857,15 @@ def check_checksums_for(self, ent, sub='', source_cnt=None):
18571857
if isinstance(checksum, dict):
18581858
checksum = checksum.get(fn)
18591859

1860-
if not is_sha256_checksum(checksum):
1861-
msg = "Non-SHA256 checksum found for %s: %s" % (fn, checksum)
1860+
# take into account that we may encounter a tuuple of valid checksums
1861+
# (see https://github.com/easybuilders/easybuild-framework/pull/2958)
1862+
if isinstance(checksum, tuple):
1863+
valid_checksums = checksum
1864+
else:
1865+
valid_checksums = (checksum,)
1866+
1867+
if not all(is_sha256_checksum(c) for c in valid_checksums):
1868+
msg = "Non-SHA256 checksum(s) found for %s: %s" % (fn, valid_checksums)
18621869
checksum_issues.append(msg)
18631870

18641871
return checksum_issues

test/framework/easyblock.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1690,7 +1690,7 @@ def run_checks():
16901690
expected = "Checksums missing for one or more sources/patches in toy-0.0-gompi-2018a-test.eb: "
16911691
expected += "found 1 sources + 1 patches vs 1 checksums"
16921692
self.assertEqual(res[0], expected)
1693-
self.assertTrue(res[1].startswith("Non-SHA256 checksum found for toy-0.0.tar.gz:"))
1693+
self.assertTrue(res[1].startswith("Non-SHA256 checksum(s) found for toy-0.0.tar.gz:"))
16941694

16951695
# check for main sources/patches should reveal two issues with checksums
16961696
res = eb.check_checksums_for(eb.cfg)
@@ -1708,6 +1708,34 @@ def run_checks():
17081708
self.assertTrue(res[idx].startswith(expected))
17091709
idx += 1
17101710

1711+
# check whether tuple of alternative SHA256 checksums is correctly recognized
1712+
toy_ec = os.path.join(testdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb')
1713+
1714+
ec = process_easyconfig(toy_ec)[0]
1715+
eb = get_easyblock_instance(ec)
1716+
1717+
# single SHA256 checksum per source/patch: OK
1718+
eb.cfg['checksums'] = [
1719+
'44332000aa33b99ad1e00cbd1a7da769220d74647060a10e807b916d73ea27bc', # toy-0.0.tar.gz
1720+
'45b5e3f9f495366830e1869bb2b8f4e7c28022739ce48d9f9ebb159b439823c5', # toy-*.patch
1721+
'4196b56771140d8e2468fb77f0240bc48ddbf5dabafe0713d612df7fafb1e458', # toy-extra.txt]
1722+
]
1723+
# no checksum issues
1724+
self.assertEqual(eb.check_checksums(), [])
1725+
1726+
# tuple of two alternate SHA256 checksums: OK
1727+
eb.cfg['checksums'] = [
1728+
(
1729+
# two alternate checksums for toy-0.0.tar.gz
1730+
'a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd',
1731+
'44332000aa33b99ad1e00cbd1a7da769220d74647060a10e807b916d73ea27bc',
1732+
),
1733+
'45b5e3f9f495366830e1869bb2b8f4e7c28022739ce48d9f9ebb159b439823c5', # toy-*.patch
1734+
'4196b56771140d8e2468fb77f0240bc48ddbf5dabafe0713d612df7fafb1e458', # toy-extra.txt
1735+
]
1736+
# no checksum issues
1737+
self.assertEqual(eb.check_checksums(), [])
1738+
17111739
def test_this_is_easybuild(self):
17121740
"""Test 'this_is_easybuild' function (and get_git_revision function used by it)."""
17131741
# make sure both return a non-Unicode string

0 commit comments

Comments
 (0)