As per title.
Portage currently constructs the module-rebuild package set via packages which own files in /lib/modules.
This results in the scenario where sys-kernel/gentoo-kernel (or other similar type packages) are wrongly recorded as external modules in the module-rebuild set because the package owns files in the /lib/modules directory.
Steps to Reproduce:
2.emerge --ask @module-rebuild
3.emerge output will show sys-kernel/gentoo-kernel alongside any other external kmods e.g. zfs-kmod, nvidia etc
sys-kernel/gentoo-kernel wrongly recorded as external kernel module.
sys-kernel/gentoo-kernel should not be recorded as an external kernel module.
I changed (locally) the module-rebuild package set logic to construct itself via inheritance of linux-mod.eclass as opposed to ownership of files in /lib/modules.
However there is the small issue of the following packages which inherit linux-mod.eclass, but only conditionally build external kernel modules.
I spoke with Zac on irc about the possibility of staying with the ownership based logic and adding 'exclude-files=/usr/src' to the module-rebuild set which works nicely, other than the small problem of zfs + spl being installed in that directory. As a result I tried 'exclude-files=/usr/src/linux*' which would hopefully exclude all kernel packages from the ownership logic while allowing zfs to be recorded in the module-rebuild set, but unfortunately exclude-files does not currently accept globs which means this doesn't work.
Another approach that Zac proposed would be via 'PROPERTIES="kernel-module"'. As far as I'm aware this would require modifying all the ebuilds individually, unless it is added to the linux-mod.eclass phases as opposed to the class itself (as some ~6 packages inherit linux-mod.eclass but only build kernel modules if USE=foo).
We could also do something like RESTRICT=module-rebuild.
Had bug #757654 too
A possibility is to extend OwnerSet with behavior like VariableSet, so we can exclude owners based on RESTRICT.
Bug 757654 comment 2 is a possibility, though we may need to add glob support to the exclude-files parameter.
We can add exclude-files glob support similar to this:
Fix has been submitted to Portage https://github.com/gentoo/portage/pull/694
PR was merged into Portage 3.0.19.