Skip to content

Commit

Permalink
autoinstall: die after attempting installs when a module fails to ins…
Browse files Browse the repository at this point in the history
…tall.

If a module fails to autoinstall due to errors during install or missing
dependencies, dkms currently still returns an exit code of 0. This change
ensures that a failing install or missing dependency returns a non-zero
exit code and reports an error instead.

Signed-off-by: Charlie Johnston <charlie.johnston@ni.com>
  • Loading branch information
Charlie Johnston authored and evelikov committed Nov 4, 2022
1 parent 630d42c commit 07a6cf8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dkms.in
Expand Up @@ -2118,6 +2118,7 @@ autoinstall() {
local -a to_install=()
local -a next_install=()
local -a installed_modules=()
local -a failed_modules=()
local -A build_depends=()

# Walk through our list of installed and built modules, and create
Expand Down Expand Up @@ -2189,6 +2190,8 @@ autoinstall() {
if (module="$m" module_version="$v" kernelver="$kernelver" arch="$arch" install_module); then
installed_modules[${#installed_modules[@]}]="$m"
install_count=$(($install_count +1))
else
failed_modules=[${#failed_modules[@]}]="$m"
fi
else
next_install[${#next_install[@]}]="$mv"
Expand All @@ -2210,6 +2213,11 @@ autoinstall() {
IFS=/ read m v <<< "$mv"
echo "$m/$v autoinstall failed due to missing dependencies: ${build_depends[$m]}"
done

if [[ "${#failed_modules[@]}" > 0 || "${#to_install[@]}" > 0 ]]; then
die 11 $"One or more modules failed to install during autoinstall." \
$"Refer to previous errors for more information."
fi
}

#############################
Expand Down

0 comments on commit 07a6cf8

Please sign in to comment.