From e4af22f8e6be3419bcf4b309c7e4f80a9bfe8209 Mon Sep 17 00:00:00 2001 From: Mart Frauenlob Date: Mon, 23 Oct 2023 15:43:37 +0200 Subject: [PATCH] Add 'broken' status If either a dkms module source, or the symbolic link pointing to it is missing, the output of `dkms status` will be messed up. Add a new status called 'broken', which will inform the user about it in a nicely formatted way. is_module_added() was modified to not report a module as added, if not both the source directory and the 'source' symlink exist. do_autoinstall() and run_match() were modified to handle a broken status. They skip that particular module/version combo and continue iterating. The new function module_is_broken_and_die() was introduced to die early on a broken module. Because if in a broken state everything has to be considered volatile, we always die. User intvervention is required to restore a healthy environment. The man page was updated with the new 'broken' status. Signed-off-by: Mart Frauenlob --- .dkms.in.swp | Bin 0 -> 16384 bytes dkms.8.in | 5 +++++ dkms.in | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .dkms.in.swp diff --git a/.dkms.in.swp b/.dkms.in.swp new file mode 100644 index 0000000000000000000000000000000000000000..15fd49c575dd3f1ab5c533178490edefb3504641 GIT binary patch literal 16384 zcmeHNYm6jS6)r^NA-KFk&?V$C zJ(_yVY_q%i2O^2lAjY5iLov~x28sMLk&vK?A!=Af2|;5-e4(%^g0JsX-RjrQEQ^0M zrYiZStLof)?!Di=_uO+%O=Id%ahcsUIVIt`R+9Lb%U?Wwh4iTtmq;58`=p|ox<#@J zTurXoj&gwlLiCBA!tA>4Wwo~H%D8Fyji&9igXhV2Z0wzziA%%`#0+f7z%|nB%yh8T z#}d2P4cD)3St@=RGY~TnGY~TnGY~TnGY~TnGY~WI|H**Y*(rSzLwk=H-f{7J$;j`& z#Py(fFOSIoDdb$de_=%a4*MME(~ck9c{{dxz`)S;$+WzA_>|C*+Gl z{@oGz8$$k3A>VP?u>RMDJmUA`Bl159c@**eXhi-;A&>Y?y>D3mYa{Z9M&y4G@?)ZZ zFOSH7FXZb&K7aYJ{@)3CQ^+45k^ff6BYv;CVz~ZqgglymeMJ7MkSj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C@FWF) zFQ8-~*CP$w57kJX3RlLN!C9wS5UXe&;Y5&C5)(AgO(fUF)27@@0tKuM)W_U{IZ=5# z%4k@9*?CNdtx&cK^UzQ%3vocyKZMSed}S|d>L;_@qHG+N9E!s4)!6AE7ec>c5btv6 zKGJ;edhiz*NMCeOOGbwMiNy79bk{tzMv4I>peI-iZLqxO%hXnI57=zm_++LJ+=qSjbB8<`d^Wm`yh!34=3Oyr0)bo)|e41lv@Z z%4b702p&VaVb{V;3n3x zW|%kv?fCX*@sN5fqTY$T)k2t{r4g(Thtte5T**^oG;K%jId+Ea$Kjh!i%*|erN Rdz=MjU~C7gfX1WJzX8uIW2688 literal 0 HcmV?d00001 diff --git a/dkms.8.in b/dkms.8.in index a954d4f3..246ddfb4 100644 --- a/dkms.8.in +++ b/dkms.8.in @@ -231,6 +231,11 @@ Returns the current status of modules, versions and kernels within the tree as well as whether they have been added, built or installed. Status can be shown for just a certain module, a certain kernel, a module/version combination or a module/version/kernel combination. + +If the source directory, or the symbolic link 'source' pointing to it is missing, +the status of the module/version combination will be displayed as 'broken'. +In that case dkms will not perform any other action on that particular module/version combination. +Manual intervention is required. .SY autoinstall .YS .IP "" 4 diff --git a/dkms.in b/dkms.in index 942da18c..5f8346bc 100644 --- a/dkms.in +++ b/dkms.in @@ -1397,10 +1397,25 @@ list_each_installed_module() done } +# Check if either the module source, or the symlink pointing to it is missing +is_module_broken() { + [[ $1 && $2 ]] || return 1 + [[ -d $dkms_tree/$1/$2 ]] || return 2 + if [[ -L $dkms_tree/$1/$2/source && ! -d $dkms_tree/$1/$2/source ]]; then + [[ $verbose ]] && error "The source directory for $1/$2is missing." + return + elif [[ ! -L $dkms_tree/$1/$2/source && -d $dkms_tree/$1/$2/source ]]; then + [[ $verbose ]] && error "The symbolic link 'source' to the source directory of $1/$2 is missing." + return + fi + return 1 + +} + is_module_added() { [[ $1 && $2 ]] || return 1 [[ -d $dkms_tree/$1/$2 ]] || return 2 - [[ -L $dkms_tree/$1/$2/source || -d $dkms_tree/$1/$2/source ]]; + [[ -L $dkms_tree/$1/$2/source && -d $dkms_tree/$1/$2/source ]] || return 2 } is_module_built() { @@ -1600,6 +1615,26 @@ do_uninstall() [[ $(find $dkms_tree/$module/original_module/* -maxdepth 0 -type d 2>/dev/null) ]] || rm -rf "$dkms_tree/$module/original_module" } +module_is_broken_and_die() { + local rip=0 + local -a msg=() + local p="$dkms_tree/$module/$module_version" + + # Die here if the base directory of module/version does not exist. + # Because the module must already be added. Unlike in is_module_broken(). + [[ -d $p ]] || die 3 \ + $"The module/version combo: $module-$module_version is not located in the DKMS tree." + + if [[ -L $p/source && ! -d $p/source ]]; then rip=1 + msg+=("The source directory for $module/$module_version is missing.") + fi + if [[ ! -L $p/source && -d $p/source ]]; then rip=1 + msg+=("The symbolic link 'source' to the source directory for $module/$module_version is missing.") + fi + ((rip)) && die 4 "${msg[@]}" "Manual intervention is required!" + return 0 +} + module_is_added_or_die() { is_module_added "$module" "$module_version" || die 3 \ @@ -1801,6 +1836,7 @@ module_status() { mv="${directory#$dkms_tree/}" m="${mv%/*}" v="${mv#*/}" + is_module_broken "$m" "$v" && { echo "broken $m/$v"; continue; } is_module_added "$m" "$v" || continue ret=0 module_status_built "$m" "$v" "$3" "$4" || echo "added $m/$v" @@ -1821,6 +1857,10 @@ do_status() { while read status mvka; do IFS=/ read m v k a <<< "$mvka" case $status in + broken) + echo "$m/$v: $status" + error "$m/$v: Missing module source directory, or the symbolic link pointing to it." + ;; added) echo "$m/$v: $status" ;; @@ -2097,6 +2137,11 @@ run_match() echo $"Module: $template_module" echo $"Version: $template_version" + # Continue if the status is broken, as there is nothing we can do + if is_module_broken "$template_module" "$template_version"; then + error $"$template_module/$template_version: Missing module source directory, or the symbolic link pointing to it." + continue + fi maybe_build_module "$template_module" "$template_version" "$kernelver" "$arch" maybe_install_module "$template_module" "$template_version" "$kernelver" "$arch" done < <(echo "$template_kernel_status") @@ -2225,6 +2270,11 @@ autoinstall() { # a list of modules and their latest version. while read status mvka; do IFS='/' read m v k a <<< "$mvka" + # If the module status is broken there is nothing that can be done + if [[ $status = broken ]]; then + error "Module $m/$v is broken. Missing source directory, or the symbolic link pointing to it." + continue + fi if [[ -z "${latest["$m"]}" ]]; then known_modules[${#known_modules[@]}]="$m" latest["$m"]="$v" @@ -2579,12 +2629,14 @@ setup_kernels_arches "$action" case "$action" in remove | unbuild | uninstall) check_module_args $action + module_is_broken_and_die module_is_added_or_die [[ $action = uninstall ]] && check_root || check_rw_dkms_tree ${action}_module ;; add | build | install) check_all_is_banned $action # TODO: fix/enable --all + [[ $action != add ]] && module_is_broken_and_die && module_is_added_or_die [[ $action = install ]] && check_root || check_rw_dkms_tree ${action}_module ;; @@ -2596,6 +2648,7 @@ match) ;; mktarball) check_module_args mktarball + module_is_broken_and_die module_is_added_or_die make_tarball ;;