From 0f499c987b13439e9f6e30895c3876ff512e8eb0 Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Fri, 17 Mar 2023 11:00:33 +0100 Subject: [PATCH] autoinstall: do not fail on modules skipped due to BUILD_EXCLUSIVE_* Closes #302 --- dkms.8.in | 2 ++ dkms.in | 13 +++++++++++-- run_test.sh | 8 +++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/dkms.8.in b/dkms.8.in index b197878c..bc0620ba 100644 --- a/dkms.8.in +++ b/dkms.8.in @@ -659,6 +659,8 @@ If the kernel being built for does not match against this regular expression (or does not the satisfy the constraints of any other .B BUILD_EXCLUSIVE_* directive), the dkms build will error out with exit code 77. +Note that dkms autoinstall will ignore this type of error condition and simply +skip the respective modules. For example, if you set it as ="^2\.4.*", your module would not be built for 2.6 or later kernels. .TP diff --git a/dkms.in b/dkms.in index 8378592c..1eb06919 100644 --- a/dkms.in +++ b/dkms.in @@ -2199,6 +2199,7 @@ autoinstall() { local -a next_install=() local -a known_modules=() local -a installed_modules=() + local -a skipped_modules=() local -a failed_modules=() local -A build_depends=() local -A latest=() @@ -2260,11 +2261,15 @@ autoinstall() { for mv in "${to_install[@]}"; do IFS=/ read m v <<< "$mv" if [[ -z "${build_depends[$m]}" ]]; then - if (module="$m" module_version="$v" kernelver="$kernelver" arch="$arch" install_module); then + (module="$m" module_version="$v" kernelver="$kernelver" arch="$arch" install_module) + status=$? + if [ "$status" = 0 ]; then installed_modules[${#installed_modules[@]}]="$m" install_count=$(($install_count +1)) + elif [ "$status" = 77 ]; then + skipped_modules[${#skipped_modules[@]}]="$m" else - failed_modules[${#failed_modules[@]}]="$m($?)" + failed_modules[${#failed_modules[@]}]="$m($status)" fi else next_install[${#next_install[@]}]="$mv" @@ -2287,6 +2292,10 @@ autoinstall() { echo "dkms autoinstall on $kernelver/$arch succeeded for ${installed_modules[@]}" fi + if [[ "${#skipped_modules[@]}" > 0 ]]; then + echo "dkms autoinstall on $kernelver/$arch was skipped for ${skipped_modules[@]}" + fi + if [[ "${#failed_modules[@]}" > 0 ]]; then echo "dkms autoinstall on $kernelver/$arch failed for ${failed_modules[@]}" fi diff --git a/run_test.sh b/run_test.sh index fd4206b0..758e70ae 100755 --- a/run_test.sh +++ b/run_test.sh @@ -1399,13 +1399,11 @@ run_status_with_expected_output 'dkms_build_exclusive_test' << EOF dkms_build_exclusive_test/1.0: added EOF -echo "Running dkms autoinstall (1 x skip) (THIS SHOULD NOT FAIL!)" -run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}" << EOF -dkms autoinstall on ${KERNEL_VER}/${KERNEL_ARCH} failed for dkms_build_exclusive_test(77) +echo "Running dkms autoinstall (1 x skip)" +run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF +dkms autoinstall on ${KERNEL_VER}/${KERNEL_ARCH} was skipped for dkms_build_exclusive_test Error! The /var/lib/dkms/dkms_build_exclusive_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/dkms.conf for module dkms_build_exclusive_test includes a BUILD_EXCLUSIVE directive which does not match this kernel/arch. This indicates that it should not be built. -Error! One or more modules failed to install during autoinstall. -Refer to previous errors for more information. EOF run_status_with_expected_output 'dkms_build_exclusive_test' << EOF dkms_build_exclusive_test/1.0: added