add magic
Some checks failed
Build empanada images for imagefactory / buildx (push) Failing after 5s
Build empanada container images for lorax / buildx (push) Successful in 1s

This commit is contained in:
Louis Abel 2024-11-15 15:08:03 -07:00
parent a4d6899601
commit f268502918
Signed by: label
GPG key ID: 2A6975660E424560

View file

@ -14,6 +14,7 @@ import xmltodict
import productmd.treeinfo
import productmd.composeinfo
import pycdlib
import magic
import empanadas
import kobo.shortcuts
from empanadas.common import Color
@ -1342,6 +1343,19 @@ class Idents:
return False
@staticmethod
def get_magic(m):
"""
Gets magic data of a given file
"""
try:
meta = magic.detect_from_filename(m)
except ValueError as exc:
print(exc)
return False
return meta
@staticmethod
def get_vol_id(i):
"""
@ -1353,6 +1367,14 @@ class Idents:
except pycdlib.pycdlibexception.PyCdlibInvalidISO as exc:
print(exc)
return False
# This is for s390x. a temporary hack
except pycdlib.pycdlibexception.PyCdlibInvalidInput as exc:
print(exc)
print('Trying magic instead')
magic_data = Idents.get_magic(i)
if magic_data.mime_type == 'application/x-iso9660-image':
volume_id = magic_data.name.split("'")[1]
return volume_id
pvd = iso.pvd
volume_id = pvd.volume_identifier.decode('UTF-8').strip()