Skip to content

Conversation

@mwilck
Copy link
Contributor

@mwilck mwilck commented Oct 1, 2021

  • labsconf 2021 debugging / profiling
  • weak-modules2: remove pointless debug statements in add_kmp_modules
  • weak-modules2: skip "test" call to has_unresolved_symbols
  • weak-modules2: try incremental depmod in has_unresolved_symbols
  • weak-modules2: remove_kmp(): drop inconsistency test
  • weak-modules2: sanitize "kernel" logic
  • weak-modules2: split run_depmod() and build_initrd()
  • weak-modules2: incremental depmod in run_depmod with WM2_DEPMOD_INC
  • weak-modules2: use needs_initrd for kernel subpackages
  • weak-modules2: factor out get_image_name()
  • weak-modules2: honor INITRD_IN_POSTTRANS for kernel packages

@mwilck mwilck force-pushed the labsconf branch 3 times, most recently from 8d58308 to 7d53d44 Compare October 4, 2021 20:30
@mwilck mwilck force-pushed the master branch 3 times, most recently from 5a09721 to 37cfee6 Compare June 2, 2022 07:56
mwilck added 16 commits August 9, 2022 21:43
The first call is supposed to check whether the kernel at hand
is in an inconsistent state before adding the KMP. But this is
a very rare situation; has_unresolved_symbols() is a slow operation (calling
depmod) and should thus not be called without good reason.

If adding the kmp failed and OPT_DEBUG=1, we carry out this operation
to provide a clue to users.
This test is bogus because remove_kmp() is called after the actual
package removal. The symlinks may still be present, but either
point to a different KMP, or be stale.
Rather than reading "_kernel_" from stdin, use a function argument.
With initrd in posttrans and incremental depmod, the logic for
depmod and initrd rebuilding will become different.
This requires copying modules.* to the temporary dir, too.
Like for KMPs, the information whether modules are present in the
initrd is also valuable for deciding if the intird must be rebuilt
for kernel subpackages.

For the time being, we always set the _kernel_ flag, forcing the
initrd to be rebuilt for these packages, too.
With this patch, if the $INITRD_IN_POSTTRANS environment variable
is set in weak-modules2's environment, it will postpone the rebuilding
of the initramfs to the %posttrans stage if possible. Also, for kernel
subpackages like -extra or -optional, the initrd rebuild will only
be triggered if it's necessary (i.e. if the current initrd contains
at least one of the modules in the package).
We are removing modules here which might be in the initrd.
We can derive kernel-modules and kernel-basenames like we
do in add_kmp_modules. Why don't we do it?

The common case by far is that kernel subpackages are removed
or updated together with the base package. In that case, rebuilding
the initrd in %postun of the subpackage is just a waste, as the
kernel will be uninstalled anyway.

In %postun we can't figure out whether or not the base package
will also be uninstalled. If it's not, in the worst case, some modules
will be kept in initramfs that are no longer installed on the system
itself. That shouldn't hurt. By not rebuilding the initrd here,
we speed up the common case.

We have to call depmod though, in order to make sure that the module
dependency database doesn't hold stale references to uninstalled modules.
depmod ignores modules that are not in the search path of the kernel
being worked on (which holds for the symlink targets in case of
weak modules). We must pass the full path of the symlink.

Using bash namerefs for this purpose.
https://stackoverflow.com/questions/10582763/how-to-return-an-array-in-bash-without-using-globals
Iterate over all installed kernels explicitly instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant