Summary: | sys-kernel/gentoo-kernel: RFE: USE=cleanup-boot & USE=cleanup-src & USE=update-bootloader | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Johannes Niess <johannes_niess> |
Component: | Current packages | Assignee: | Distribution Kernel Project <dist-kernel> |
Status: | UNCONFIRMED --- | ||
Severity: | enhancement | CC: | dharding, ionen, jstein, sam |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Johannes Niess
2021-02-19 20:05:08 UTC
Those call /sbin/installkernel during pkg_postinst() to install the kernel which in turn (for installkernel-gentoo) run /etc/kernel/postinst.d/* scripts. You can have a simple script in there to update your bootloader (with whatever method is needed, there's a lot of different setups), and even run eclean-kernel if wanted. As for the sources, they already gets cleaned up during normal depclean (those are also smaller than normal sources, just enough to build third party modules or update configs). Thanks for the tip regarding USE=update-bootloader. That's resolved. What's missing is the deletion bit. Eclean-kernel won't work for cleaning /boot on its own, as the kernels to be removed are already referenced in the boot loader via previous /etc/kernel/postinst.d/* scripts. Eclean-kernel has no '--keep-intalled-packages' option. 'Eclean-kernel --num' is a crude workaround and doesn't need to know the version, so it could also be called from /etc/kernel/postinst.d/* What about adding a corresponding /etc/kernel/pre-del.d/* called by the kernel ebuilds during removal? In case the scripts see a $version / $package, they easily can nuke /usr/src/kernel-<version> and files in /boot. (In reply to Johannes Niess from comment #2) > Thanks for the tip regarding USE=update-bootloader. That's resolved. > > What's missing is the deletion bit. > > Eclean-kernel won't work for cleaning /boot on its own, as the kernels to be > removed are already referenced in the boot loader via previous > /etc/kernel/postinst.d/* scripts. Eclean-kernel has no > '--keep-intalled-packages' option. 'Eclean-kernel --num' is a crude > workaround and doesn't need to know the version, so it could also be called > from /etc/kernel/postinst.d/* > > What about adding a corresponding /etc/kernel/pre-del.d/* called by the > kernel ebuilds during removal? In case the scripts see a $version / > $package, they easily can nuke /usr/src/kernel-<version> and files in /boot. /usr/portage/eclass/kernel-build.eclass already has a hook to play around with: # @FUNCTION: kernel-install_pkg_postrm # @DESCRIPTION: # No-op at the moment. Will be used to remove obsolete kernels # in the future. kernel-install_pkg_postrm() { debug-print-function ${FUNCNAME} "${@}" if [[ -z ${ROOT} ]] && use initramfs; then local ver="${PV}${KV_LOCALVERSION}" local image_path=$(dist-kernel_get_image_path) ebegin "Removing initramfs" rm -f "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" && find "${EROOT}/usr/src/linux-${ver}" -depth -type d -empty -delete eend ${?} fi } (In reply to Johannes Niess from comment #3) > (In reply to Johannes Niess from comment #2) > > Thanks for the tip regarding USE=update-bootloader. That's resolved. > > > > What's missing is the deletion bit. > > > > Eclean-kernel won't work for cleaning /boot on its own, as the kernels to be > > removed are already referenced in the boot loader via previous > > /etc/kernel/postinst.d/* scripts. Eclean-kernel has no > > '--keep-intalled-packages' option. 'Eclean-kernel --num' is a crude > > workaround and doesn't need to know the version, so it could also be called > > from /etc/kernel/postinst.d/* > > > > What about adding a corresponding /etc/kernel/pre-del.d/* called by the > > kernel ebuilds during removal? In case the scripts see a $version / > > $package, they easily can nuke /usr/src/kernel-<version> and files in /boot. > > /usr/portage/eclass/kernel-install.eclass already has a hook to play around > with: > # @FUNCTION: kernel-install_pkg_postrm > # @DESCRIPTION: > # No-op at the moment. Will be used to remove obsolete kernels > # in the future. > kernel-install_pkg_postrm() { > debug-print-function ${FUNCNAME} "${@}" > > if [[ -z ${ROOT} ]] && use initramfs; then > local ver="${PV}${KV_LOCALVERSION}" > local image_path=$(dist-kernel_get_image_path) > ebegin "Removing initramfs" > rm -f > "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" && > find "${EROOT}/usr/src/linux-${ver}" -depth -type d > -empty -delete > eend ${?} > fi > } It is in the kernel-install.eclass I use the script below since many months. For now I haven't added it to my /etc/kernel/postinst.d/* scripts: #! /bin/sh # Clean up sources emerge --depclean sys-kernel/gentoo-kernel # Ensure eclean-kernel sees all candidates for deletion from /boot and modules grub-mkconfig -o /boot/grub/grub.cfg # Remove all but latest two kernels using app-admin/eclean-kernel eclean-kernel -d -n2 # Clean up grub afterwards grub-mkconfig -o /boot/grub/grub.cfg |