iso: Extract volume id with xorriso if available

Pungi can use either genisoimage or xorriso to create ISOs.

It also needed isoinfo utility for querying volume ID from the ISO
image. However, the utility is part of the genisoimage suite of tools.

On systems that no longer provide genisoimage, the image would be
successfully generate with xorriso, but then pungi would fail to extract
the volume id leading to metadata with missing values.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2024-04-22 08:38:46 +02:00
parent 5c9e79f535
commit bc0334cc09
6 changed files with 54 additions and 15 deletions

View file

@ -24,6 +24,19 @@ Supported ISO: no
INCORRECT_OUTPUT = """This should never happen: File not found"""
XORRISO_LOAD_OUTPUT = """\
xorriso 1.5.4 : RockRidge filesystem manipulator, libburnia project.
xorriso : NOTE : Loading ISO image tree from LBA 0
xorriso : UPDATE : 7074 nodes read in 1 seconds
Drive current: -indev 'dummy.iso'
Media current: stdio file, overwriteable
Media status : is written , is appendable
Boot record : El Torito , MBR isohybrid cyl-align-off GPT
Media summary: 1 session, 5415454 data blocks, 10.3g data, 4086g free
Volume id : 'My volume id'
"""
# Cached to use in tests that mock os.listdir
orig_listdir = os.listdir
@ -187,6 +200,11 @@ class TestIsoUtils(unittest.TestCase):
self.assertEqual(len(mock_unmount.call_args_list), 0)
self.assertEqual(len(log.mock_calls), 1)
@mock.patch("pungi.wrappers.iso.run")
def test_get_volume_id_xorriso(self, mock_run):
mock_run.return_value = (0, XORRISO_LOAD_OUTPUT)
self.assertEqual(iso.get_volume_id("/dummy.iso", True), "My volume id")
class TestCmpGraftPoints(unittest.TestCase):
def assertSorted(self, *args):