eclean-kernel icon indicating copy to clipboard operation
eclean-kernel copied to clipboard

Add --write-eclean-kernel-preserved-set option

Open Flowdalic opened this issue 1 year ago • 6 comments

This options makes eclean-kernel create (or update) a portage user set called 'eclean-kernel-preserved'. Since user sets are automatically part of the world set, this prevents kernels that are preserved by eclean-kernel to be uninstalled by portage via the depclean mechanism.

Flowdalic avatar Mar 20 '23 14:03 Flowdalic

I don't think this is the right approach. It basically assumes that the PM should remove kernels unless user calls eclean-kernel first, in which case eclean-kernel blocks the PM from removing kernels.

It would really make more sense if emerge marked newly installed kernels as "non-uninstallable", and EK removed these markers in order to unblock removal.

mgorny avatar Mar 21 '23 12:03 mgorny

I don't think this is the right approach.

And I think I agree. However, this approach seems to do the job of preserving installed kernels from --depclean. You only have to

  1. emerge @world
  2. eclean-kernel --num 3 --write-eclean-kernel-preserved-set
  3. emerge --depclean

that is, you should run eclean-kernel prior --depclean so that the dynamic user set is generated. Your proposed solution does not have this requirement. But on the other hand, it would require modifications to portage (if I understand your proposal correctly), and, probably overall require more effort.

While I am not absolutely happy with the approach in this PR, it is a relatively small modification. The only thing that I do not like is the dependency on gentoolkit, but it was the only(?) API I could find to query the package owning a file1.

But overall, I like it, and hence would like to continue with this PR. You are, of course, free to reject it on various grounds. I'd like to know where you stand: Is it, as is, an absolute no-go for eclean-kernel?

1: I was quite surprised that I was unable to find a portage API doing the same. But maybe I missed it?

Flowdalic avatar Mar 29 '23 19:03 Flowdalic

Yes, IMO it's a no-go. It's counterintuitive and it really doesn't belong here.

mgorny avatar Mar 29 '23 19:03 mgorny

Let us see if we can find a compromise. Would introducing an eclean-kerne hook, which is passed the preserved and to be removed kernel versions as arguments, be acceptable? Then users, like me, could add something that creates the dynamic portage set in /etc/eclean-kernel/hook.d.

Flowdalic avatar Mar 29 '23 20:03 Flowdalic

What kind of hook? How would it work?

mgorny avatar Mar 30 '23 02:03 mgorny

What kind of hook? How would it work?

Lines of code say more than a thousands words: Something among the lines of https://github.com/projg2/eclean-kernel/pull/38

Flowdalic avatar Mar 30 '23 07:03 Flowdalic