lesavka: clarify kernel module preflight

This commit is contained in:
Brad Stein 2026-04-20 14:25:34 -03:00
parent 11aa2b5ec4
commit 48503c7c22
5 changed files with 36 additions and 11 deletions

View File

@ -4,7 +4,7 @@ path = "src/main.rs"
[package]
name = "lesavka_client"
version = "0.11.27"
version = "0.11.28"
edition = "2024"
[dependencies]

View File

@ -1,6 +1,6 @@
[package]
name = "lesavka_common"
version = "0.11.27"
version = "0.11.28"
edition = "2024"
build = "build.rs"

View File

@ -17,6 +17,6 @@ mod tests {
#[test]
fn banner_includes_version() {
assert_eq!(banner("0.11.27"), "lesavka-common CLI (v0.11.27)");
assert_eq!(banner("0.11.28"), "lesavka-common CLI (v0.11.28)");
}
}

View File

@ -16,6 +16,23 @@ log() {
printf '==> %s\n' "$*"
}
installed_kernel_module_trees() {
local roots=(/usr/lib/modules /lib/modules)
local seen=()
local root entry
for root in "${roots[@]}"; do
[[ -d $root ]] || continue
for entry in "$root"/*; do
[[ -d $entry ]] || continue
seen+=("$(basename "$entry")")
done
done
if [[ ${#seen[@]} -eq 0 ]]; then
return 0
fi
printf '%s\n' "${seen[@]}" | awk '!seen[$0]++'
}
require_command() {
local cmd=$1
local pkg_hint=$2
@ -51,10 +68,23 @@ require_kernel_module() {
if modinfo "$module" >/dev/null 2>&1; then
return 0
fi
local running_kernel
running_kernel=$(uname -r)
mapfile -t module_trees < <(installed_kernel_module_trees)
echo "❌ required kernel module '$module' is unavailable for the running kernel $(uname -r)." >&2
echo " Lesavka needs it for $why." >&2
echo " This usually means the machine booted an older kernel than the modules that are currently installed." >&2
echo " Reboot into the freshly installed kernel, then rerun the installer." >&2
if [[ ${#module_trees[@]} -eq 0 ]]; then
echo " No kernel module trees are currently installed under /usr/lib/modules or /lib/modules." >&2
else
echo " Installed kernel module trees: ${module_trees[*]}" >&2
if [[ ! " ${module_trees[*]} " =~ [[:space:]]${running_kernel}[[:space:]] ]]; then
echo " The machine is booted into an older kernel than the modules that are currently installed." >&2
echo " Reboot into one of the installed kernels above, then rerun the installer." >&2
else
echo " The current kernel tree exists, but modinfo still cannot resolve '$module'." >&2
echo " Verify the kernel package and headers are healthy, then rerun the installer." >&2
fi
fi
exit 1
}
@ -121,11 +151,6 @@ require_linkable "$(command -v protoc)" "protoc"
if [[ -e /usr/lib/libclang.so ]]; then
require_linkable /usr/lib/libclang.so "libclang"
fi
if [[ ! -d /lib/modules/$(uname -r) ]]; then
echo "❌ no kernel module tree exists for the running kernel $(uname -r)." >&2
echo " Reboot into the freshly installed kernel, then rerun the installer." >&2
exit 1
fi
require_kernel_module snd_usb_audio "USB microphones and USB headsets"
require_gst_element pulsesrc
require_gst_element pulsesink

View File

@ -10,7 +10,7 @@ bench = false
[package]
name = "lesavka_server"
version = "0.11.27"
version = "0.11.28"
edition = "2024"
autobins = false