allow to customize how many kernels to keep on gentoo system upgrade
This commit is contained in:
parent
aafe46d429
commit
39a61aeddd
11
config.cfg
11
config.cfg
@ -16,9 +16,14 @@ version_sensitivity=1
|
|||||||
# not close all deleted files (any platform)
|
# not close all deleted files (any platform)
|
||||||
do_reboot=no
|
do_reboot=no
|
||||||
|
|
||||||
# FreeBSD system update (freebsd-update fetch install, not freebsd-update upgrade)
|
# Attempt to do a system upgrade
|
||||||
|
# FreeBSD: upgrade to latest patch version using freebsd-update fetch install
|
||||||
|
# Gentoo: allow upgrade of sys-kernel/-packages, clean old kernels, and update grub-config
|
||||||
do_system_upgrade=yes
|
do_system_upgrade=yes
|
||||||
|
|
||||||
|
# On Gentoo kernel upgrades, remove all but the last keep_kernels kernels from /boot
|
||||||
|
keep_kernels=4
|
||||||
|
|
||||||
# upgrade packages
|
# upgrade packages
|
||||||
do_package_upgrade=yes
|
do_package_upgrade=yes
|
||||||
|
|
||||||
@ -46,9 +51,7 @@ syslog_loglevel=info
|
|||||||
# Gentoo uses the category/package naming scheme
|
# Gentoo uses the category/package naming scheme
|
||||||
dev-db/postgresql=1
|
dev-db/postgresql=1
|
||||||
|
|
||||||
# Gentoo kernel stuff should be updated manually
|
# It's safer to upgrade zfs manually
|
||||||
sys-kernel/gentoo-sources=99
|
|
||||||
sys-kernel/spl=99
|
|
||||||
sys-fs/zfs-kmod=99
|
sys-fs/zfs-kmod=99
|
||||||
|
|
||||||
# FreeBSD uses the short package name (without category)
|
# FreeBSD uses the short package name (without category)
|
||||||
|
@ -196,12 +196,16 @@ def pkg_upgrade():
|
|||||||
log.warning(line)
|
log.warning(line)
|
||||||
|
|
||||||
if do_grub:
|
if do_grub:
|
||||||
|
keep_kernels = conf.getint('default', 'keep_kernels', default=4)
|
||||||
|
if keep_kernels < 1:
|
||||||
|
log.error('keep_kernels cannot be less than one; falling back to default')
|
||||||
|
keep_kernels = 4
|
||||||
for root, dirs, files in os.walk('/boot'):
|
for root, dirs, files in os.walk('/boot'):
|
||||||
for sysfile in ['config', 'initramfs', 'System.map', 'vmlinuz']:
|
for sysfile in ['config', 'initramfs', 'System.map', 'vmlinuz']:
|
||||||
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)
|
||||||
for f in match[4:]:
|
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))
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user