It's common practice to deliver Linux kernel drivers (kernel objects KOs) in the source code, and build and install them on the target computer. For example NVIDIA display drivers and Oracle VirtualBox guest add-on drivers are installed this way. It is also common to receive new versions of the kernel (with appropriate headers) through system update. This requires the KO to be re-built and re-installed, otherwise the device will stop working after update.
In our product installation startup script we want to add the step to make and install the KO on every boot. The user may choose to opt-out, and would have to build and install the KO manually. The device driver communicates with a USB device.
The actual re-build will happen only once when the new kernel is installed, because make will not try to re-build the file that is already there and up-to date.
It takes about two seconds to rebuild the driver, and milliseconds to skip the build during the normal boot (not after kernel update)
In the unlikely event that the build fails, it should not crash the system or make it unstable. However our hardware device will not work.
Some distributions may allow to register hooks, to do actions on certain events, like kernel update. However, we are trying to implement something that will work on the most of the distributions in the uniform way. Our installer is script+tar or script+rpm. Unfortunately for this release we do not have bandwidth to prepare native packages for all the distributions (for example Debian-style).
Is this an acceptable solution? If not, why?
What are the potential risks associated with this approach?
What the correct/preferred place to run make during startup? rc.local or script under init.d or other? The goal is to make it work on the most of the distributions using the same method (if at all possible).