2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-02-14 19:59:00 +00:00

Fallback to filename for PE format kernels

Some ARM64 kernels ship as EFI executables, but it's
not obvious how to extract version numbers from those properly.
This commit is contained in:
Jarrod Johnson
2026-01-15 14:29:23 -05:00
parent a0a5887214
commit f8b8ce3847

View File

@@ -824,11 +824,14 @@ def version_sort(iterable):
def get_kern_version(filename):
with open(filename, 'rb') as kernfile:
checkgzip = kernfile.read(2)
if checkgzip == b'\x1f\x8b':
# gzipped... this would probably be aarch64
header = kernfile.read(2)
if header == b'\x1f\x8b':
# gzipped... we can't process this right now,
# assume the filename has the version embedded
return os.path.basename(filename).replace('vmlinuz-', '')
if header == b'MZ':
# PE format, no easy way to get version, assume filename has it
return os.path.basename(filename).replace('vmlinuz-', '')
kernfile.seek(0x20e)
offset = struct.unpack('<H', kernfile.read(2))[0] + 0x200
kernfile.seek(offset)