diff --git a/sau/gentoo.py b/sau/gentoo.py index 4e3e27c..f740706 100644 --- a/sau/gentoo.py +++ b/sau/gentoo.py @@ -419,7 +419,8 @@ def pkg_upgrade(): for sysfile in ['config', 'initramfs', 'System.map', 'vmlinuz', 'kernel']: match = sorted( [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:]: log.debug(f"Removing old kernel file {f}") os.remove(os.path.join(root, f))