commit:     4a0f408ed58c36002ded30e0b0b702ecf5d147e4
Author:     Nowa Ammerlaan <nowa <AT> gentoo <DOT> org>
AuthorDate: Sun Mar  2 08:58:22 2025 +0000
Commit:     Nowa Ammerlaan <nowa <AT> gentoo <DOT> org>
CommitDate: Mon Mar  3 17:45:55 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4a0f408e

kernel-install.eclass: cleanup dead symlinks after removal

Since we remove /usr/src/linux-KV_FULL but by design keep the
/lib/modules/KV_FULL, we end up with some dead symlinks after
depcleaning a dist-kernel. This has the unfortunate side effect of
tricking systemd's kernel-install into thinking that a kernel image
for this kernel still exists. Which leads to some ugliness further
down the line. We can easily resolve the problem by cleaning up these
dead symlinks.

Signed-off-by: Nowa Ammerlaan <nowa <AT> gentoo.org>

 eclass/kernel-install.eclass | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index cf34007844a8..67143278f368 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -808,6 +808,9 @@ kernel-install_pkg_postrm() {
                        find "${kernel_dir}" -depth -type d -empty -delete
                eend ${?}
        fi
+
+       # Clean up dead symlinks
+       find -L "${EROOT}/lib/modules/${KV_FULL}" -type l -delete
 }
 
 # @FUNCTION: kernel-install_pkg_config

Reply via email to