better kernel version sorting

should now detect that 6.12.16 is newer than 6.6.74 for example
This commit is contained in:
Fredrik Eriksson 2025-02-28 07:53:11 +01:00
parent 17fc601022
commit bbe23b1549
Signed by: feffe
GPG Key ID: 20651C52AADCDB8D

View File

@ -419,7 +419,8 @@ def pkg_upgrade():
for sysfile in ['config', 'initramfs', 'System.map', 'vmlinuz', 'kernel']: for sysfile in ['config', 'initramfs', 'System.map', 'vmlinuz', 'kernel']:
match = sorted( match = sorted(
[f for f in files if f.startswith(f'{sysfile}-')], [f for f in files if f.startswith(f'{sysfile}-')],
reverse=True) reverse=True,
key=lambda x: tuple(map(int, x.split('-')[1].split('.')[:3])))
for f in match[keep_kernels:]: for f in match[keep_kernels:]:
log.debug(f"Removing old kernel file {f}") log.debug(f"Removing old kernel file {f}")
os.remove(os.path.join(root, f)) os.remove(os.path.join(root, f))