diff options
author | Wolfgang Müller | 2022-04-26 19:11:35 +0200 |
---|---|---|
committer | Wolfgang Müller | 2022-04-26 19:27:11 +0200 |
commit | 34f213ac35ded6b8c824704d6e65fc775837aa39 (patch) | |
tree | ee20b6a9c3388f729669739a75e67ff39c01778e | |
parent | c51013909b5eb64671902e02b9a19d0fd11fbd46 (diff) | |
download | kern-34f213ac35ded6b8c824704d6e65fc775837aa39.tar.gz |
Use /proc/config.gz for config diffs
diff_kernel relies on the existence of the /boot/config-{kernel} file
which is usually installed by the install-kernel script. This file may
be missing on systems with a custom install workflow or EFI systems that
use the systemd install_kernel functionality. The latter installs the
EFI stub kernel only, no auxiliary files of any kind. Comparisons
against the /boot/config-{kernel} file therefore fail on such systems.
This commit attempts to support a wider range of install workflows by
extracting the config from /proc/config.gz instead. Regardless of how
the kernel is installed, this particular file should exist as long as
CONFIG_IKCONFIG is enabled in the running kernel.
A word about "running config": The way that phrase was used previous to
this commit is technically inaccurate, since the "running config" could
change by installing a kernel and replacing the config file under /boot.
Now we *always* refer to the configuration saved within the currently
running kernel.
Diffstat (limited to '')
-rwxr-xr-x | kern | 19 | ||||
-rw-r--r-- | kern.1 | 7 |
2 files changed, 15 insertions, 11 deletions
@@ -4,6 +4,14 @@ set -e KERNFRAG=${KERNFRAG:-/etc/kernfrag} +RUNNING_CONFIG=$(mktemp --suffix=-kern-config) +zcat /proc/config.gz > "$RUNNING_CONFIG" + +# We do want to expand tmpdir now rather than later, +# and mktemp should give us a path without spaces. +# shellcheck disable=SC2064 +trap "{ rm $RUNNING_CONFIG; }" EXIT + err() { printf "kern: %s\n" "$@" >&2 } @@ -43,13 +51,6 @@ get_running_kernel() { uname -r } -get_running_config() { - mount_boot_on_demand - config=/boot/config-$(get_running_kernel) - test -r "$config" || errx "Could not read configuration file: $config" - echo "$config" -} - set_kernel() { kern=${1:-$(get_latest_kernel)} selected=$(get_selected_kernel) @@ -82,7 +83,7 @@ config_kernel() { diff_kernel() { need_kernel_source - diff=${1:-$(get_running_config)} + diff=${1:-$RUNNING_CONFIG} if command -v git >/dev/null; then git diff --no-index "$diff" .config @@ -116,7 +117,7 @@ strip_config() { test_diff() { dt=$(mktemp) - strip_config "$(get_running_config)" > "$dt" + strip_config "$RUNNING_CONFIG" > "$dt" if ! strip_config .config | diff -q "$dt" -; then diff_kernel || true @@ -105,8 +105,11 @@ to display the differences between the generated kernel configuration and .Pp If no config is given, this command compares against the configuration of the currently running kernel. -This requires the configuration file to be present under -.Pa /boot . +This requires a kernel configuration to be present under +.Pa /proc/config.gz . +See the +.Sy CONFIG_IKCONFIG +configuration option in the kernel for more information. .It Sy build Builds the selected kernel. .It Sy install |