Add directory name for checksum file
Fixes: https://pagure.io/pungi/issue/745 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
dec00fe2f4
commit
9ab3840085
@ -1429,7 +1429,7 @@ Media Checksums Settings
|
|||||||
* ``type``
|
* ``type``
|
||||||
* ``type_suffix``
|
* ``type_suffix``
|
||||||
* ``version``
|
* ``version``
|
||||||
* ``version``
|
* ``dirname`` (only if ``media_checksum_one_file`` is enabled)
|
||||||
|
|
||||||
For example, for Fedora the prefix should be
|
For example, for Fedora the prefix should be
|
||||||
``%(release_short)s-%(variant)s-%(version)s-%(date)s%(type_suffix)s.%(respin)s``.
|
``%(release_short)s-%(variant)s-%(version)s-%(date)s%(type_suffix)s.%(respin)s``.
|
||||||
|
@ -60,10 +60,10 @@ class ImageChecksumPhase(PhaseBase):
|
|||||||
images.setdefault((variant, arch, path), set()).add(image)
|
images.setdefault((variant, arch, path), set()).add(image)
|
||||||
return images
|
return images
|
||||||
|
|
||||||
def _get_base_filename(self, variant, arch):
|
def _get_base_filename(self, variant, arch, **kwargs):
|
||||||
base_checksum_name = self.compose.conf['media_checksum_base_filename']
|
base_checksum_name = self.compose.conf['media_checksum_base_filename']
|
||||||
if base_checksum_name:
|
if base_checksum_name:
|
||||||
substs = get_format_substs(self.compose, variant=variant, arch=arch)
|
substs = get_format_substs(self.compose, variant=variant, arch=arch, **kwargs)
|
||||||
base_checksum_name = (base_checksum_name % substs).format(**substs)
|
base_checksum_name = (base_checksum_name % substs).format(**substs)
|
||||||
base_checksum_name += '-'
|
base_checksum_name += '-'
|
||||||
return base_checksum_name
|
return base_checksum_name
|
||||||
@ -74,7 +74,7 @@ class ImageChecksumPhase(PhaseBase):
|
|||||||
|
|
||||||
|
|
||||||
def _compute_checksums(results, cache, variant, arch, path, images,
|
def _compute_checksums(results, cache, variant, arch, path, images,
|
||||||
checksum_types, base_checksum_name, one_file):
|
checksum_types, base_checksum_name_gen, one_file):
|
||||||
for image in images:
|
for image in images:
|
||||||
filename = os.path.basename(image.path)
|
filename = os.path.basename(image.path)
|
||||||
full_path = os.path.join(path, filename)
|
full_path = os.path.join(path, filename)
|
||||||
@ -98,20 +98,23 @@ def _compute_checksums(results, cache, variant, arch, path, images,
|
|||||||
results[checksum_filename].add((filename, filesize, checksum, digest))
|
results[checksum_filename].add((filename, filesize, checksum, digest))
|
||||||
|
|
||||||
if one_file:
|
if one_file:
|
||||||
checksum_filename = os.path.join(path, base_checksum_name + 'CHECKSUM')
|
dirname = os.path.basename(path)
|
||||||
|
base_checksum_name = base_checksum_name_gen(variant, arch, dirname=dirname)
|
||||||
|
checksum_filename = base_checksum_name + 'CHECKSUM'
|
||||||
else:
|
else:
|
||||||
checksum_filename = os.path.join(path, '%s%sSUM' % (base_checksum_name, checksum.upper()))
|
base_checksum_name = base_checksum_name_gen(variant, arch)
|
||||||
|
checksum_filename = '%s%sSUM' % (base_checksum_name, checksum.upper())
|
||||||
|
checksum_path = os.path.join(path, checksum_filename)
|
||||||
|
|
||||||
results[checksum_filename].add((filename, filesize, checksum, digest))
|
results[checksum_path].add((filename, filesize, checksum, digest))
|
||||||
|
|
||||||
|
|
||||||
def make_checksums(topdir, im, checksum_types, one_file, base_checksum_name_gen):
|
def make_checksums(topdir, im, checksum_types, one_file, base_checksum_name_gen):
|
||||||
results = defaultdict(set)
|
results = defaultdict(set)
|
||||||
cache = {}
|
cache = {}
|
||||||
for (variant, arch, path), images in get_images(topdir, im).iteritems():
|
for (variant, arch, path), images in get_images(topdir, im).iteritems():
|
||||||
base_checksum_name = base_checksum_name_gen(variant, arch)
|
|
||||||
_compute_checksums(results, cache, variant, arch, path, images,
|
_compute_checksums(results, cache, variant, arch, path, images,
|
||||||
checksum_types, base_checksum_name, one_file)
|
checksum_types, base_checksum_name_gen, one_file)
|
||||||
|
|
||||||
for file in results:
|
for file in results:
|
||||||
dump_checksums(file, results[file])
|
dump_checksums(file, results[file])
|
||||||
|
@ -194,4 +194,4 @@ def load_config(data={}, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def load_bin(name):
|
def load_bin(name):
|
||||||
return imp.load_source('pungi_cli_fake_' + name, os.path.dirname(__file__) + "/../bin/" + name)
|
return imp.load_source('pungi_cli_fake_' + name, os.path.dirname(__file__) + "/../bin/" + name)
|
||||||
|
@ -95,7 +95,7 @@ class TestImageChecksumPhase(PungiTestCase):
|
|||||||
compose = DummyCompose(self.topdir, {
|
compose = DummyCompose(self.topdir, {
|
||||||
'media_checksums': ['sha256'],
|
'media_checksums': ['sha256'],
|
||||||
'media_checksum_one_file': True,
|
'media_checksum_one_file': True,
|
||||||
'media_checksum_base_filename': '%(release_short)s-%(variant)s-%(version)s-%(date)s%(type_suffix)s.%(respin)s_%(label)s'
|
'media_checksum_base_filename': '%(release_short)s-%(variant)s-%(version)s-%(date)s%(type_suffix)s.%(respin)s_%(label)s-%(dirname)s'
|
||||||
})
|
})
|
||||||
compose.compose_label = 'Alpha-1.0'
|
compose.compose_label = 'Alpha-1.0'
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ class TestImageChecksumPhase(PungiTestCase):
|
|||||||
phase.run()
|
phase.run()
|
||||||
|
|
||||||
dump_checksums.assert_called_once_with(
|
dump_checksums.assert_called_once_with(
|
||||||
self.topdir + '/compose/Client/i386/iso/test-Client-1.0-20151203.t.0_Alpha-1.0-CHECKSUM',
|
self.topdir + '/compose/Client/i386/iso/test-Client-1.0-20151203.t.0_Alpha-1.0-iso-CHECKSUM',
|
||||||
set([('image.iso', 123, 'sha256', 'cafebabe')]))
|
set([('image.iso', 123, 'sha256', 'cafebabe')]))
|
||||||
cc.assert_called_once_with(self.topdir + '/compose/Client/i386/iso/image.iso', ['sha256'])
|
cc.assert_called_once_with(self.topdir + '/compose/Client/i386/iso/image.iso', ['sha256'])
|
||||||
compose.image.add_checksum.assert_called_once_with(None, 'sha256', 'cafebabe')
|
compose.image.add_checksum.assert_called_once_with(None, 'sha256', 'cafebabe')
|
||||||
|
Loading…
Reference in New Issue
Block a user