kmod ports and conflicts when upgrading

From: David Chisnall <theraven_at_FreeBSD.org>
Date: Tue, 12 Sep 2023 09:25:40 UTC
Hi,

As part of the work to run FreeBSD containers on other operating systems via Podman, I have written a device driver for the QEMU firmware config interface.  I am currently building this via an overlay port, but aim to upstream it into -CURRENT soonish.  In parallel, I’d like to add a port for it.

Both ports and base install kernel modules in the same place and so I’m worried that someone will install the port, update FreeBSD to a version that includes the module in base, and then end up with problems when the uninstall the port (or have the upgrade fail because the file already exists).

I’m sure this problem must have been solved for other things that have migrated in a similar path.  Is there a way to automatically uninstall a port when doing a major version upgrade or when a base-system thing tries to write to the same location (or, at least, ensure that it is not removed when the package is removed later)?

David