[live-images] Correctly create format
Extracting extensions from the file name is not reliable as there is no way to determine where extensions start. There can very well be a version.release separated by dot. To bypass this, just use hardcoded list of possible formats. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
e9292fc942
commit
456fbb8812
@ -197,6 +197,8 @@ class LiveImagesPhase(PhaseBase):
|
||||
|
||||
|
||||
class CreateLiveImageThread(WorkerThread):
|
||||
EXTS = ('.iso', '.raw.xz')
|
||||
|
||||
def process(self, item, num):
|
||||
compose, cmd, variant, arch = item
|
||||
try:
|
||||
@ -290,20 +292,17 @@ class CreateLiveImageThread(WorkerThread):
|
||||
compose.im.add(variant=variant.uid, arch=arch, image=img)
|
||||
|
||||
def _is_image(self, path):
|
||||
for ext in ('.iso', '.raw.xz'):
|
||||
for ext in self.EXTS:
|
||||
if path.endswith(ext):
|
||||
return True
|
||||
return False
|
||||
|
||||
def _get_format(self, path):
|
||||
"""Extract all extensions from the path."""
|
||||
exts = []
|
||||
while True:
|
||||
path, ext = os.path.splitext(path)
|
||||
if not ext:
|
||||
break
|
||||
exts.append(ext.lstrip('.'))
|
||||
return '.'.join(reversed(exts))
|
||||
"""Get format based on extension."""
|
||||
for ext in self.EXTS:
|
||||
if path.endswith(ext):
|
||||
return ext[1:]
|
||||
raise RuntimeError('Getting format for unknown image %s' % path)
|
||||
|
||||
def _write_manifest(self, iso_path):
|
||||
"""Generate manifest for ISO at given path.
|
||||
|
@ -409,7 +409,7 @@ class TestCreateLiveImageThread(PungiTestCase):
|
||||
'output': 'some output',
|
||||
'task_id': 123
|
||||
}
|
||||
koji_wrapper.get_image_path.return_value = ['/path/to/image.raw.xz']
|
||||
koji_wrapper.get_image_path.return_value = ['/path/to/image-a.b-sda.raw.xz']
|
||||
|
||||
t = CreateLiveImageThread(pool)
|
||||
with mock.patch('pungi.phases.live_images.get_file_size') as get_file_size:
|
||||
@ -424,7 +424,7 @@ class TestCreateLiveImageThread(PungiTestCase):
|
||||
log_file=self.topdir + '/logs/amd64/createiso-None-None-None.amd64.log')])
|
||||
self.assertEqual(koji_wrapper.get_image_path.mock_calls, [mock.call(123)])
|
||||
self.assertEqual(copy2.mock_calls,
|
||||
[mock.call('/path/to/image.raw.xz', self.topdir + '/compose/Client/amd64/iso/image-name')])
|
||||
[mock.call('/path/to/image-a.b-sda.raw.xz', self.topdir + '/compose/Client/amd64/iso/image-name')])
|
||||
|
||||
write_manifest_cmd = ' && '.join([
|
||||
'cd ' + self.topdir + '/compose/Client/amd64/iso',
|
||||
|
Loading…
Reference in New Issue
Block a user