FIx looping kernel-devsrc postinst on systems living in the past.#240
Conversation
The kernel-devsrc.bbappend currently uses its own implementation of the NI-specific postinst methods. There already exists a kernel-devsrc-nilrt.inc file which includes a more modern version of the same function, and which is sourced by the alternative kernel-devsrc packages. Use the kernel-devsrc-nilrt.inc file which is common to all NILRT kernel-devsrc implementations, in the primary version of the package, for easier maintenance. Signed-off-by: Alex Stewart <alex.stewart@ni.com>
IPK data segment files have their file modification times set at the datetime when they were packed into the IPK archive. On unpack, opkg intentionally does not refresh this timestamp. This means that it is possible for system to have it software clock set before the mtime of the files its installing. This can cause unintended behavior for packages which call GNU make in their postinst scripts; kernel-devsrc is one such package. Refresh the mtime of all the source files installed by kernel-devsrc prior to calling `make` - to ensure that they are behind the software clock source when `make` is executing. Signed-off-by: Alex Stewart <alex.stewart@ni.com>
The `gcc` and `as` utilities are required by the kernel-devsrc Makefile when rebuilding. Because the NI-specific postinst calls `make`, we must provide these utilities through package dependencies. Signed-off-by: Alex Stewart <alex.stewart@ni.com>
Break the common kernel-devsrc-* components into two includes files. kernel-devsrc-nilrt.inc contains content which is common to all NI kernel-devsrc packages. kernel-devsrc-nilrt-alt.inc contains content common to only the alternative-kernel devsrc packages. Signed-off-by: Alex Stewart <alex.stewart@ni.com>
Rename to kernel-devsrc-nilrt-alternate.inc to be consistent with the linux-nilrt-* includes naming. Signed-off-by: Alex Stewart <alex.stewart@ni.com>
OE throws a QA warning during kernel-devsrc-*:do_package, about the /usr/src directory not being installed into any package. When alternate kernel-devsrc packages remove the /usr/src/kernel symlink, the /usr/src path in the package install root becomes empty, and so triggers the warning. Try to remove the path from the install root, to satisfy OE. Signed-off-by: Alex Stewart <alex.stewart@ni.com>
Use tabs for indentation in shell functions. Nothing in this commit is intended to change behavior. Signed-off-by: Alex Stewart <alex.stewart@ni.com>
There was a problem hiding this comment.
This looks good and I like the clean-up.
I would sleep a lot better if you could also test that installing one of the alternate kernels (for example opkg install packagegroup-ni-debug-kernel) still works and NI out of tree modules get versioned correctly: for example you can see nikal when running lsmod after booting the alternate kernel. This requires installing the NI drivers on the VM or using real hardware.
|
I'm fine with this change, but I wonder if we should have a warning output from "opkg update" if Packages.gz is newer than the system time. In general, Packages.gz should always be "older" than the current system time, and if not output a warning message similar to what gcc/make does. I'm just a bit concerned that this may happen to other IPK/postinst/prerm/etc scripts. Maybe even promote the error all the way to MAX - but that's a UI element that I really don't want to get into. |
|
@gratian I also tried installing the -next packagegroup on a 21.3 runmode with ni-kal already installed. It successfully rebuilt the driver and I could reload it. |
|
Thanks. LGTM. Ship it! |
The NI implementation of the
kernel-devsrcpackages have a postinst whichcds into the kernel source directory and invokesmaketo prepare the kernel modules. GNUmakeuses file modification times to determine which target dependencies require rebuilding. Whenopkgunpacks thekernel-devsrcdata segment, it intentionally does not refresh the file modification times; which means that the extracted files have their mtimes set to when they were packed by the IPK build server. On systems where the software clock is set backwards in time (either due to not having an RTC, or being enslaved to a network time server), it is possible for the system time to be behind the date on the source files' mtime.Normally, you would expect
maketo skip creating some targets in this case; andmakeindeed throws a warning during compilation to that affect. However, thekernel-devsrcpackage also includes theobjtoolutility, which generates - as a consequence of its Makefile target - intermediate files which are reingested bymake. Some exotic interaction in this special circumstance causes thekernel-devsrcpostinst to loop indefinitely. The system appears to hang in this case.The thrust of this PR is to fix this loop by reconciling the mtime on the
kernel-devsrcdata files. Before invokingmake, the postinst will now find and touch the mtime of all the source files - rolling them back to whenever the software clock is set. The remainder of this PR cleans up the includes files which are shared between thekernel-devsrc(prime) bbappend and the alternative kernel flavors' recipes.NI-AZDO #1605300
Note: the
kernel-devsrcpostinst will still throw a warning during compilation, alerting the user that the/usr/include/stdc-predef.hfile is living in the future (for the same reason as above.) However, this doesn't seem to be a problem for the Makefile, and I don't think its appropriate forkernel-devsrcto refresh its mtime, because the file is owned by thelibc6-devpackage.As a result, the user might see a few iterations of this warning during compilation:
Testing
kernel-devsrc{-*}recipes. Verified that the resulting packages look correct./usr/srcdirectory being unpackaged when building the alternative -devsrc recipes.kernel-devsrcpackage to a VM which has its soft-clock setback to 2000-01-01. Verified that 1) thegccandastools are now installed as dependencies, and 2) the compilation now succeeds without looping.Maintainership
@ni/rtos