From 7f243d1e734a27279c0434fc0cb32a8039d85c51 Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Mon, 15 May 2023 14:12:44 +0200 Subject: [PATCH 1/6] restore non-clang CC detection from .config --- dkms.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dkms.in b/dkms.in index 7846662a..3c764f8d 100644 --- a/dkms.in +++ b/dkms.in @@ -1062,6 +1062,12 @@ prepare_build() done if [[ -e "${kernel_config}" ]]; then + local cc=$(sed -n 's|^CONFIG_CC_VERSION_TEXT="\([^ ]*\) .*"|\1|p' "${kernel_config}") + if command -v "$cc" >/dev/null; then + export CC="$cc" + export KERNEL_CC="$cc" + fi + if grep -q 'CONFIG_CC_IS_CLANG=y' "${kernel_config}"; then local cc=clang if command -v "$cc" >/dev/null; then From c53ba2c18f26f53fa5b660d7ed33134102c759e7 Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Mon, 15 May 2023 14:17:11 +0200 Subject: [PATCH 2/6] move .kernelvariables parsing to prepare_build() where the .config based compiler detection happens, ensures that the compiler is set for PRE_BUILD --- dkms.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dkms.in b/dkms.in index 3c764f8d..ebd9ca95 100644 --- a/dkms.in +++ b/dkms.in @@ -1061,6 +1061,12 @@ prepare_build() $"Check $build_dir for more information." done + if [ -f "$kernel_source_dir/.kernelvariables" ]; then + export CC=$(echo -e "show-%:\n\t@echo \$(\$*)\ninclude $kernel_source_dir/.kernelvariables" | make -f - show-CC) + else + unset CC + fi + if [[ -e "${kernel_config}" ]]; then local cc=$(sed -n 's|^CONFIG_CC_VERSION_TEXT="\([^ ]*\) .*"|\1|p' "${kernel_config}") if command -v "$cc" >/dev/null; then @@ -1100,12 +1106,6 @@ actual_build() echo $"" echo $"Building module:" - if [ -f "$kernel_source_dir/.kernelvariables" ]; then - export CC=$(echo -e "show-%:\n\t@echo \$(\$*)\ninclude $kernel_source_dir/.kernelvariables" | make -f - show-CC) - else - unset CC - fi - invoke_command "$clean" "Cleaning build area" background echo $"DKMS make.log for $module-$module_version for kernel $kernelver ($arch)" >> "$build_log" date >> "$build_log" From 3372796070d2b790640ba3c0fbea9228c07346d4 Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Sun, 11 Jun 2023 18:20:25 +0200 Subject: [PATCH 3/6] CI: add Debian 12 (bookworm) to the test matrix --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b10f85c6..bc3a906a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,6 +25,7 @@ jobs: - {name: "centos", tag: "7"} - {name: "almalinux", tag: "9"} - {name: "almalinux", tag: "8"} + - {name: "debian", tag: "12"} - {name: "debian", tag: "11"} - {name: "debian", tag: "10"} - {name: "ubuntu", tag: "22.04"} From 3707494e045b5d76fca0c93c6c7e6424396914e7 Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Sun, 11 Jun 2023 18:24:30 +0200 Subject: [PATCH 4/6] CI: Debian: rely on the compiler dependency of the header package Debian (but not Ubuntu) builds its kernels with a versioned compiler binary (gcc-XX) and the linux-headers-* packages depend on that compiler --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bc3a906a..d5f590f2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -62,7 +62,7 @@ jobs: if: matrix.distro.name == 'debian' run: | apt-get update -q - apt-get install -qy gcc make linux-headers-amd64 linux-image-amd64 openssl + apt-get install -qy make linux-headers-amd64 linux-image-amd64 openssl - name: Install Ubuntu dependencies if: matrix.distro.name == 'ubuntu' From f5759f40a3cd586c78c2ca98a605f80d77e58085 Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Mon, 12 Jun 2023 13:56:05 +0200 Subject: [PATCH 5/6] dkms: error out if $arch cannot be determined if for some reason $arch cannot be determined (e.g. due to a broken rpm shim on distributions using a different package manager), dkms will happily build a module, placing state info in /var/lib/dkms/$module/$version/$kernel//, but that subsequently causes errors because the module is not considered to be installed and at the same time cannot be removed any more Before: sid# dkms status sid# ln -s /bin/true /usr/bin/rpm sid# dkms add dkms_test/1.0 Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0 sid# dkms status dkms_test/1.0: added sid# dkms build -k 6.1.0-9-amd64 dkms_test/1.0 Sign command: /usr/lib/linux-kbuild-6.1/scripts/sign-file Signing key: /var/lib/dkms/mok.key Public certificate (MOK): /var/lib/dkms/mok.pub Building module: Cleaning build area... make -j16 KERNELRELEASE=6.1.0-9-amd64 -C /lib/modules/6.1.0-9-amd64/build M=/var/lib/dkms/dkms_test/1.0/build... Signing module /var/lib/dkms/dkms_test/1.0/build/dkms_test.ko Cleaning build area... sid# dkms status dkms_test/1.0: added sid# dkms build -k 6.1.0-9-amd64 dkms_test/1.0 Sign command: /usr/lib/linux-kbuild-6.1/scripts/sign-file Signing key: /var/lib/dkms/mok.key Public certificate (MOK): /var/lib/dkms/mok.pub Error! This module/version has already been built on: 6.1.0-9-amd64 Directory /var/lib/dkms/dkms_test/1.0/6.1.0-9-amd64/ already exists. Use the dkms remove function before trying to build again. sid# dkms status dkms_test/1.0: added sid# dkms remove -k 6.1.0-9-amd64 dkms_test/1.0 Module dkms_test 1.0 is not installed for kernel 6.1.0-9-amd64 (). Skipping... Module dkms_test 1.0 is not built for kernel 6.1.0-9-amd64 (). Skipping... sid# dkms status dkms_test/1.0: added sid# dkms remove dkms_test/1.0 --all sid# dkms status dkms_test/1.0: added sid# find /var/lib/dkms/dkms_test/1.0/ /var/lib/dkms/dkms_test/1.0/ /var/lib/dkms/dkms_test/1.0/6.1.0-9-amd64 /var/lib/dkms/dkms_test/1.0/6.1.0-9-amd64/module /var/lib/dkms/dkms_test/1.0/6.1.0-9-amd64/module/dkms_test.ko /var/lib/dkms/dkms_test/1.0/6.1.0-9-amd64/log /var/lib/dkms/dkms_test/1.0/6.1.0-9-amd64/log/make.log /var/lib/dkms/dkms_test/1.0/6.1.0-9-amd64/log/.config /var/lib/dkms/dkms_test/1.0/source After: sid# dkms status sid# ln -s /bin/true /usr/bin/rpm sid# dkms add dkms_test/1.0 Error! Could not determine architecture. sid# echo $? 12 to manually recover from the bug use rm -rf /var/lib/dkms/$module/$version and add/build/install the module(s) again --- dkms.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dkms.in b/dkms.in index ebd9ca95..ef94ad19 100644 --- a/dkms.in +++ b/dkms.in @@ -287,6 +287,9 @@ setup_kernels_arches() fi fi fi + if [[ ! $arch ]]; then + die 12 $"Could not determine architecture." + fi fi # If only one arch is specified, make it so for all the kernels From bb56e9c38b9d2269859c75cb51813163e6e9d988 Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Fri, 16 Jun 2023 12:15:46 +0200 Subject: [PATCH 6/6] fix hardcoded architecture in test output --- run_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_test.sh b/run_test.sh index 2f47b069..aed425c4 100755 --- a/run_test.sh +++ b/run_test.sh @@ -678,7 +678,7 @@ echo "Running dkms autoinstall for a kernel without headers installed (expected run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}-noheaders" << EOF Error! Your kernel headers for kernel ${KERNEL_VER}-noheaders cannot be found at /lib/modules/${KERNEL_VER}-noheaders/build or /lib/modules/${KERNEL_VER}-noheaders/source. Please install the linux-headers-${KERNEL_VER}-noheaders package or use the --kernelsourcedir option to tell DKMS where it's located. -dkms autoinstall on ${KERNEL_VER}-noheaders/x86_64 failed for dkms_test(1) +dkms autoinstall on ${KERNEL_VER}-noheaders/${KERNEL_ARCH} failed for dkms_test(1) Error! One or more modules failed to install during autoinstall. Refer to previous errors for more information. EOF