diff options
author | Wynn Wolf Arbor | 2020-06-04 14:50:18 +0200 |
---|---|---|
committer | Wynn Wolf Arbor | 2020-06-04 15:59:33 +0200 |
commit | 344f0f271daac9ad77c5b1da2ed59c3a3e394e13 (patch) | |
tree | a669447aeaa08b29f4420c35f9729a37c995ddeb | |
parent | 1c5a81df33ddbc0fda4bfb64ae9def531c213743 (diff) | |
download | kern-344f0f271daac9ad77c5b1da2ed59c3a3e394e13.tar.gz |
Use configuration file under /boot instead of /proc/config.gz
kern(1) has been using /proc/config.gz as the source of the currently
running kernel's config since its initial commit. Whilst this location
is convenient because of its static nature, it does need a specific
kernel option, IKCONFIG_PROC, to be set.
Furthermore, it introduces a dependency on gzip(1) to decompress the
file on the fly. Consequently, we need to stream gzip's output to
commands or save it in a temporary file to access it neatly.
Since Gentoo's default install script for the kernel, installkernel(8),
places each kernel's configuration file in /boot, we can use this
location to retrieve the currently running kernel's configuration
instead and work around all of the above limitations.
Of course we need to make sure that /boot is mounted before we try
accessing any configuration files on there. We use the already existing
code from install_kernel() for that.
Diffstat (limited to '')
-rw-r--r-- | TODO | 2 | ||||
-rwxr-xr-x | kern | 25 | ||||
-rw-r--r-- | kern.1 | 7 |
3 files changed, 23 insertions, 11 deletions
@@ -1,2 +0,0 @@ -- Consider falling back to /boot/config-<kernel> if /proc/config.gz - does not exist @@ -21,6 +21,12 @@ is_boot_mounted() { mountpoint -q /boot } +mount_boot_on_demand() { + if has_boot_mount && ! is_boot_mounted; then + sudo mount /boot + fi +} + get_latest_kernel() { eselect --brief kernel list | tail -n1 } @@ -29,6 +35,17 @@ get_selected_kernel() { readlink /usr/src/linux } +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) @@ -59,7 +76,7 @@ config_kernel() { } diff_kernel() { - diff=${1:-/proc/config.gz} + diff=${1:-$(get_running_config)} nvim -d .config "$diff" } @@ -68,9 +85,7 @@ build_kernel() { } install_kernel() { - if has_boot_mount && ! is_boot_mounted; then - sudo mount /boot - fi + mount_boot_on_demand sudo make install modules_install } @@ -84,7 +99,7 @@ clean_kernel() { test_diff() { dt=$(mktemp) - zcat /proc/config.gz | sed -nE '/^(# )?CONFIG_.*/p' > "$dt" + sed -nE '/^(# )?CONFIG_.*/p' "$(get_running_config)" > "$dt" if ! sed -nE '/^(# )?CONFIG_.*/p' .config | diff -q "$dt" -; then diff_kernel printf "Continue? [y/N] " @@ -1,4 +1,4 @@ -.Dd May 16, 2020 +.Dd June 4, 2020 .Dt KERN 1 .Os .Sh NAME @@ -103,9 +103,8 @@ 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 -.Sy IKCONFIG_PROC -to be enabled. +This requires the configuration file to be present under +.Pa /boot . .It Sy build Builds the selected kernel. .It Sy install |