diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..065f673
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,13 @@
+# To use this config with your editor, follow the instructions at:
+# http://editorconfig.org
+
+root = true
+
+[*]
+charset = utf-8
+insert_final_newline = true
+indent_style = space
+indent_size = 4
+
+[Makefile]
+indent_style = tab
diff --git a/.gitignore b/.gitignore
index abf02c5..29155b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,17 @@
-dist/*
-*.o
+/dist
dkms
dkms.8
+dkms.bash-completion
+dkms.zsh-completion
+dkms_framework.conf
+dkms_autoinstaller
+dkms.service
+dkms_common.postinst
+debian_kernel_install.d
+debian_kernel_postinst.d
+debian_kernel_preinst.d
+debian_kernel_prerm.d
+redhat_kernel_install.d
+
+test_cmd_expected_output.log
+test_cmd_output.log
diff --git a/COPYING b/COPYING
index d159169..9efa6fb 100644
--- a/COPYING
+++ b/COPYING
@@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -304,8 +304,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ with this program; if not, see .
Also add information on how to contact you by electronic and paper mail.
@@ -329,8 +328,8 @@ necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
- , 1 April 1989
- Ty Coon, President of Vice
+ , 1 April 1989
+ Moe Ghoul, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
diff --git a/Makefile b/Makefile
index 0fca9a3..fe726f9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
-RELEASE_DATE := "1 October 2024"
+RELEASE_DATE := "12 Sep 2025"
RELEASE_MAJOR := 3
-RELEASE_MINOR := 1
-RELEASE_MICRO := 0
+RELEASE_MINOR := 2
+RELEASE_MICRO := 2
RELEASE_NAME := dkms
RELEASE_VERSION := $(RELEASE_MAJOR).$(RELEASE_MINOR).$(RELEASE_MICRO)
RELEASE_STRING := $(RELEASE_NAME)-$(RELEASE_VERSION)
@@ -29,7 +29,7 @@ SED_SUBSTITUTIONS = \
%: %.in
$(SED) $(SED_SUBSTITUTIONS) $< > $@
-all: \
+GENERATED= \
dkms \
dkms.8 \
dkms_autoinstaller \
@@ -38,23 +38,17 @@ all: \
dkms_common.postinst \
dkms_framework.conf \
dkms.service \
- kernel_install.d_dkms \
- kernel_postinst.d_dkms \
- kernel_prerm.d_dkms
+ debian_kernel_install.d \
+ debian_kernel_postinst.d \
+ debian_kernel_preinst.d \
+ debian_kernel_prerm.d \
+ redhat_kernel_install.d
+
+all: $(GENERATED)
clean:
-rm -rf dist/
- -rm -rf dkms
- -rm -rf dkms.8
- -rm -rf dkms_autoinstaller
- -rm -rf dkms.bash-completion
- -rm -rf dkms.zsh-completion
- -rm -rf dkms_common.postinst
- -rm -rf dkms_framework.conf
- -rm -rf dkms.service
- -rm -rf kernel_install.d_dkms
- -rm -rf kernel_postinst.d_dkms
- -rm -rf kernel_prerm.d_dkms
+ $(RM) $(GENERATED)
install: all
$(if $(strip $(VAR)),$(error Setting VAR is not supported))
@@ -65,8 +59,6 @@ ifneq (,$(DESTDIR))
$(if $(filter $(DESTDIR)%,$(KCONF)),$(error Using a DESTDIR as prefix for KCONF is no longer supported))
endif
install -D -m 0755 dkms $(DESTDIR)$(SBIN)/dkms
- install -D -m 0755 dkms_common.postinst $(DESTDIR)$(LIBDIR)/common.postinst
- install -D -m 0755 dkms_autoinstaller $(DESTDIR)$(LIBDIR)/dkms_autoinstaller
$(if $(strip $(ETC)),$(error Setting ETC is not supported))
install -D -m 0644 dkms_framework.conf $(DESTDIR)/etc/dkms/framework.conf
install -d -m 0755 $(DESTDIR)/etc/dkms/framework.conf.d
@@ -74,20 +66,25 @@ endif
install -D -m 0644 dkms.bash-completion $(DESTDIR)/usr/share/bash-completion/completions/dkms
install -D -m 0644 dkms.zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_dkms
install -D -m 0644 dkms.8 $(DESTDIR)/usr/share/man/man8/dkms.8
- install -D -m 0755 kernel_install.d_dkms $(DESTDIR)$(KINSTALL)/40-dkms.install
- install -D -m 0755 kernel_postinst.d_dkms $(DESTDIR)$(KCONF)/postinst.d/dkms
- install -D -m 0755 kernel_prerm.d_dkms $(DESTDIR)$(KCONF)/prerm.d/dkms
install-redhat: install
ifneq (,$(DESTDIR))
$(if $(filter $(DESTDIR)%,$(SYSTEMD)),$(error Using a DESTDIR as prefix for SYSTEMD is no longer supported))
endif
install -D -m 0644 dkms.service $(DESTDIR)$(SYSTEMD)/dkms.service
+ install -D -m 0755 redhat_kernel_install.d $(DESTDIR)$(KINSTALL)/40-dkms.install
+ install -D -m 0755 dkms_common.postinst $(DESTDIR)$(LIBDIR)/common.postinst
install-debian: install
$(if $(strip $(SHAREDIR)),$(error Setting SHAREDIR is not supported))
+ install -D -m 0755 dkms_autoinstaller $(DESTDIR)$(LIBDIR)/dkms_autoinstaller
install -D -m 0755 dkms_apport.py $(DESTDIR)/usr/share/apport/package-hooks/dkms_packages.py
- install -D -m 0755 kernel_postinst.d_dkms $(DESTDIR)$(KCONF)/header_postinst.d/dkms
+ install -D -m 0755 dkms_common.postinst $(DESTDIR)$(LIBDIR)/common.postinst
+ install -D -m 0755 debian_kernel_install.d $(DESTDIR)$(KINSTALL)/40-dkms.install
+ install -D -m 0755 debian_kernel_postinst.d $(DESTDIR)$(KCONF)/postinst.d/dkms
+ install -D -m 0755 debian_kernel_postinst.d $(DESTDIR)$(KCONF)/header_postinst.d/dkms
+ install -D -m 0755 debian_kernel_preinst.d $(DESTDIR)$(KCONF)/preinst.d/dkms
+ install -D -m 0755 debian_kernel_prerm.d $(DESTDIR)$(KCONF)/prerm.d/dkms
install-doc:
$(if $(strip $(DOC)),$(error Setting DOCDIR is not supported))
diff --git a/README.md b/README.md
index 763bd2d..0764ad2 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,13 @@
-Dynamic Kernel Module System (DKMS)
-==
-This intention of this README is to explain how DKMS can be used in conjunction
-with tarballs which contain a dkms.conf file within them.
+# Dynamic Kernel Module System (DKMS)
+
+This intention of this README is to explain how DKMS can be used in conjunction with tarballs which contain a dkms.conf file within them.
The DKMS project (and any updates) can be found at: https://github.com/dell/dkms
-Installation
---
-Installation is performed from the source directory with one of the following
-commands:
+## Installation
+
+Installation is performed from the source directory with one of the following commands:
```
make install
@@ -17,118 +15,110 @@ make install-debian
make install-redhat
```
-Distribution specific installations (RPM, DEB, etc.) are not contained in this
-source repository.
+Distribution specific installations (RPM, DEB, etc.) are not contained in this source repository.
-Installation via DKMS Tarballs
---
+## Installation of DKMS Tarballs
DKMS can install directly from the following:
1. Generic module source tarballs which contain a dkms.conf file
-2. Specially created DKMS tarballs with module source, pre-built module
- binaries and a dkms.conf file
-3. Specially created DKMS tarballs with pre-built module binaries and a
- dkms.conf file
-4. Manual placement of module source and dkms.conf file into
- `/usr/src/-/` directory
+2. Specially created DKMS tarballs with module source, pre-built module binaries and a `dkms.conf` file
+3. Specially created DKMS tarballs with pre-built module binaries and a `dkms.conf` file
+4. Manual placement of module source and `dkms.conf` file into `/usr/src/-/` directory
-In order to load any tarball into the DKMS tree, you must use the following
-command:
+In order to load any tarball into the DKMS tree, you must use the following command:
```
# dkms ldtarball /path/to/dkms_enabled.tar.gz
```
-This command will first inspect the tarball to ensure that it contains a
-dkms.conf configuration file for that module. If it cannot find this file
-anywhere within the archive, then the ldtarball will fail.
-
-From here, it will place the source in the tarball into
-`/usr/src/-/`. If source already exists in the directory,
-it will not overwrite it unless the --force option is specified. If the tarball
-is of type "c" above and does not contain source, it will only continue to load
-the tarball if existing module source is found in
-`/usr/src/-/` or if the --force option is specified.
+This command will first inspect the tarball to ensure that it contains a `dkms.conf` configuration file for that module.
+If it cannot find this file anywhere within the archive, then the `ldtarball` command will fail.
-Continuing on, if the tarball is of type "b" or "c" it will then load any
-pre-built binaries found within the tarball into the dkms tree, but will stop
-short of installing them. Thus, all pre-built binaries will then be of in the
-*built* state when checked from the `dkms status` command. You can then use the
-`dkms install` command to install any of these binaries.
+From here, it will place the source in the tarball into `/usr/src/-/`.
+If source already exists in the directory, it will not overwrite it unless the `--force` option is specified.
+If the tarball is of type "c" above and does not contain source, it will only continue to load the tarball if existing module source is found in `/usr/src/-/` or if the `--force` option is specified.
-To create a tarball of type "1" above, you need only to take module source and a
-dkms.conf file for that module and create a tarball from them. Tarballs of
-type *2* or type *3* are created with the `dkms mktarball` command. To create
-a type *3* tarball, you must specify the flag `--binaries-only` with the
-`mktarball`.
+Continuing on, if the tarball is of type "b" or "c" it will then load any pre-built binaries found within the tarball into the DKMS tree, but will stop short of installing them.
+Thus, all pre-built binaries will then be of in the *built* state when checked from the `dkms status` command. You can then use the `dkms install` command to install any of these binaries.
+To create a tarball of type "1" above, you need only to take module source and a `dkms.conf` file for that module and create a tarball from them.
+Tarballs of type *2* or type *3* are created with the `dkms mktarball` command.
+To create a type *3* tarball, you must specify the flag `--binaries-only` along with the `mktarball` command.
+### Installation on Systems with no Module Source and/or Compiler
-Installation on Systems with no Module Source and/or Compiler
---
+If you choose not to load module source on your system or if you choose not to load a compiler such as gcc onto your system, DKMS can still be used to install modules.
+It does this through use of DKMS binary only tarballs as explained in this README under tarballs of type *c*.
-If you choose not to load module source on your system or if you choose not to
-load a compiler such as gcc onto your system, DKMS can still be used to install
-modules. It does this through use of DKMS binary only tarballs as explained in
-this README under tarballs of type *c*.
-
-If your system does not have module source, loading the dkms tarball will fail
-because of this. To avoid this, use the --force flag, as such:
+If your system does not have module source, loading the dkms tarball will fail because of this.
+To avoid this, use the `--force` flag, as such:
```
# dkms ldtarball /path/to/dkms_enabled.tar.gz --force
```
-This will load the pre-built binaries into the dkms tree, and create the
-directory `/usr/src/-/` which will only contain the
-module's dkms.conf configuration file. Once the tarball is loaded, you can then
-use `dkms install` to install any of the pre-built modules.
+This will load the pre-built binaries into the dkms tree, and create the directory `/usr/src/-/` which will only contain the module's `dkms.conf` configuration file.
+Once the tarball is loaded, you can then use `dkms install` to install any of the pre-built modules.
+
+Of course, since the module source will not be located in your DKMS tree, you will not be able to build any modules with DKMS for this package.
-Of course, since module source will not be located in your dkms tree, you will
-not be able to build any modules with DKMS for this package.
-Module signing
---
+## Module signing
-By default, DKMS generates a self signed certificate for signing modules at
-build time and signs every module that it builds before it gets compressed in
-the configured kernel compression mechanism of choice.
+By default, DKMS generates a self signed certificate for signing modules at build time and signs every module that it builds before it gets compressed in the configured kernel compression mechanism of choice.
-This requires the `openssl` command to be present on the system.
+Private key and certificate are auto generated the first time DKMS is run and placed in `/var/lib/dkms`.
+These certificate files can be pre-populated with your own certificates of choice.
-Private key and certificate are auto generated the first time DKMS is run and
-placed in `/var/lib/dkms`. These certificate files can be pre-populated with
-your own certificates of choice.
+The location as well can be changed by setting the appropriate variables in `/etc/dkms/framework.conf`.
+For example, to allow usage of the system default Ubuntu `update-secureboot-policy` set the configuration file as follows:
-The location as well can be changed by setting the appropriate variables in
-`/etc/dkms/framework.conf`. For example, to allow usage of the system default
-Ubuntu `update-secureboot-policy` set the configuration file as follows:
```
mok_signing_key="/var/lib/shim-signed/mok/MOK.priv"
mok_certificate="/var/lib/shim-signed/mok/MOK.der"
```
-NOTE: If any of the files specified by `mok_signing_key` and
-`mok_certificate` are non-existant, dkms will re-create both files.
-The paths specified in `mok_signing_key`, `mok_certificate` and `sign_file` can
-use the variable `${kernelver}` to represent the target kernel version.
+NOTE: If any of the files specified by `mok_signing_key` and `mok_certificate` are non-existant, DKMS will re-create both files.
+
+The paths specified in `mok_signing_key`, `mok_certificate` and `sign_file` can use the variable `${kernelver}` to represent the target kernel version.
+
```
sign_file="/lib/modules/${kernelver}/build/scripts/sign-file"
```
-The variable `mok_signing_key` can also be a `pkcs11:...` string for a [PKCS#11
-engine](https://www.rfc-editor.org/rfc/rfc7512), as long as the `sign_file`
-program supports it.
+The variable `mok_signing_key` can also be a `pkcs11:...` string for a [PKCS#11 engine](https://www.rfc-editor.org/rfc/rfc7512), as long as the `sign_file` program supports it.
+
+### Code Signing extended key usage validation
+
+Your kernel might be patched and compiled with the option `CONFIG_CHECK_CODESIGN_EKU` to assist with compliance to the NIAP Protection Profile for General Purpose Operating Systems.
+Page 35 of [version 4.3 of the specification](https://www.niap-ccevs.org/protectionprofiles/469) states:
-Secure Boot
---
+```
+* The OS shall validate the extendedKeyUsage field according to the following rules:
+ * Certificates used for trusted updates and executable code integrity
+ verification shall have the Code Signing Purpose (id-kp 3 with OID
+ 1.3.6.1.5.5.7.3.3) in the extendedKeyUsage field.
+```
-On an UEFI system with Secure Boot enabled, modules require signing (as
-described in the above paragraph) before they can be loaded and the firmware of
-the system must know the correct public certificate to verify the module
-signature.
+So from DKMS 3.1.7 the MOK self signed certificate is now generated with the `extendedKeyUsage` set to `codeSigning`.
+This requires version *1.1.1 or newer* of the `openssl` command to be present on the system.
+
+In case your system is validating the extended key usage and you have autogenerated keys from a DKMS version prior to 3.1.7, the keys need to be regenerated.
+For example, assuming the default configuration:
+
+```
+# rm -fr /var/lib/dkms/mok.{key,pub}
+# dkms generate_mok
+Signing key: /var/lib/dkms/mok.key
+Public certificate (MOK): /var/lib/dkms/mok.pub
+```
+
+
+## Secure Boot
+
+On an UEFI system with Secure Boot enabled, modules require signing (as described in the above paragraph) before they can be loaded and the firmware of the system must know the correct public certificate to verify the module signature.
For importing the MOK certificate make sure `mokutil` is installed.
@@ -189,11 +179,15 @@ signer: DKMS module signing key
The module can now be loaded without issues.
-Further Documentation
---
+### MOK certificate encryption algorithm
+
+UEFI specification 2.11 [contains a list of valid encryption keys](https://uefi.org/specs/UEFI/2.11/37_Secure_Technologies.html#encryption-algorithm-properties) for the MOK certificate.
+The list is quite limited, basically offering only RSA as a valid key type.
+For maximum compatibility, DKMS generates the MOK certificate with a *2048 bit RSA key with SHA-2 256 as a digest*.
+
+
+## Further Documentation
-Once DKMS is installed, you can reference its man page for further information
-on different DKMS options and also to understand the formatting of a module's
-dkms.conf configuration file.
+Once DKMS is installed, you can reference its man page for further information on different DKMS options and also to understand the formatting of a module's `dkms.conf` configuration file.
The DKMS project is located at: https://github.com/dell/dkms
diff --git a/debian/HOWTO.Debian b/debian/HOWTO.Debian
deleted file mode 100644
index 532e5b9..0000000
--- a/debian/HOWTO.Debian
+++ /dev/null
@@ -1,40 +0,0 @@
-HOWTO Build DKMS debs w/ Debian & Ubuntu systems
-Copyright 2008 Dell Inc.
- Author: Mario Limonciello
-
-------------
-
-A dkms deb is a common representation of a DKMS package that can be distributed across multiple machines.
-After you have a functional DKMS package, you can follow these steps to build a DKMS deb.
-
-1) Start out by putting together a tree in /usr/src/PACKAGE-VERSION. For our example, we are going to use
-the PACKAGE lirc and VERSION 0.8.3~pre1. Create a dkms.conf per the recommendations in the DKMS guide.
-
-2) "Add" the package to the dkms tree system:
- dkms add -m lirc -v 0.8.3~pre1
-
-3) "Build" the binary modules for the current kernel:
- dkms build -m lirc -v 0.8.3~pre1
-
-4) Make the deb and/or dsc for the package:
- dkms mkdeb -m lirc -v 0.8.3~pre1
- dkms mkdsc -m lirc -v 0.8.3~pre1
-
-The end result will be a deb and/or dsc in /var/lib/dkms/lirc/0.8.3~pre1/deb or /var/lib/dkms/lirc/0.8.3~pre1/dsc
-
-------------
-If you would prefer not to contaminate your system with the changes from building these debs, you should
-create a framework.conf that contains these variables (adjust for your use case):
-
- source_tree="/path/to/source/tree"
- dkms_tree="/path/to/dkms/tree"
-
-You will then call DKMS with an extra variable, '--dkmsframework'. Here is an example of how this would work
-using the same lirc example above:
-
- dkms add -m lirc -v 0.8.3~pre1 --dkmsframework framework.conf
- dkms build -m lirc -v 0.8.3~pre1 --dkmsframework framework.conf
- dkms mkdeb -m lirc -v 0.8.3~pre1 --dkmsframework framework.conf
- dkms mkdsc -m lirc -v 0.8.3~pre1 --dkmsframework framework.conf
-
-The end result will be both a debian binary package and a debian source package that you can use.
diff --git a/debian/autoinstall_all_kernels.conf b/debian/autoinstall_all_kernels.conf
new file mode 100644
index 0000000..baca357
--- /dev/null
+++ b/debian/autoinstall_all_kernels.conf
@@ -0,0 +1 @@
+autoinstall_all_kernels="yes"
diff --git a/debian/changelog b/debian/changelog
index 6fd50de..a008019 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,111 @@
-dkms (3.1.0-1deepin1) unstable; urgency=medium
+dkms (3.2.2-1~deb13u1) trixie; urgency=medium
- * fix bug when dkms status (original_module exists)
+ * Rebuild for trixie.
- -- shaoyang Fri, 07 Nov 2025 15:11:30 +0800
+ -- Andreas Beckmann Sat, 01 Nov 2025 20:49:32 +0100
+
+dkms (3.2.2-1) unstable; urgency=medium
+
+ * New upstream release.
+ * Stop shipping dkms.service. Not really needed and causes a dependency
+ cycle with cloud-init-network.service. (Closes: #1107232)
+ * common.postinst: Emit a warning if no kernel headers were found.
+ (Closes: #1114731)
+ * Drop Pre-Depends: lsb-release, no longer used since 3.0.12.
+ * Add Breaks against more obsolete *-dkms packages.
+
+ -- Andreas Beckmann Wed, 17 Sep 2025 00:42:50 +0200
+
+dkms (3.2.0-1) unstable; urgency=medium
+
+ * New upstream release.
+
+ -- Andreas Beckmann Sat, 10 May 2025 04:47:51 +0200
+
+dkms (3.1.8-1) unstable; urgency=medium
+
+ * New upstream release. (Closes: #1102075, #1098805)
+ * Suppress the CLEAN deprecation warning for trixie.
+
+ -- Andreas Beckmann Sat, 12 Apr 2025 00:23:30 +0200
+
+dkms (3.1.7-2) unstable; urgency=medium
+
+ * Skip autopkgtest without /proc if it cannot be unmounted.
+ * Unbreak zfs-dkms post_build script.
+
+ -- Andreas Beckmann Fri, 04 Apr 2025 22:50:46 +0200
+
+dkms (3.1.7-1) unstable; urgency=medium
+
+ * New upstream release. (Closes: #1025785)
+ * Install zsh completions in /usr/share/zsh/vendor-completions/.
+ * New autopkgtest: Run upstream testsuite with /proc unmounted.
+ * Ship dkms.service.
+
+ -- Andreas Beckmann Fri, 04 Apr 2025 02:09:34 +0200
+
+dkms (3.1.5-2) unstable; urgency=medium
+
+ * dkms-autopkgtest: Support manual execution with a .deb file argument.
+ * Add Breaks against more obsolete *-dkms packages.
+ * run_test.sh: Extract only the major part of the kmod version.
+ (Closes: #1099711)
+ * Bump Standards-Version to 4.7.2, no changes needed.
+
+ -- Andreas Beckmann Tue, 18 Mar 2025 09:08:57 +0100
+
+dkms (3.1.5-1) unstable; urgency=medium
+
+ * New upstream release. (Closes: #1009645, #706868)
+ * Refresh patches.
+ * framework.conf.d: Enable autoinstall_all_kernels="yes" by default.
+ (Closes: #1087433, #704788, #704150)
+ * dkms-autopkgtest: Skip test (exit 0) on i386 (no more kernels or headers).
+ * dkms-autopkgtest: Skip test (exit 77) if no linux-headers-* seem to exist.
+ * Skip upstream testsuite on i386.
+ * Add Breaks against obsolete *-dkms packages that are incompatible with the
+ Linux 6.12 kernel in trixie.
+ * Remove outdated HOWTO.Debian.
+ * Upload to unstable.
+
+ -- Andreas Beckmann Wed, 05 Feb 2025 04:13:14 +0100
+
+dkms (3.1.4-1) experimental; urgency=medium
+
+ * New upstream release. (Closes: #1088640, #843113)
+ * Refresh patches.
+ * Add dkms-replace-test-dkms package with a trivial kernel module for dkms
+ tests.
+ * Fix dkms_autoinstaller error propagation. (Closes: #1093556)
+ * Ensure modules get rebuilt once on kernel upgrades w/o version change.
+ (Closes: #1076351)
+ * dkms-autopkgtest: Update module-is-installed regex again.
+ * Remove Mario Limonciello from Uploaders at his request.
+ * Upload to experimental.
+
+ -- Andreas Beckmann Thu, 23 Jan 2025 05:31:56 +0100
+
+dkms (3.1.0-2.1) unstable; urgency=medium
+
+ * Non-maintainer upload.
+ * No change source-only upload for testing migration.
+
+ -- Boyuan Yang Sun, 19 Jan 2025 15:57:54 -0500
+
+dkms (3.1.0-2) unstable; urgency=medium
+
+ * Team upload.
+
+ [ Andreas Beckmann ]
+ * Clean up /etc/kernel/install.d/40-dkms.install, moved to /usr.
+ (Closes: #1086441)
+
+ [ Jeremy Sowden ]
+ * d/s/dkms-autopkgtest: fix testing of packages that override original modules
+ (Closes: #1088558).
+
+ -- Petter Reinholdtsen Mon, 06 Jan 2025 23:40:28 +0100
dkms (3.1.0-1) unstable; urgency=medium
@@ -14,7 +117,7 @@ dkms (3.1.0-1) unstable; urgency=medium
dkms (3.0.13-1) unstable; urgency=medium
- * New upstream release.
+ * New upstream release. (Closes: #897677)
* Refresh patches.
* Downgrade compiler dependency to Recommends to ease cross installation.
The linux-headers-* packages have a proper compiler dependency.
@@ -95,7 +198,7 @@ dkms (3.0.11-2) unstable; urgency=medium
* dh_dkms: Bump generated dkms dependency for new BUILD_EXCLUSIVE
directives.
* Fix and unify CC detection.
- * Fail early if $arch detection fails. (Closes: #1036033, #842596)
+ * Fail early if $arch detection fails. (Closes: #1036033, #842596, #999467)
* Add Breaks against obsolete *-dkms packages that are incompatible with the
Linux 6.1 kernel in bookworm. (Closes: #1037425)
* Upload to unstable.
@@ -116,6 +219,7 @@ dkms (3.0.11-1) experimental; urgency=medium
dkms (3.0.10-9) experimental; urgency=medium
* Add dkms-test-dkms package with a trivial kernel module for dkms tests.
+ (Closes: #642174)
* New autopkgtest: Install some-dkms after linux-headers.
* New autopkgtest: Install linux-headers after some-dkms.
* New autopkgtest: Install some-dkms after linux-image w/o linux-headers.
@@ -218,7 +322,7 @@ dkms (3.0.10-1) unstable; urgency=medium
dkms (3.0.9-1) unstable; urgency=medium
- * New upstream version 3.0.9 (Closes: #1019425)
+ * New upstream version 3.0.9 (Closes: #1019425, #1008505, #1025224)
* Remove patches merged upstream and refresh remainders
* Remove unused override: source/maintainer-manual-page
* Remove unused "Breaks: ${dkms:Breaks}" from d/control
@@ -727,7 +831,7 @@ dkms (2.3-1) unstable; urgency=medium
[ Aron Xu ]
* Downgrade menu from Recommends to Suggests (Closes: #744054)
- * Imported Upstream version 2.3
+ * Imported Upstream version 2.3 (Closes: #702018)
* Upstream post-release cherry-picks
* d/compat: 7 -> 9
diff --git a/debian/control b/debian/control
index 6808393..eb5cc7d 100644
--- a/debian/control
+++ b/debian/control
@@ -5,10 +5,9 @@ Maintainer: Dynamic Kernel Module System Team
Uploaders: David Paleino ,
Petter Reinholdtsen ,
Aron Xu ,
- Mario Limonciello ,
Andreas Beckmann ,
Build-Depends: debhelper-compat (= 13)
-Standards-Version: 4.7.0
+Standards-Version: 4.7.2
Homepage: https://github.com/dell/dkms
Vcs-Git: https://salsa.debian.org/debian/dkms.git
Vcs-Browser: https://salsa.debian.org/debian/dkms
@@ -18,7 +17,6 @@ Testsuite: autopkgtest-pkg-dkms
Package: dkms
Architecture: all
Multi-Arch: foreign
-Pre-Depends: lsb-release
Depends: ${misc:Depends},
kmod,
dpkg-dev,
@@ -30,14 +28,51 @@ Recommends:
sudo,
Suggests: menu, e2fsprogs
Breaks:
+# fewer supported architectures in trixie than before
+ broadcom-sta-dkms (<< 6.30.223.271-25.1~),
+ dahdi-dkms (<< 1:3.1.0+git20230717~dfsg-10.1~),
+ nvidia-tesla-535-kernel-dkms (<< 535.230),
+ tp-smapi-dkms (<< 0.44-1.2~),
+# in bookworm, not in trixie
+ adv-17v35x-dkms (<< 5.0.7.0-1.0),
+ nat-rtsp-dkms (<< 0.7+5.3-0.3~),
+# fewer supported architectures in bookworm than before
+ bbswitch-dkms (<< 0.8-12~),
+ nvidia-kernel-dkms (<< 535.230),
+# in bullseye, not in bookworm
+ spl-dkms (<< 2.1),
+ wireguard-dkms (<< 1.0.20210606-1.0),
# in buster, not in bullseye
+ aufs-dkms (<< 5.2+20190909-1.1.0),
+ dpdk-igb-uio-dkms (<< 20.08-1.0),
+ dpdk-rte-kni-dkms (<< 18.11.11-1.0),
+ kpatch-dkms (<< 0.6.0-0.2.0),
+ mali-midgard-dkms (<< 16.0+pristine-4.0),
+ ndiswrapper-dkms (<< 1.60-8.0),
sl-modem-dkms (<< 2.9.11~20110321-16.0),
# in stretch, not in buster
+ asic0x-dkms (<< 1.0.1-1.0),
+ backfire-dkms (<< 1.0-1.0),
blktap-dkms (<< 2.0.93-0.10.0),
+ flashcache-dkms (<< 3.1.3+git20150701-5.0),
+ open-vm-tools-dkms (<< 2:10.1.15-1.0),
+ sysdig-dkms (<< 0.27.1-0.3.0),
# in jessie, not in stretch
- oss4-dkms (<< 4.2-build2020-1~),
+ fglrx-modules-dkms (<< 1:15.12-2.0),
+ iscsitarget-dkms (<< 1.4.20.3+svn502-2.0),
+ oss4-dkms (<< 4.2-build2020-5~),
+ virtualbox-dkms (<< 5),
+ virtualbox-guest-dkms (<< 7),
# in wheezy, not in jessie
blcr-dkms (<< 0.8.6~b3-1.0),
+ fuse4bsd-dkms (<< 0.3.9~pre1.20080208-8.0),
+ openswan-modules-dkms (<< 1:2.6.38-1.0),
+ openvswitch-datapath-dkms (<< 2.1.0+git20140411-3.0),
+ virtualbox-ose-dkms (<< 5),
+ virtualbox-ose-guest-dkms (<< 5),
+# in squeeze, not in wheezy
+ batman-adv-dkms (<< 2011.1.0-1.0),
+ batmand-gateway-dkms (<< 0.3.2-9.0),
Provides:
dkms-autopkgtest (= ${binary:Version}),
Description: Dynamic Kernel Module System (DKMS)
@@ -72,8 +107,8 @@ Depends:
Description: trivial dkms test kernel module
This package provides the dkms source code for the dkms_test kernel module.
.
- This package is only intended for ci tests and not expected to be installed
- on regular systems
+ This package is only intended for CI tests and not expected to be installed
+ on regular systems.
Package: dkms-noautoinstall-test-dkms
Architecture: all
@@ -83,5 +118,17 @@ Description: trivial dkms noautoinstall test kernel module
This package provides the dkms source code for the dkms_noautoinstall_test
kernel module.
.
- This package is only intended for ci tests and not expected to be installed
- on regular systems
+ This package is only intended for CI tests and not expected to be installed
+ on regular systems.
+
+Package: dkms-replace-test-dkms
+Architecture: all
+Depends:
+ dkms-test-dkms,
+ ${misc:Depends},
+Description: trivial dkms replace test kernel module
+ This package provides the dkms source code for the dkms_replace_test
+ kernel module.
+ .
+ This package is only intended for CI tests and not expected to be installed
+ on regular systems.
diff --git a/debian/copyright b/debian/copyright
index abc0837..4f7b2b4 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,5 +1,6 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://github.com/dell/dkms
+Upstream-Name: DKMS
Files: *
Copyright: © 2003-2022, Dell, Inc.
@@ -11,27 +12,22 @@ Copyright: © 2008-2009, David Paleino
© 2008-2009, Mario Limonciello
© 2008-2009, Giuseppe Iuculano
© 2019-2023, Gianfranco Costamagna
- © 2020-2024, Andreas Beckmann
+ © 2020-2025, Andreas Beckmann
License: GPL-2+
-Files: debian/HOWTO.Debian
-Copyright: © 2008-2020, Dell, Inc.
License: GPL-2+
-
-License: GPL-2+
- This program is free software; you can redistribute it and/or modify
+ This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License,
- or (at your option) any later version.
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
.
- This program is distributed in the hope that it will be useful,
+ This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- .
- On Debian systems, the complete text of the GNU General Public License
- can be found in /usr/share/common-licenses/GPL-2 file.
+ You should have received a copy of the GNU General Public License
+ along with this package. If not, see .
+Comment:
+ On Debian systems, the complete text of the GNU General
+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
diff --git a/debian/dkms-replace-test-dkms.dkms b/debian/dkms-replace-test-dkms.dkms
new file mode 100644
index 0000000..58b7832
--- /dev/null
+++ b/debian/dkms-replace-test-dkms.dkms
@@ -0,0 +1 @@
+test/dkms_replace_test-2.0/dkms.conf
diff --git a/debian/dkms-replace-test-dkms.install b/debian/dkms-replace-test-dkms.install
new file mode 100644
index 0000000..dec9942
--- /dev/null
+++ b/debian/dkms-replace-test-dkms.install
@@ -0,0 +1 @@
+test/dkms_replace_test-2.0 usr/src/
diff --git a/debian/dkms.docs b/debian/dkms.docs
deleted file mode 100644
index b017ad0..0000000
--- a/debian/dkms.docs
+++ /dev/null
@@ -1 +0,0 @@
-debian/HOWTO.Debian
diff --git a/debian/dkms.install b/debian/dkms.install
index fc647cc..41bd804 100644
--- a/debian/dkms.install
+++ b/debian/dkms.install
@@ -1 +1,12 @@
+etc/dkms/
+etc/kernel/
+usr/lib/dkms/
+usr/lib/kernel/
+usr/sbin/dkms
+usr/share/apport/
+usr/share/bash-completion/
+usr/share/zsh/site-functions/_dkms usr/share/zsh/vendor-completions/
+var/lib/dkms/
+
debian/scripts/dkms-autopkgtest usr/lib/dkms/
+debian/autoinstall_all_kernels.conf etc/dkms/framework.conf.d/
diff --git a/debian/dkms.maintscript b/debian/dkms.maintscript
index b33c374..3885df7 100644
--- a/debian/dkms.maintscript
+++ b/debian/dkms.maintscript
@@ -18,5 +18,5 @@ rm_conffile /etc/dkms/template-dkms-mkbmdeb/debian/changelog 3.0.3-3~
rm_conffile /etc/dkms/template-dkms-mkbmdeb/debian/README.Debian 3.0.3-3~
rm_conffile /etc/dkms/template-dkms-mkbmdeb/Makefile 3.0.3-3~
rm_conffile /etc/dkms/sign_helper.sh 3.0.10-8~
-mv_conffile /etc/kernel/install.d/dkms /etc/kernel/install.d/40-dkms.install 3.0.12-1~
rm_conffile /etc/kernel/install.d/dkms 3.0.12-2~
+rm_conffile /etc/kernel/install.d/40-dkms.install 3.1.0-2~
diff --git a/debian/dkms.manpages b/debian/dkms.manpages
new file mode 100644
index 0000000..0c40ad0
--- /dev/null
+++ b/debian/dkms.manpages
@@ -0,0 +1 @@
+usr/share/man/man8/dkms.8
diff --git a/debian/patches/0001-Remove-last-remnants-of-log_action_msg-from-dkms_aut.patch b/debian/patches/0001-Remove-last-remnants-of-log_action_msg-from-dkms_aut.patch
deleted file mode 100644
index 02232d0..0000000
--- a/debian/patches/0001-Remove-last-remnants-of-log_action_msg-from-dkms_aut.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 8c502778eb2277b2f16b215f0820545909bf1833 Mon Sep 17 00:00:00 2001
-From: Simone Caronni
-Date: Sat, 5 Oct 2024 17:06:59 +0200
-Subject: [PATCH 1/2] Remove last remnants of log_action_msg from
- dkms_autoinstaller.in
-
----
- dkms_autoinstaller.in | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/dkms_autoinstaller.in b/dkms_autoinstaller.in
-index 31c382e..358e3d1 100755
---- a/dkms_autoinstaller.in
-+++ b/dkms_autoinstaller.in
-@@ -59,9 +59,9 @@ case "$1" in
- kernel=$(uname -r)
- fi
- if [ -f /etc/dkms/no-autoinstall ]; then
-- log_action_msg "Automatic installation of modules has been disabled."
-+ echo "Automatic installation of modules has been disabled."
- elif ! _check_kernel_dir $kernel; then
-- log_action_msg "Automatic installation of modules for kernel $kernel was skipped since the kernel headers for this kernel do not seem to be installed."
-+ echo "Automatic installation of modules for kernel $kernel was skipped since the kernel headers for this kernel do not seem to be installed."
- else
- dkms autoinstall --kernelver $kernel
- res=$?
---
-2.39.5
-
diff --git a/debian/patches/0001-run_test.sh-add-gentoo-as-valid-os-id-in-tests.patch b/debian/patches/0001-run_test.sh-add-gentoo-as-valid-os-id-in-tests.patch
deleted file mode 100644
index a7aef48..0000000
--- a/debian/patches/0001-run_test.sh-add-gentoo-as-valid-os-id-in-tests.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 2dbc4a9c155c02c65b932deca89f238a9a72cb49 Mon Sep 17 00:00:00 2001
-From: Andrew Ammerlaan
-Date: Sun, 24 Sep 2023 15:45:34 +0200
-Subject: [PATCH 01/32] run_test.sh: add gentoo as valid os id in tests
-
-Signed-off-by: Andrew Ammerlaan
----
- run_test.sh | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/run_test.sh b/run_test.sh
-index 4cda255..87c464d 100755
---- a/run_test.sh
-+++ b/run_test.sh
-@@ -249,6 +249,9 @@ case "${os_id}" in
- expected_dest_loc=kernel/extra
- mod_compression_ext=.gz
- ;;
-+ gentoo)
-+ expected_dest_loc=kernel/extra
-+ ;;
- *)
- echo >&2 "Error: unknown Linux distribution ID ${os_id}"
- exit 1
---
-2.20.1
-
diff --git a/debian/patches/0001-run_test.sh-show-make.log-on-unexpected-errors.patch b/debian/patches/0001-run_test.sh-show-make.log-on-unexpected-errors.patch
new file mode 100644
index 0000000..9982c21
--- /dev/null
+++ b/debian/patches/0001-run_test.sh-show-make.log-on-unexpected-errors.patch
@@ -0,0 +1,33 @@
+From 4a00fead920c99e480e42f5b88573c5b0944ff6d Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann
+Date: Wed, 3 Sep 2025 13:32:00 +0200
+Subject: [PATCH 1/2] run_test.sh: show make.log on unexpected errors
+
+---
+ run_test.sh | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/run_test.sh b/run_test.sh
+index 2790a7e..9bc11e9 100755
+--- a/run_test.sh
++++ b/run_test.sh
+@@ -222,13 +222,16 @@ run_with_expected_error() {
+ local output_log=test_cmd_output.log
+ local expected_output_log=test_cmd_expected_output.log
+ local error_code=0
++ local make_log
+
+ shift
+ cat > "${expected_output_log}"
+ stdbuf -o L -e L "$@" > "${output_log}" 2>&1 || error_code=$?
++ make_log=$(awk '{print $2}' "${output_log}" | grep make.log || true)
+ if [[ "${error_code}" != "${expected_error_code}" ]] ; then
+ echo "Error: command '$*' returned status ${error_code} instead of expected ${expected_error_code}"
+ cat "${output_log}"
++ [ -z "${make_log}" ] || cat "${make_log}"
+ rm "${expected_output_log}" "${output_log}"
+ return 1
+ fi
+--
+2.39.5
+
diff --git a/debian/patches/0002-Drop-GNU-kFreeBSD.patch b/debian/patches/0002-Drop-GNU-kFreeBSD.patch
deleted file mode 100644
index eb88eca..0000000
--- a/debian/patches/0002-Drop-GNU-kFreeBSD.patch
+++ /dev/null
@@ -1,151 +0,0 @@
-From cf6973e4e09fea041df3832300861d4ecd4c8760 Mon Sep 17 00:00:00 2001
-From: Simone Caronni
-Date: Sat, 5 Oct 2024 17:14:06 +0200
-Subject: [PATCH 2/2] Drop GNU/kFreeBSD
-
----
- dkms.in | 16 ++--------------
- dkms_autoinstaller.in | 11 ++---------
- dkms_common.postinst.in | 11 ++---------
- kernel_postinst.d_dkms.in | 23 ++++-------------------
- 4 files changed, 10 insertions(+), 51 deletions(-)
-
-diff --git a/dkms.in b/dkms.in
-index 1cd55b1..a8f2c6a 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -55,10 +55,7 @@ readonly mv_re='^([^/]*)/(.*)$'
- _get_kernel_dir() {
- if [[ -z $ksourcedir_fromcli ]]; then
- KVER=$1
-- case ${current_os} in
-- Linux) DIR="$install_tree/$KVER/build" ;;
-- GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
-- esac
-+ DIR="$install_tree/$KVER/build"
- echo $DIR
- else
- echo $kernel_source_dir
-@@ -67,11 +64,7 @@ _get_kernel_dir() {
-
- _check_kernel_dir() {
- DIR=$(_get_kernel_dir $1)
-- case ${current_os} in
-- Linux) test -e $DIR/include ;;
-- GNU/kFreeBSD) test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;;
-- *) return 1 ;;
-- esac
-+ test -e $DIR/include
- return $?
- }
-
-@@ -406,11 +399,6 @@ override_dest_module_location()
- local orig_location="$1"
- [[ ${addon_modules_dir} ]] && echo "/${addon_modules_dir}" && return
-
-- if [[ $current_os = GNU/kFreeBSD ]] ; then
-- # Does not support subdirs, regardless of distribution
-- echo "" && return
-- fi
--
- case "$running_distribution" in
- fedora* | rhel* | ovm*)
- echo "/extra" && return
-diff --git a/dkms_autoinstaller.in b/dkms_autoinstaller.in
-index 358e3d1..eee0352 100755
---- a/dkms_autoinstaller.in
-+++ b/dkms_autoinstaller.in
-@@ -34,20 +34,13 @@ uname_s=$(uname -s)
-
- _get_kernel_dir() {
- KVER=$1
-- case ${uname_s} in
-- Linux) DIR="@MODDIR@/$KVER/build" ;;
-- GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
-- esac
-+ DIR="@MODDIR@/$KVER/build"
- echo $DIR
- }
-
- _check_kernel_dir() {
- DIR=$(_get_kernel_dir $1)
-- case ${uname_s} in
-- Linux) test -e $DIR/include ;;
-- GNU/kFreeBSD) test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;;
-- *) return 1 ;;
-- esac
-+ test -e $DIR/include
- return $?
- }
-
-diff --git a/dkms_common.postinst.in b/dkms_common.postinst.in
-index fe5d037..2c54058 100644
---- a/dkms_common.postinst.in
-+++ b/dkms_common.postinst.in
-@@ -10,20 +10,13 @@ uname_s=$(uname -s)
-
- _get_kernel_dir() {
- KVER=$1
-- case ${uname_s} in
-- Linux) DIR="@MODDIR@/$KVER/build" ;;
-- GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
-- esac
-+ DIR="@MODDIR@/$KVER/build"
- echo $DIR
- }
-
- _check_kernel_dir() {
- DIR=$(_get_kernel_dir $1)
-- case ${uname_s} in
-- Linux) test -e $DIR/include ;;
-- GNU/kFreeBSD) test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;;
-- *) return 1 ;;
-- esac
-+ test -e $DIR/include
- return $?
- }
-
-diff --git a/kernel_postinst.d_dkms.in b/kernel_postinst.d_dkms.in
-index f4ccc95..d73fcb7 100755
---- a/kernel_postinst.d_dkms.in
-+++ b/kernel_postinst.d_dkms.in
-@@ -7,32 +7,17 @@ uname_s=$(uname -s)
-
- _get_kernel_dir() {
- KVER=$1
-- case ${uname_s} in
-- Linux) DIR="@MODDIR@/$KVER/build" ;;
-- GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
-- esac
-+ DIR="@MODDIR@/$KVER/build"
- echo "$DIR"
- }
-
- _check_kernel_dir() {
- DIR=$(_get_kernel_dir "$1")
-- case ${uname_s} in
-- Linux) test -e "$DIR/include" ;;
-- GNU/kFreeBSD) test -e "$DIR/kern" && test -e "$DIR/conf/kmod.mk" ;;
-- *) false ;;
-- esac
-+ test -e "$DIR/include"
- }
-
--case "${uname_s}" in
-- Linux)
-- header_pkg="linux-headers-$inst_kern"
-- kernel="Linux"
-- ;;
-- GNU/kFreeBSD)
-- header_pkg="kfreebsd-headers-$inst_kern"
-- kernel="kFreeBSD"
-- ;;
--esac
-+header_pkg="linux-headers-$inst_kern"
-+kernel="Linux"
-
- if [ -x @LIBDIR@/dkms_autoinstaller ]; then
- exec @LIBDIR@/dkms_autoinstaller start "$inst_kern"
---
-2.39.5
-
diff --git a/debian/patches/0002-common.postinst-emit-a-warning-if-no-kernel-headers-.patch b/debian/patches/0002-common.postinst-emit-a-warning-if-no-kernel-headers-.patch
new file mode 100644
index 0000000..aa1721f
--- /dev/null
+++ b/debian/patches/0002-common.postinst-emit-a-warning-if-no-kernel-headers-.patch
@@ -0,0 +1,32 @@
+From d876d6ce26a1d6e01384bd404d4d64e8f078b01e Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann
+Date: Sun, 14 Sep 2025 13:27:56 +0200
+Subject: [PATCH 2/2] common.postinst: emit a warning if no kernel headers were
+ found
+
+Fixes: #545
+---
+ dkms_common.postinst.in | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/dkms_common.postinst.in b/dkms_common.postinst.in
+index 9e76604..87781b8 100644
+--- a/dkms_common.postinst.in
++++ b/dkms_common.postinst.in
+@@ -208,6 +208,13 @@ if [ -z "$autoinstall_all_kernels" ]; then
+ fi
+ fi
+
++if [ -z "$KERNELS" ]; then
++ echo "WARNING: No kernel headers were found, skipping module build."
++ echo " The get the headers for the running kernel ($CURRENT_KERNEL)"
++ echo " please install the linux-headers-$CURRENT_KERNEL package."
++ exit 0
++fi
++
+ # Take care of displaying newline separated list
+ echo "Building for $KERNELS" | tr '\n' ',' \
+ | sed -e 's/,/, /g; s/, $/\n/; s/, \([^,]\+\)$/ and \1/'
+--
+2.39.5
+
diff --git a/debian/patches/0003-common.postinst-fix-warning-message.patch b/debian/patches/0003-common.postinst-fix-warning-message.patch
new file mode 100644
index 0000000..fcb6e5b
--- /dev/null
+++ b/debian/patches/0003-common.postinst-fix-warning-message.patch
@@ -0,0 +1,25 @@
+From a66123e937308553e9d721b3ddc965149d65ba31 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann
+Date: Mon, 15 Sep 2025 13:05:47 +0200
+Subject: [PATCH] common.postinst: fix warning message
+
+---
+ dkms_common.postinst.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/dkms_common.postinst.in b/dkms_common.postinst.in
+index 87781b8..10dd392 100644
+--- a/dkms_common.postinst.in
++++ b/dkms_common.postinst.in
+@@ -210,7 +210,7 @@ fi
+
+ if [ -z "$KERNELS" ]; then
+ echo "WARNING: No kernel headers were found, skipping module build."
+- echo " The get the headers for the running kernel ($CURRENT_KERNEL)"
++ echo " To get the headers for the running kernel ($CURRENT_KERNEL)"
+ echo " please install the linux-headers-$CURRENT_KERNEL package."
+ exit 0
+ fi
+--
+2.39.5
+
diff --git a/debian/patches/0003-document-CLEAN-true.patch b/debian/patches/0003-document-CLEAN-true.patch
new file mode 100644
index 0000000..6418834
--- /dev/null
+++ b/debian/patches/0003-document-CLEAN-true.patch
@@ -0,0 +1,36 @@
+From b351ded2712358c10ff736513d3e2db9595b2296 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann
+Date: Sat, 10 May 2025 03:31:00 +0200
+Subject: [PATCH 3/3] document CLEAN="true"
+
+---
+ dkms.8.in | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/dkms.8.in b/dkms.8.in
+index 4ad5f6b..6b87dfe 100644
+--- a/dkms.8.in
++++ b/dkms.8.in
+@@ -661,6 +661,19 @@ to use the corresponding make command in the
+ .B MAKE[#]
+ directive array to build your module.
+ .TP
++.B CLEAN=
++(deprecated)
++The
++.B CLEAN
++directive used to contain a command for cleaning the ephemeral build tree right before it gets deleted.
++For backwards compatibility with older DKMS versions
++.B CLEAN="true"
++can be used instead of removing the directive from
++.I dkms.conf
++entirely.
++This will turn the unneeded cleanup command into a no-op on older DKMS versions
++while suppressing the deprecation warning on newer versions.
++.TP
+ .B NO_WEAK_MODULES=
+ The
+ .B NO_WEAK_MODULES
+--
+2.39.5
+
diff --git a/debian/patches/0004-Use-unbuild-instead-of-remove-in-kernel-prerm-script.patch b/debian/patches/0004-Use-unbuild-instead-of-remove-in-kernel-prerm-script.patch
deleted file mode 100644
index 736e7c3..0000000
--- a/debian/patches/0004-Use-unbuild-instead-of-remove-in-kernel-prerm-script.patch
+++ /dev/null
@@ -1,124 +0,0 @@
-From 334294d61a6ed1873aa1320801dd01fc175b6b14 Mon Sep 17 00:00:00 2001
-From: Ian Abbott
-Date: Tue, 19 Sep 2023 12:16:37 +0100
-Subject: [PATCH 04/13] Use 'unbuild' instead of 'remove' in kernel prerm
- script
-
-When DKMS is invoked by the kernel_prerm.d_dkms script to remove modules
-from a kernel that is being removed, it uses the DKMS 'remove' command.
-If there are no other installations of the module, it will be removed
-completely from DKMS. That seems to be an undesirable side-effect and
-predates the introduction of the DKMS 'unbuild' command which merely
-undoes the 'install' and 'build' steps.
-
-Change the script to use 'unbuild' instead of 'remove'. Keep the echoed
-message that says "dkms: removing: ..." because "dkms: unbuilding: ..."
-may be confusing to the user.
-
-I have tested it by removing a kernel with a module installed by DKMS
-that was the only installed instance of the module. Without the change,
-the module was removed completely from DKMS. With the change, the
-module was removed from the kernel, but was not removed completely. On
-reinstalling the kernel, the module was rebuilt and reinstalled for the
-kernel by DKMS.
-
-This change was suggested by @RalfGoebel for issue #37 and might be
-Debian-specific.
-
-For Debian and Ubuntu, the 'kernel_postinst.d_dkms' script is installed as
-'/etc/kernel/postinst.d/dkms' and '/etc/kernel/header_postinst.d/dkms',
-and the 'kernel_prerm.d_dkms' script is installed as
-'/etc/kernel/prerm.d/dkms'. The scripts are invoked in the following
-circumstances, with the script parameter $1 set to the kernel version
-from the kernel package (referred to as "${KVER}" below):
-
-1. When a "linux-headers-${KVER}" package is installed (containing the
- stuff needed to build external modules), the
- '/etc/kernel/header_postinst.d/dkms' ('kernel_postinst.d_dkms')
- script is invoked to autoinstall DKMS modules for the kernel version,
- building the modules if necessary.
-
-2. When a "linux-image-${KVER}" package is installed (containing the
- Linux kernel binary, and in the case of Debian, also the kernel
- module binaries), the '/etc/kernel/postinst.d/dkms
- ('kernel_postinst.d_dkms') script is invoked to autoinstall DKMS
- modules for the kernel version, building the modules if necessary and
- possible. (Building the modules will fail unless the
- "linux-headers-${KVER}" package is installed.)
-
-3. When a "linux-headers-${KVER}" package is being removed, none of the
- DKMS scripts are invoked.
-
-4. When a "linux-image-${KVER}" package is being removed, the
- '/etc/kernel/prerm.d/dkms' ('kernel_prerm.d_dkms') script is invoked
- to perform some sort of uninstallation action on all DKMS modules
- that have been built for the kernel version. Prior to this patch,
- the DKMS 'remove' command was used to uninstall the modules. This
- patch changes that to the DKMS 'unbuild' command which is less
- destructive.
-
-On first glance, it may seem better to use the DKMS 'uninstall' command
-when removing a "linux-image-${KVER}" package, and to use the DKMS
-'unbuild' command when removing a "linux-headers-${KVER}" package.
-However, the "linux-image-${KVER}" and "linux-headers-${KVER}" packages
-do not depend on each other, so unbuilding the DKMS modules when the
-"linux-headers-${KVER}" package is being removed would have the side
-effect of uninstalling the DKMS modules for the kernel, even if the
-"linux-image-${KVER}" package is still installed. Therefore, the
-compromise is to use the DKMS 'unbuild' command when removing a
-"linux-image-${KVER}" package and to do nothing when removing a
-"linux-headers-${KVER}" package. This helps avoid littering the
-'/var/lib/dkms' directory with stale builds. It is sub-optimal if the
-same version of the "linux-image-${KVER}" package is to be reinstalled
-later because the DKMS modules would need to be built again, but that
-should be fairly rare. Normally, kernel packages are upgraded to a
-different version, requiring the DKMS modules to be built anyway.
-
-The script only affects DKMS modules with the "installed" status. Only
-DKMS modules with the "installed" status have files in
-"/lib/modules/${KVER}" that need to be cleaned up. It could be argued
-that since the script is using the DKMS 'unbuild' command, it should
-also unbuild DKMS modules with the "built" status. There must have been
-some external intervention outside of the kernel installation/removal
-hook scripts to leave those modules at the "built" status, so the script
-may be playing it safe by leaving those DKMS modules alone.
-
-Link: https://github.com/dell/dkms/issues/37#issuecomment-1041184403
-Tested-by: Ian Abbott
-Signed-off-by: Ian Abbott
----
- kernel_prerm.d_dkms | 13 +++++++++++--
- 1 file changed, 11 insertions(+), 2 deletions(-)
-
-diff --git a/kernel_prerm.d_dkms b/kernel_prerm.d_dkms
-index aeb8e3a..9d507fe 100755
---- a/kernel_prerm.d_dkms
-+++ b/kernel_prerm.d_dkms
-@@ -1,13 +1,22 @@
- #!/bin/sh
-
--# We're passed the version of the kernel being removed
-+# This script is triggered when the kernel (linux-image) package is being
-+# removed. We're passed the version of the kernel being removed.
- inst_kern=$1
-
- if command -v dkms > /dev/null; then
- dkms status -k "$inst_kern" 2>/dev/null | while IFS=",:/ " read -r name vers _ arch status; do
- [ "$status" = "installed" ] || continue
- echo "dkms: removing: $name $vers ($inst_kern) ($arch)" >&2
-- dkms remove -m "$name" -v "$vers" -k "$inst_kern" -a "$arch"
-+ # Compromise on using 'unbuild' to remove the module when a
-+ # kernel is being removed. The 'remove' command is too
-+ # destructive. The 'uninstall' command leaves built files
-+ # around that have no other trigger to 'unbuild' them.
-+ # (Triggering 'unbuild' on kernel header removal would not be
-+ # a good idea because that would also cause the module to be
-+ # uninstalled for the kernel, even though only the headers are
-+ # being removed.)
-+ dkms unbuild -m "$name" -v "$vers" -k "$inst_kern" -a "$arch"
- done
- fi
-
---
-2.20.1
-
diff --git a/debian/patches/0007-dkms-always-use-read_conf_or_die.patch b/debian/patches/0007-dkms-always-use-read_conf_or_die.patch
deleted file mode 100644
index a784c9c..0000000
--- a/debian/patches/0007-dkms-always-use-read_conf_or_die.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From c0004f07b901099dea4083b50f4e25fa09970a2d Mon Sep 17 00:00:00 2001
-From: Emil Velikov
-Date: Sat, 21 Oct 2023 14:48:51 +0100
-Subject: [PATCH 07/13] dkms: always use read_conf_or_die
-
-Currently dkms status and by extension dkms autoinstall use read_conf,
-which prints an error yet results in the commands succeeding.
-
-Browsing across Arch and Debian, this can only happen on user error. As
-such lets flip it to the fatal "_or_die" variant, like all the other
-instances in the codebase.
-
-Signed-off-by: Emil Velikov
----
- dkms.in | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/dkms.in b/dkms.in
-index 881d083..43fcab6 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -1731,7 +1731,7 @@ do_status_weak()
- # interested in, but that the DKMS internals do not usually care about.
- module_status_built_extra() (
- set_module_suffix "$3"
-- read_conf "$3" "$4" "$dkms_tree/$1/$2/source/dkms.conf" 2>/dev/null
-+ read_conf_or_die "$3" "$4" "$dkms_tree/$1/$2/source/dkms.conf" 2>/dev/null
- [[ -d $dkms_tree/$1/original_module/$3/$4 ]] && echo -n " (original_module exists)"
- for ((count=0; count < ${#dest_module_name[@]}; count++)); do
- tree_mod=$(compressed_or_uncompressed "$dkms_tree/$1/$2/$3/$4/module" "${dest_module_name[$count]}")
---
-2.20.1
-
diff --git a/debian/patches/0013-test-Make-suite-runnable-on-linuxmint.patch b/debian/patches/0013-test-Make-suite-runnable-on-linuxmint.patch
deleted file mode 100644
index 7f0e4a5..0000000
--- a/debian/patches/0013-test-Make-suite-runnable-on-linuxmint.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 749b219744ccb3bbc6219aa48db653bbc9ebbebb Mon Sep 17 00:00:00 2001
-From: Edwin Kofler
-Date: Mon, 23 Oct 2023 05:59:49 -0700
-Subject: [PATCH 13/32] test: Make suite runnable on `linuxmint`
-
----
- run_test.sh | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/run_test.sh b/run_test.sh
-index 87c464d..50e233b 100755
---- a/run_test.sh
-+++ b/run_test.sh
-@@ -242,7 +242,7 @@ case "${os_id}" in
- sles | suse | opensuse)
- expected_dest_loc=updates
- ;;
-- arch | debian | ubuntu)
-+ arch | debian | ubuntu | linuxmint)
- expected_dest_loc=updates/dkms
- ;;
- alpine)
---
-2.20.1
-
diff --git a/debian/patches/0014-Document-that-both-MOK-files-must-exist.patch b/debian/patches/0014-Document-that-both-MOK-files-must-exist.patch
deleted file mode 100644
index 09f79e8..0000000
--- a/debian/patches/0014-Document-that-both-MOK-files-must-exist.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-From 643522285118974e23e3ce1236c9a5c670f53060 Mon Sep 17 00:00:00 2001
-From: Emil Velikov
-Date: Wed, 29 Nov 2023 13:42:54 +0000
-Subject: [PATCH 14/19] Document that both MOK files must exist
-
-... or dkms will overwrite them both.
-
-In the future we might consider changing this to an error if only one of
-the two is available, but for now document the current behaviour.
-
-Closes: https://github.com/dell/dkms/issues/366
-Signed-off-by: Emil Velikov
----
- README.md | 2 ++
- dkms.8.in | 4 ++++
- dkms_framework.conf | 4 ++++
- 3 files changed, 10 insertions(+)
-
-diff --git a/README.md b/README.md
-index e112824..65c1d15 100644
---- a/README.md
-+++ b/README.md
-@@ -109,6 +109,8 @@ Ubuntu `update-secureboot-policy` set the configuration file as follows:
- mok_signing_key="/var/lib/shim-signed/mok/MOK.priv"
- mok_certificate="/var/lib/shim-signed/mok/MOK.der"
- ```
-+NOTE: If any of the files specified by `mok_signing_key` and
-+`mok_certificate` are non-existant, dkms will re-create both files.
-
- The paths specified in `mok_signing_key`, `mok_certificate` and `sign_file` can
- use the variable `${kernelver}` to represent the target kernel version.
-diff --git a/dkms.8.in b/dkms.8.in
-index a228f8c..ad34b4b 100644
---- a/dkms.8.in
-+++ b/dkms.8.in
-@@ -787,6 +787,10 @@ can be used in path to represent the target kernel version. The path for the bin
- Location of the key and certificate files used for Secure boot. The variable
- .B $kernelver
- can be used in path to represent the target kernel version.
-+
-+NOTE: If any of the files specified by $mok_signing_key and
-+$mok_certificate are non-existant, dkms will re-create both files.
-+
- .I mok_signing_key
- can also be a "pkcs11:..." string for PKCS#11 engine, as long as the sign_file program supports it.
- .TP
-diff --git a/dkms_framework.conf b/dkms_framework.conf
-index db487c0..6ad6dd2 100644
---- a/dkms_framework.conf
-+++ b/dkms_framework.conf
-@@ -31,6 +31,10 @@
-
- # Location of the key and certificate files used for Secure boot. $kernelver
- # can be used in path to represent the target kernel version.
-+#
-+# NOTE: If any of the files specified by `mok_signing_key` and
-+# `mok_certificate` are non-existant, dkms will re-create both files.
-+#
- # mok_signing_key can also be a "pkcs11:..." string for PKCS#11 engine, as
- # long as the sign_file program supports it.
- # (default: /var/lib/dkms):
---
-2.20.1
-
diff --git a/debian/patches/0015-Fallback-to-reading-os-release-in-usr-lib-if-missing.patch b/debian/patches/0015-Fallback-to-reading-os-release-in-usr-lib-if-missing.patch
deleted file mode 100644
index 1906017..0000000
--- a/debian/patches/0015-Fallback-to-reading-os-release-in-usr-lib-if-missing.patch
+++ /dev/null
@@ -1,135 +0,0 @@
-From 0b1b2b55005e1fff96cd3e4101734de2ed72335b Mon Sep 17 00:00:00 2001
-From: Edwin Kofler
-Date: Fri, 1 Dec 2023 18:21:08 -0800
-Subject: [PATCH 15/19] Fallback to reading `os-release` in `/usr/lib` if
- missing one in `/etc`
-
----
- dkms.in | 27 +++++++++++---------
- run_test.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 87 insertions(+), 11 deletions(-)
-
-diff --git a/dkms.in b/dkms.in
-index 43fcab6..54a1010 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -329,18 +329,23 @@ do_depmod()
- # Grab distro information from os-release.
- distro_version()
- {
-- [[ -r /etc/os-release ]] || die 4 $"System is missing /etc/os-release file."
-- (
-- . /etc/os-release
-- if [[ "$ID" = "ubuntu" ]]; then
-- # ID_LIKE=debian in ubuntu
-- echo $ID
-- elif [[ ${#ID_LIKE[@]} != 0 ]]; then
-- echo ${ID_LIKE[0]}
-- else
-- echo $ID
-+ for f in /etc/os-release /usr/lib/os-release; do
-+ if [[ -r $f ]]; then
-+ (
-+ . "$f"
-+ if [[ "$ID" = "ubuntu" ]]; then
-+ # ID_LIKE=debian in ubuntu
-+ echo $ID
-+ elif [[ ${#ID_LIKE[@]} != 0 ]]; then
-+ echo ${ID_LIKE[0]}
-+ else
-+ echo $ID
-+ fi
-+ )
-+ return
- fi
-- )
-+ done
-+ die 4 $"System is missing os-release file."
- }
-
- override_dest_module_location()
-diff --git a/run_test.sh b/run_test.sh
-index 50e233b..c731892 100755
---- a/run_test.sh
-+++ b/run_test.sh
-@@ -1541,6 +1541,77 @@ EOF
- echo 'Removing /usr/src/dkms_build_exclusive_test-1.0'
- rm -r /usr/src/dkms_build_exclusive_test-1.0
-
-+############################################################################
-+### Testing os-release detection ###
-+############################################################################
-+echo "Backing up /etc/os-release and /usr/bin/os-release"
-+osrelease_cleanup() {
-+ rm -f _os-release
-+ mv _etc-os-release /etc/os-release &>/dev/null || :
-+ mv _usrlib-os-release /usr/lib/os-release &>/dev/null || :
-+}
-+trap osrelease_cleanup EXIT
-+for f in /etc/os-release /usr/lib/os-release; do
-+ if [ -f "$f" ]; then
-+ cp -f "$f" _os-release
-+ break
-+ fi
-+done
-+[ -f _os-release ] || { echo >&2 "Error: file os-release not found"; exit 1; }
-+mv /etc/os-release _etc-os-release &>/dev/null || :
-+mv /usr/lib/os-release _usrlib-os-release &>/dev/null || :
-+
-+echo "Adding the dkms_test-1.0 module with no os-release files (expected error)"
-+run_with_expected_error 4 dkms add test/dkms_test-1.0 << EOF
-+Error! System is missing os-release file.
-+EOF
-+
-+echo "Creating /etc/os-release"
-+cp -f _os-release /etc/os-release
-+echo "Adding the dkms_test-1.0 module with file /etc/os-release"
-+run_with_expected_output dkms add test/dkms_test-1.0 << EOF
-+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
-+EOF
-+run_status_with_expected_output 'dkms_test' << EOF
-+dkms_test/1.0: added
-+EOF
-+
-+echo 'Removing dkms_test module'
-+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
-+Module dkms_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-+Module dkms_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-+Deleting module dkms_test-1.0 completely from the DKMS tree.
-+EOF
-+echo "Removing /usr/src/dkms_test-1.0"
-+rm -r /usr/src/dkms_test-1.0
-+echo "Deleting /etc/os-release"
-+rm -f /etc/os-release
-+
-+echo "Creating /usr/lib/os-release"
-+cp -f _os-release /etc/os-release
-+echo "Adding the dkms_test-1.0 module with file /usr/lib/os-release"
-+run_with_expected_output dkms add test/dkms_test-1.0 << EOF
-+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
-+EOF
-+run_status_with_expected_output 'dkms_test' << EOF
-+dkms_test/1.0: added
-+EOF
-+
-+echo 'Removing dkms_test module'
-+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
-+Module dkms_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-+Module dkms_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-+Deleting module dkms_test-1.0 completely from the DKMS tree.
-+EOF
-+echo "Removing /usr/src/dkms_test-1.0"
-+rm -r /usr/src/dkms_test-1.0
-+echo "Deleting /usr/lib/os-release"
-+rm -f /usr/lib/os-release
-+
-+echo "Restoring /etc/os-release and /usr/bin/os-release"
-+osrelease_cleanup
-+trap - EXIT
-+
- echo 'Checking that the environment is clean again'
- check_no_dkms_test
-
---
-2.20.1
-
diff --git a/debian/patches/0016-fix-Properly-exit-process-if-function-distro_version.patch b/debian/patches/0016-fix-Properly-exit-process-if-function-distro_version.patch
deleted file mode 100644
index d074f27..0000000
--- a/debian/patches/0016-fix-Properly-exit-process-if-function-distro_version.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From 98fd2eb0b8b22a71ac25b10b3e8e9a4aed61be5a Mon Sep 17 00:00:00 2001
-From: Edwin Kofler
-Date: Fri, 1 Dec 2023 18:21:18 -0800
-Subject: [PATCH 16/19] fix: Properly exit process if function `distro_version`
- fails
-
-`distro_version` contains code that can run `exit`, which is supposed to
-exit the whole process. However, `distro_version` runs in a subshell.
-By default in Bash, this means that `exit` will only exit the subshell, and set `?`
-to that exit code. The rest of script will execute, despite the error.
-
-There are two ways to fix this:
-- Enable the POSIX shell option `errexit` for the entire script
-- Manually check for non-zero exit code and "cascade the error"
-
-The latter was chosen because it is a localized change that does not
-affect the behavior of the entire script.
----
- dkms.in | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/dkms.in b/dkms.in
-index 54a1010..d021cba 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -2325,7 +2325,7 @@ unset CC CXX CFLAGS CXXFLAGS LDFLAGS
- # Set important variables
- current_kernel=$(uname -r)
- current_os=$(uname -s)
--running_distribution=$(distro_version)
-+running_distribution=$(distro_version) || exit
- dkms_tree="/var/lib/dkms"
- source_tree="/usr/src"
- install_tree="/lib/modules"
---
-2.20.1
-
diff --git a/debian/patches/0017-man-Add-build-and-install-actions-to-force-descripti.patch b/debian/patches/0017-man-Add-build-and-install-actions-to-force-descripti.patch
deleted file mode 100644
index 0353f46..0000000
--- a/debian/patches/0017-man-Add-build-and-install-actions-to-force-descripti.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 7bf3beea267f57813e9d9f354da91b4a09bd7ac6 Mon Sep 17 00:00:00 2001
-From: Mart Frauenlob
-Date: Mon, 4 Dec 2023 13:37:08 +0100
-Subject: [PATCH 17/19] man: Add build and install actions to --force
- description
-
-Signed-off-by: Mart Frauenlob
----
- dkms.8.in | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/dkms.8.in b/dkms.8.in
-index ad34b4b..fa2b498 100644
---- a/dkms.8.in
-+++ b/dkms.8.in
-@@ -318,6 +318,8 @@ combinations on the other kernel.
- .TP
- .B \-\-force
- This option can be used in conjunction with
-+.B build, install
-+and
- .B ldtarball
- to force copying over of extant files.
- .TP
---
-2.20.1
-
diff --git a/debian/patches/0018-man-Document-the-force-version-override-option.patch b/debian/patches/0018-man-Document-the-force-version-override-option.patch
deleted file mode 100644
index b2d4435..0000000
--- a/debian/patches/0018-man-Document-the-force-version-override-option.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 98df2ebabc6e72dbbf18be391a5e47400bb4487c Mon Sep 17 00:00:00 2001
-From: Mart Frauenlob
-Date: Mon, 4 Dec 2023 14:03:28 +0100
-Subject: [PATCH 18/19] man: Document the --force-version-override option
-
-Signed-off-by: Mart Frauenlob
----
- dkms.8.in | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/dkms.8.in b/dkms.8.in
-index fa2b498..4908964 100644
---- a/dkms.8.in
-+++ b/dkms.8.in
-@@ -323,6 +323,10 @@ and
- .B ldtarball
- to force copying over of extant files.
- .TP
-+.B \-\-force\-version\-override
-+This option skips the checks whether the version of the module, which is
-+going to be installed, is newer than the already installed version.
-+.TP
- .B \-\-binaries\-only
- This option can be used in conjunction with
- .B mktarball
---
-2.20.1
-
diff --git a/debian/patches/0019-Fix-typo.patch b/debian/patches/0019-Fix-typo.patch
deleted file mode 100644
index aa3c083..0000000
--- a/debian/patches/0019-Fix-typo.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From ce6469b65c9fa9c5826444b550397a3821ede139 Mon Sep 17 00:00:00 2001
-From: Simone Caronni
-Date: Mon, 4 Dec 2023 20:57:14 +0100
-Subject: [PATCH 19/19] Fix typo
-
----
- dkms.8.in | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/dkms.8.in b/dkms.8.in
-index 4908964..a954d4f 100644
---- a/dkms.8.in
-+++ b/dkms.8.in
-@@ -321,7 +321,7 @@ This option can be used in conjunction with
- .B build, install
- and
- .B ldtarball
--to force copying over of extant files.
-+to force copying over existing files.
- .TP
- .B \-\-force\-version\-override
- This option skips the checks whether the version of the module, which is
---
-2.20.1
-
diff --git a/debian/patches/0020-do-not-label-skipped-module-builds-as-Error.patch b/debian/patches/0020-do-not-label-skipped-module-builds-as-Error.patch
deleted file mode 100644
index 3df258e..0000000
--- a/debian/patches/0020-do-not-label-skipped-module-builds-as-Error.patch
+++ /dev/null
@@ -1,111 +0,0 @@
-From 81d9fb6d350681491c54f17d4f232a6c80079af2 Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Fri, 24 Nov 2023 15:15:57 +0100
-Subject: [PATCH 20/26] do not label skipped module builds as 'Error!'
-
----
- dkms.in | 16 ++++++++++++++--
- run_test.sh | 24 ++++++++++++++++++------
- 2 files changed, 32 insertions(+), 8 deletions(-)
-
-diff --git a/dkms.in b/dkms.in
-index d021cba..a7d46f1 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -138,6 +138,16 @@ die() {
- [[ $die_is_fatal = yes ]] && exit $ret || return $ret
- }
-
-+# Print a warning message and die with the passed error code.
-+diewarn() {
-+ # $1 = error code to return with
-+ # rest = strings to print before we exit.
-+ ret=$1
-+ shift
-+ warn "$@"
-+ [[ $die_is_fatal = yes ]] && exit $ret || return $ret
-+}
-+
- mktemp_or_die() {
- local t
- t=$(mktemp "$@") && echo "$t" && return
-@@ -1014,8 +1024,10 @@ prepare_build()
- read_conf_or_die "$kernelver" "$arch"
-
- # Error out if build_exclude is set
-- [[ $build_exclude ]] && die 77 \
-- $"The $base_dir/dkms.conf for module $module includes a BUILD_EXCLUSIVE directive which does not match this kernel/arch/config."\
-+ [[ $build_exclude ]] && diewarn 77 \
-+ $"The $base_dir/dkms.conf"\
-+ $"for module $module includes a BUILD_EXCLUSIVE directive"\
-+ $"which does not match this kernel/arch/config."\
- $"This indicates that it should not be built."
-
- # Error out if source_tree is basically empty (binary-only dkms tarball w/ --force check)
-diff --git a/run_test.sh b/run_test.sh
-index c731892..90c6335 100755
---- a/run_test.sh
-+++ b/run_test.sh
-@@ -1366,7 +1366,9 @@ fi
- # Should this really fail?
- echo '(Not) building the build-exclusive test module'
- run_with_expected_error 77 dkms build -k "${KERNEL_VER}" -m dkms_build_exclusive_test -v 1.0 << EOF
--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/config.
-+Warning: 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/config.
- This indicates that it should not be built.
- EOF
- run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
-@@ -1375,7 +1377,9 @@ EOF
-
- echo "Running dkms autoinstall (1 x skip)"
- run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
--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/config.
-+Warning: 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/config.
- This indicates that it should not be built.
- dkms autoinstall on ${KERNEL_VER}/${KERNEL_ARCH} was skipped for dkms_build_exclusive_test
- EOF
-@@ -1393,7 +1397,9 @@ EOF
-
- echo "Running dkms autoinstall (1 x skip, 1 x pass)"
- run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
--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/config.
-+Warning: 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/config.
- This indicates that it should not be built.
-
- Building module:
-@@ -1441,7 +1447,9 @@ EOF
-
- echo "Running dkms autoinstall (1 x skip, 1 x fail, 1 x pass) (expected error)"
- run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}" << EOF
--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/config.
-+Warning: 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/config.
- This indicates that it should not be built.
-
- Building module:
-@@ -1510,9 +1518,13 @@ fi
-
- echo "Running dkms autoinstall (2 x skip, with dependency)"
- run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
--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/config.
-+Warning: 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/config.
- This indicates that it should not be built.
--Error! The /var/lib/dkms/dkms_build_exclusive_dependencies_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/dkms.conf for module dkms_build_exclusive_dependencies_test includes a BUILD_EXCLUSIVE directive which does not match this kernel/arch/config.
-+Warning: The /var/lib/dkms/dkms_build_exclusive_dependencies_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/dkms.conf
-+for module dkms_build_exclusive_dependencies_test includes a BUILD_EXCLUSIVE directive
-+which does not match this kernel/arch/config.
- This indicates that it should not be built.
- dkms autoinstall on ${KERNEL_VER}/${KERNEL_ARCH} was skipped for dkms_build_exclusive_test dkms_build_exclusive_dependencies_test
- EOF
---
-2.20.1
-
diff --git a/debian/patches/0021-only-enumerate-kernels-that-potentially-have-headers.patch b/debian/patches/0021-only-enumerate-kernels-that-potentially-have-headers.patch
deleted file mode 100644
index 18288c0..0000000
--- a/debian/patches/0021-only-enumerate-kernels-that-potentially-have-headers.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From b2b705940c3b3e0a1666a7758066e36a6e367d07 Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Fri, 24 Nov 2023 16:02:41 +0100
-Subject: [PATCH 21/26] only enumerate kernels that potentially have headers
- installed
-
-avoid noise
- Module build for kernel was skipped since the
- kernel headers for this kernel does not seem to be installed.
-on removed kernels that still have a nearly empty /lib/modules/
-(w/o a build symlink) remaining
----
- dkms_common.postinst | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/dkms_common.postinst b/dkms_common.postinst
-index 52fb3a4..18459ff 100644
---- a/dkms_common.postinst
-+++ b/dkms_common.postinst
-@@ -127,7 +127,7 @@ if [ -r /etc/dkms/framework.conf ]; then
- . /etc/dkms/framework.conf
- fi
-
--KERNELS=$(ls -v /lib/modules/ 2>/dev/null || true)
-+KERNELS=$(ls -dv /lib/modules/*/build 2>/dev/null | cut -d/ -f4 || true)
- CURRENT_KERNEL=$(uname -r)
-
- #We never want to keep an older version side by side to prevent conflicts
---
-2.20.1
-
diff --git a/debian/patches/0022-clean-up-after-depmod-if-modules.dep-is-empty.patch b/debian/patches/0022-clean-up-after-depmod-if-modules.dep-is-empty.patch
deleted file mode 100644
index c01991b..0000000
--- a/debian/patches/0022-clean-up-after-depmod-if-modules.dep-is-empty.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From 3decaea196648b60b923a649c3c82d3f2a12e4e5 Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Sat, 25 Nov 2023 00:23:22 +0100
-Subject: [PATCH 22/26] clean up after depmod if modules.dep is empty
-
-we just removed the last module from (no longer installed) kernel $1
-so do not leave stale depmod files around
----
- dkms.in | 7 +++++++
- 1 file changed, 7 insertions(+)
-
-diff --git a/dkms.in b/dkms.in
-index a7d46f1..095178a 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -334,6 +334,13 @@ do_depmod()
- else
- depmod -a "$1"
- fi
-+ if [ -f /lib/modules/$1/modules.dep ] && [ ! -s /lib/modules/$1/modules.dep ]; then
-+ # if modules.dep is empty, we just removed the last kernel module from
-+ # no longer installed kernel $1, so do not leave stale depmod files around
-+ rm -fv /lib/modules/$1/modules.{alias,dep,devname,softdep,symbols,*.bin}
-+ rmdir --ignore-fail-on-non-empty /lib/modules/$1
-+ test -d /lib/modules/$1 || echo $"Removed /lib/modules/$1"
-+ fi
- }
-
- # Grab distro information from os-release.
---
-2.20.1
-
diff --git a/debian/patches/0023-run_tests.sh-add-more-dkms-status-calls.patch b/debian/patches/0023-run_tests.sh-add-more-dkms-status-calls.patch
deleted file mode 100644
index a465c94..0000000
--- a/debian/patches/0023-run_tests.sh-add-more-dkms-status-calls.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From b4aca95c19d223699050400995ccd9c28df4f706 Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Tue, 5 Dec 2023 19:13:09 +0100
-Subject: [PATCH 23/26] run_tests.sh: add more dkms status calls
-
----
- run_test.sh | 14 ++++++++++++++
- 1 file changed, 14 insertions(+)
-
-diff --git a/run_test.sh b/run_test.sh
-index 90c6335..0405572 100755
---- a/run_test.sh
-+++ b/run_test.sh
-@@ -676,6 +676,9 @@ Running module version sanity check.
- depmod...
- dkms autoinstall on ${KERNEL_VER}/${KERNEL_ARCH} succeeded for dkms_test
- EOF
-+run_status_with_expected_output 'dkms_test' << EOF
-+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
-+EOF
-
- echo "Running dkms autoinstall for a kernel without headers installed (expected error)"
- run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}-noheaders" << EOF
-@@ -757,10 +760,15 @@ dkms.conf: Warning! Zero modules specified.
- dkms.conf: Warning! Zero modules specified.
- Creating symlink /var/lib/dkms/dkms_conf_test/1.0/source -> /usr/src/dkms_conf_test-1.0
- EOF
-+run_status_with_expected_output 'dkms_conf_test' << EOF
-+dkms_conf_test/1.0: added
-+EOF
-
- run_with_expected_output dkms remove --all -m dkms_conf_test -v 1.0 << EOF
- Deleting module dkms_conf_test-1.0 completely from the DKMS tree.
- EOF
-+run_status_with_expected_output 'dkms_conf_test' << EOF
-+EOF
-
- echo 'Testing add/build/install of a test module building zero kernel modules'
- run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_conf_test -v 1.0 << EOF
-@@ -973,6 +981,9 @@ EOF
- echo 'Removing /usr/src/dkms_multiver_test-1.0 /usr/src/dkms_multiver_test-2.0'
- rm -r /usr/src/dkms_multiver_test-1.0 /usr/src/dkms_multiver_test-2.0
-
-+echo 'Checking that the environment is clean again'
-+check_no_dkms_test
-+
- ############################################################################
- ### Testing dkms operations ...
- ############################################################################
-@@ -1553,6 +1564,9 @@ EOF
- echo 'Removing /usr/src/dkms_build_exclusive_test-1.0'
- rm -r /usr/src/dkms_build_exclusive_test-1.0
-
-+echo 'Checking that the environment is clean again'
-+check_no_dkms_test
-+
- ############################################################################
- ### Testing os-release detection ###
- ############################################################################
---
-2.20.1
-
diff --git a/debian/patches/0024-add-test-module-with-AUTOINSTALL.patch b/debian/patches/0024-add-test-module-with-AUTOINSTALL.patch
deleted file mode 100644
index 3486a1c..0000000
--- a/debian/patches/0024-add-test-module-with-AUTOINSTALL.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From c6404e2feeacbaceeb7dce99f81d226b1cf8b83d Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Tue, 5 Dec 2023 19:14:22 +0100
-Subject: [PATCH 24/26] add test module with AUTOINSTALL=""
-
----
- test/dkms_noautoinstall_test-1.0/Makefile | 7 ++++++
- test/dkms_noautoinstall_test-1.0/dkms.conf | 7 ++++++
- .../dkms_noautoinstall_test.c | 23 +++++++++++++++++++
- 3 files changed, 37 insertions(+)
- create mode 100644 test/dkms_noautoinstall_test-1.0/Makefile
- create mode 100644 test/dkms_noautoinstall_test-1.0/dkms.conf
- create mode 100644 test/dkms_noautoinstall_test-1.0/dkms_noautoinstall_test.c
-
-diff --git a/test/dkms_noautoinstall_test-1.0/Makefile b/test/dkms_noautoinstall_test-1.0/Makefile
-new file mode 100644
-index 0000000..3452b7e
---- /dev/null
-+++ b/test/dkms_noautoinstall_test-1.0/Makefile
-@@ -0,0 +1,7 @@
-+obj-m += dkms_noautoinstall_test.o
-+
-+all:
-+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
-+
-+clean:
-+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
-diff --git a/test/dkms_noautoinstall_test-1.0/dkms.conf b/test/dkms_noautoinstall_test-1.0/dkms.conf
-new file mode 100644
-index 0000000..f816acb
---- /dev/null
-+++ b/test/dkms_noautoinstall_test-1.0/dkms.conf
-@@ -0,0 +1,7 @@
-+PACKAGE_NAME="dkms_noautoinstall_test"
-+PACKAGE_VERSION="1.0"
-+BUILT_MODULE_NAME="dkms_noautoinstall_test"
-+
-+AUTOINSTALL=""
-+
-+DEST_MODULE_LOCATION="/kernel/extra"
-diff --git a/test/dkms_noautoinstall_test-1.0/dkms_noautoinstall_test.c b/test/dkms_noautoinstall_test-1.0/dkms_noautoinstall_test.c
-new file mode 100644
-index 0000000..93d0098
---- /dev/null
-+++ b/test/dkms_noautoinstall_test-1.0/dkms_noautoinstall_test.c
-@@ -0,0 +1,23 @@
-+#include
-+#include
-+#include
-+
-+#define DKMS_TEST_VER "1.0"
-+
-+MODULE_LICENSE("GPL");
-+MODULE_DESCRIPTION("A Simple dkms test module");
-+
-+static int __init dkms_test_init(void)
-+{
-+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
-+ return 0;
-+}
-+
-+static void __exit dkms_test_cleanup(void)
-+{
-+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
-+}
-+
-+module_init(dkms_test_init);
-+module_exit(dkms_test_cleanup);
-+MODULE_VERSION(DKMS_TEST_VER);
---
-2.20.1
-
diff --git a/debian/patches/0025-run-tests-on-the-AUTOINSTALL-module.patch b/debian/patches/0025-run-tests-on-the-AUTOINSTALL-module.patch
deleted file mode 100644
index 57b28f8..0000000
--- a/debian/patches/0025-run-tests-on-the-AUTOINSTALL-module.patch
+++ /dev/null
@@ -1,141 +0,0 @@
-From 2f8303691447010d81bd1a0dc096e2082da78687 Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Tue, 5 Dec 2023 19:15:20 +0100
-Subject: [PATCH 25/26] run tests on the AUTOINSTALL="" module
-
----
- run_test.sh | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++-
- 1 file changed, 102 insertions(+), 2 deletions(-)
-
-diff --git a/run_test.sh b/run_test.sh
-index 0405572..acc9575 100755
---- a/run_test.sh
-+++ b/run_test.sh
-@@ -20,6 +20,7 @@ export parallel_jobs=1
- # Temporary files, directories, and modules created during tests
- TEST_MODULES=(
- "dkms_test"
-+ "dkms_noautoinstall_test"
- "dkms_failing_test"
- "dkms_dependencies_test"
- "dkms_multiver_test"
-@@ -31,8 +32,9 @@ TEST_MODULES=(
- "dkms_build_exclusive_dependencies_test"
- )
- TEST_TMPDIRS=(
-- "/usr/src/dkms_test-1.0/"
-- "/usr/src/dkms_failing_test-1.0/"
-+ "/usr/src/dkms_test-1.0"
-+ "/usr/src/dkms_noautoinstall_test-1.0"
-+ "/usr/src/dkms_failing_test-1.0"
- "/usr/src/dkms_dependencies_test-1.0"
- "/usr/src/dkms_multiver_test-1.0"
- "/usr/src/dkms_multiver_test-2.0"
-@@ -717,6 +719,104 @@ rm -r /usr/src/dkms_test-1.0
- echo 'Checking that the environment is clean again'
- check_no_dkms_test
-
-+############################################################################
-+### Testing dkms on a regular module with AUTOINSTALL="" ###
-+############################################################################
-+
-+echo 'Adding the noautoinstall test module by directory'
-+run_with_expected_output dkms add test/dkms_noautoinstall_test-1.0 << EOF
-+Creating symlink /var/lib/dkms/dkms_noautoinstall_test/1.0/source -> /usr/src/dkms_noautoinstall_test-1.0
-+EOF
-+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
-+dkms_noautoinstall_test/1.0: added
-+EOF
-+if ! [[ -d /usr/src/dkms_noautoinstall_test-1.0 ]] ; then
-+ echo >&2 'Error: directory /usr/src/dkms_noautoinstall_test-1.0 was not created'
-+ exit 1
-+fi
-+
-+echo "Running dkms autoinstall"
-+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
-+EOF
-+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
-+dkms_noautoinstall_test/1.0: added
-+EOF
-+
-+echo 'Building the noautoinstall test module'
-+set_signing_message "dkms_noautoinstall_test" "1.0"
-+run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
-+
-+Building module:
-+Cleaning build area...
-+make -j1 KERNELRELEASE=${KERNEL_VER} -C /lib/modules/${KERNEL_VER}/build M=/var/lib/dkms/dkms_noautoinstall_test/1.0/build...
-+${SIGNING_MESSAGE}Cleaning build area...
-+EOF
-+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
-+dkms_noautoinstall_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
-+EOF
-+
-+echo 'Installing the noautoinstall test module'
-+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
-+
-+dkms_noautoinstall_test.ko${mod_compression_ext}:
-+Running module version sanity check.
-+ - Original module
-+ - No original module exists within this kernel
-+ - Installation
-+ - Installing to /lib/modules/${KERNEL_VER}/${expected_dest_loc}/
-+depmod...
-+EOF
-+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
-+dkms_noautoinstall_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
-+EOF
-+
-+echo 'Uninstalling the noautoinstall test module'
-+run_with_expected_output dkms uninstall -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
-+Module dkms_noautoinstall_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}).
-+Before uninstall, this module version was ACTIVE on this kernel.
-+
-+dkms_noautoinstall_test.ko${mod_compression_ext}:
-+ - Uninstallation
-+ - Deleting from: /lib/modules/${KERNEL_VER}/${expected_dest_loc}/
-+ - Original module
-+ - No original module was found for this module on this kernel.
-+ - Use the dkms install command to reinstall any previous module version.
-+EOF
-+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
-+dkms_noautoinstall_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
-+EOF
-+if [[ -e "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noautoinstall_test.ko${mod_compression_ext}" ]] ; then
-+ echo >&2 "Error: module not removed in /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noautoinstall_test.ko${mod_compression_ext}"
-+ exit 1
-+fi
-+
-+echo 'Unbuilding the noautoinstall test module'
-+run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
-+Module dkms_noautoinstall_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-+EOF
-+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
-+dkms_noautoinstall_test/1.0: added
-+EOF
-+
-+echo 'Removing the noautoinstall test module'
-+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
-+Module dkms_noautoinstall_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-+Module dkms_noautoinstall_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-+Deleting module dkms_noautoinstall_test-1.0 completely from the DKMS tree.
-+EOF
-+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
-+EOF
-+if ! [[ -d /usr/src/dkms_noautoinstall_test-1.0 ]] ; then
-+ echo >&2 'Error: directory /usr/src/dkms_noautoinstall_test-1.0 was removed'
-+ exit 1
-+fi
-+
-+echo 'Removing /usr/src/dkms_noautoinstall_test-1.0'
-+rm -r /usr/src/dkms_noautoinstall_test-1.0
-+
-+echo 'Checking that the environment is clean again'
-+check_no_dkms_test
-+
- ############################################################################
- ### Testing malformed/borderline dkms.conf ###
- ############################################################################
---
-2.20.1
-
diff --git a/debian/patches/0026-dkms_autoinstaller-improve-console-output.patch b/debian/patches/0026-dkms_autoinstaller-improve-console-output.patch
deleted file mode 100644
index 8ca3c4e..0000000
--- a/debian/patches/0026-dkms_autoinstaller-improve-console-output.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 20164939030ece840ec3cbf566fc6155512727eb Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Wed, 6 Dec 2023 01:14:44 +0100
-Subject: [PATCH 26/26] dkms_autoinstaller: improve console output
-
-dkms autoinstall may produce multiline output
----
- dkms_autoinstaller.in | 6 ++++--
- 1 file changed, 4 insertions(+), 2 deletions(-)
-
-diff --git a/dkms_autoinstaller.in b/dkms_autoinstaller.in
-index 10c9348..0d4e46c 100755
---- a/dkms_autoinstaller.in
-+++ b/dkms_autoinstaller.in
-@@ -71,9 +71,11 @@ case "$1" in
- elif ! _check_kernel_dir $kernel; then
- log_action_msg "$prog: autoinstall for kernel $kernel was skipped since the kernel headers for this kernel do not seem to be installed"
- else
-- log_daemon_msg "$prog: running auto installation service for kernel $kernel"
-+ log_action_msg "$prog: running auto installation service for kernel $kernel"
- dkms autoinstall --kernelver $kernel
-- log_end_msg $?
-+ res=$?
-+ log_daemon_msg "$prog: autoinstall for kernel" "$kernel"
-+ log_end_msg $res
- fi
- ;;
- stop|restart|force-reload|status|reload)
---
-2.20.1
-
diff --git a/debian/patches/0049-dkms-use-saner-compression-defaults.patch b/debian/patches/0049-dkms-use-saner-compression-defaults.patch
deleted file mode 100644
index 25cfc32..0000000
--- a/debian/patches/0049-dkms-use-saner-compression-defaults.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 66d9ecef16eab02665e89253d816e180041cb34d Mon Sep 17 00:00:00 2001
-From: Emil Velikov
-Date: Mon, 29 Jan 2024 17:05:46 +0000
-Subject: [PATCH 49/54] dkms: use saner compression defaults
-
-Currently our compression options vary from those used in upstream
-kernel. As of 6.8-rc2 upstream uses (ignoring force/rm input file etc):
-
- - gzip -9
- - xz --check=crc32 --lzma2=dict=1MiB
- Note: some older kernels lacked crc32 and/or used 2MiB
- - zstd -T0 (aka -3)
-
-With the higher dictionary size (xz) and compression size (20+ zstd)
-more memory is required for decompression. Which may be a problem if the
-kernel itself is responsible for the decompression (instead of kmod),
-since it uses a smaller/limited ram amount.
-
-Reduce the numbers of be compatible with upstream.
-
-Closes: https://github.com/dell/dkms/issues/386
-
-Signed-off-by: Emil Velikov
----
- dkms.in | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/dkms.in b/dkms.in
-index 90cc485..d2397f0 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -1154,9 +1154,9 @@ actual_build()
- if [ "$module_compressed_suffix" = ".gz" ]; then
- gzip -9f "$built_module" || compressed_module=""
- elif [ "$module_compressed_suffix" = ".xz" ]; then
-- xz -f "$built_module" || compressed_module=""
-+ xz --check=crc32 --lzma2=dict=1MiB -f "$built_module" || compressed_module=""
- elif [ "$module_compressed_suffix" = ".zst" ]; then
-- zstd -q -f -T0 -20 --ultra "$built_module" || compressed_module=""
-+ zstd -q -f -T0 -19 "$built_module" || compressed_module=""
- fi
- if [ -n "$compressed_module" ]; then
- cp -f "$compressed_module" "$base_dir/module/${dest_module_name[$count]}$module_suffix" >/dev/null
---
-2.20.1
-
diff --git a/debian/patches/1001-do-not-run-depmod-if-modules.dep-does-not-yet-exist.patch b/debian/patches/1001-do-not-run-depmod-if-modules.dep-does-not-yet-exist.patch
deleted file mode 100644
index 6c29629..0000000
--- a/debian/patches/1001-do-not-run-depmod-if-modules.dep-does-not-yet-exist.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 8fab3c1390e57a0a21aaaf85757334c783b94117 Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Wed, 6 Dec 2023 19:08:34 +0100
-Subject: [PATCH] do not run depmod if modules.dep does not yet exist
-
-i.e. only linux headers but no corresponding linux image is installed
----
- dkms.in | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/dkms.in b/dkms.in
-index 095178a..d9e2d35 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -329,6 +329,11 @@ do_depmod()
- if [ "${current_os}" != "Linux" ] ; then
- return
- fi
-+ if [[ ! -f $install_tree/$1/modules.dep ]]; then
-+ # if the corresponding linux image $1 is not installed
-+ # do not create modules.dep
-+ return
-+ fi
- if [[ -f /boot/System.map-$1 ]]; then
- depmod -a "$1" -F "/boot/System.map-$1"
- else
---
-2.20.1
-
diff --git a/debian/patches/1001-remove-trailing-whitespace.patch b/debian/patches/1001-remove-trailing-whitespace.patch
deleted file mode 100644
index 6d12070..0000000
--- a/debian/patches/1001-remove-trailing-whitespace.patch
+++ /dev/null
@@ -1,84 +0,0 @@
-From 0ed79841a3898fde8bbab673563ee672974c468b Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Fri, 18 Oct 2024 01:45:04 +0200
-Subject: [PATCH] remove trailing whitespace
-
----
- dkms.8.in | 4 ++--
- dkms.in | 16 ++++++++--------
- 2 files changed, 10 insertions(+), 10 deletions(-)
-
-diff --git a/dkms.8.in b/dkms.8.in
-index 5c829d9..634c697 100644
---- a/dkms.8.in
-+++ b/dkms.8.in
-@@ -333,8 +333,8 @@ combinations on the other kernel.
- .TP
- .B \-\-force
- This option can be used in conjunction with
--.B build, install
--and
-+.B build, install
-+and
- .B ldtarball
- to force copying over existing files.
- .TP
-diff --git a/dkms.in b/dkms.in
-index a8f2c6a..371290a 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -96,19 +96,19 @@ invoke_command()
- local cmd_mode="$4"
- local exitval=0
- local progresspid
--
-+
- [[ $verbose ]] && echo -e "$cmd" || echo -en "$cmd_description..."
-
- if [[ $cmd_mode == background && ! $verbose && $package_name != dkms*_test ]]; then
-- while true ; do
-+ while true ; do
- sleep 3
- echo -n "."
- done &
- progresspid=$!
- fi
-
-- if [[ -n "$cmd_output_file" ]]; then
-- ( eval "$cmd" ) >> "$cmd_output_file" 2>&1
-+ if [[ -n "$cmd_output_file" ]]; then
-+ ( eval "$cmd" ) >> "$cmd_output_file" 2>&1
- exitval=$?
- elif [[ -z "$cmd_output_file" && $cmd_mode == background && ! $verbose ]]; then
- ( eval "$cmd" ) >/dev/null 2>&1
-@@ -119,15 +119,15 @@ invoke_command()
- fi
-
- [ -n "$progresspid" ] && kill "$progresspid" >/dev/null 2>&1
--
-- if (( exitval > 0)); then
-+
-+ if (( exitval > 0 )); then
- echo -en "(bad exit status: $exitval)"
- # Print the failing command without the clunky redirection
- [[ ! $verbose ]] && echo -en "\nFailed command:\n$1"
- else
- echo " done."
- fi
--
-+
- return "$exitval"
- }
-
-@@ -1941,7 +1941,7 @@ make_tarball()
- die 6 "Failed to make tarball."
- fi
-
-- eval "$make_tarball_rm_temp_dir_name"
-+ eval "$make_tarball_rm_temp_dir_name"
- unset make_tarball_rm_temp_dir_name
- }
-
---
-2.39.5
-
diff --git a/debian/patches/1002-do_depmod-use-install_tree-instead-of-hardcoding-lib.patch b/debian/patches/1002-do_depmod-use-install_tree-instead-of-hardcoding-lib.patch
deleted file mode 100644
index 7338320..0000000
--- a/debian/patches/1002-do_depmod-use-install_tree-instead-of-hardcoding-lib.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From c14cc2c4bd47bb5bb323d3c8ede92347b33735ef Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Wed, 6 Dec 2023 19:14:56 +0100
-Subject: [PATCH] do_depmod: use $install_tree instead of hardcoding
- /lib/modules
-
----
- dkms.in | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/dkms.in b/dkms.in
-index d9e2d35..9484863 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -339,12 +339,12 @@ do_depmod()
- else
- depmod -a "$1"
- fi
-- if [ -f /lib/modules/$1/modules.dep ] && [ ! -s /lib/modules/$1/modules.dep ]; then
-+ if [ -f $install_tree/$1/modules.dep ] && [ ! -s $install_tree/$1/modules.dep ]; then
- # if modules.dep is empty, we just removed the last kernel module from
- # no longer installed kernel $1, so do not leave stale depmod files around
-- rm -fv /lib/modules/$1/modules.{alias,dep,devname,softdep,symbols,*.bin}
-- rmdir --ignore-fail-on-non-empty /lib/modules/$1
-- test -d /lib/modules/$1 || echo $"Removed /lib/modules/$1"
-+ rm -fv $install_tree/$1/modules.{alias,dep,devname,softdep,symbols,*.bin}
-+ rmdir --ignore-fail-on-non-empty $install_tree/$1
-+ test -d $install_tree/$1 || echo $"removed directory $install_tree/$1"
- fi
- }
-
---
-2.20.1
-
diff --git a/debian/patches/1002-initially-clear-variables-that-can-contain-cleanup-c.patch b/debian/patches/1002-initially-clear-variables-that-can-contain-cleanup-c.patch
deleted file mode 100644
index 300c362..0000000
--- a/debian/patches/1002-initially-clear-variables-that-can-contain-cleanup-c.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-From 4bc1a61cc942fe2d54462f2afc121064c11dd781 Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Fri, 18 Oct 2024 02:14:25 +0200
-Subject: [PATCH] initially clear variables that can contain cleanup code
-
----
- dkms.in | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/dkms.in b/dkms.in
-index 371290a..2815b53 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -81,6 +81,7 @@ on_exit()
- exit $exitcode_on_exit
- }
-
-+unset make_tarball_rm_temp_dir_name load_tarball_rm_temp_dir_name
- trap on_exit EXIT
-
- # Run a command that we may or may not want to be detailed about.
---
-2.39.5
-
diff --git a/debian/patches/1003-add-help-h-options.patch b/debian/patches/1003-add-help-h-options.patch
deleted file mode 100644
index 5d59511..0000000
--- a/debian/patches/1003-add-help-h-options.patch
+++ /dev/null
@@ -1,51 +0,0 @@
-From 8521870c3c0b97f3d0648648e9e199f9e1d0fbad Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Fri, 18 Oct 2024 02:23:02 +0200
-Subject: [PATCH] add --help / -h options
-
----
- dkms.8.in | 3 +++
- dkms.in | 6 +++++-
- 2 files changed, 8 insertions(+), 1 deletion(-)
-
-diff --git a/dkms.8.in b/dkms.8.in
-index 634c697..30e28e7 100644
---- a/dkms.8.in
-+++ b/dkms.8.in
-@@ -292,6 +292,9 @@ Quiet.
- .B \-V, \-\-version
- Prints the currently installed version of dkms and exits.
- .TP
-+.B \-h, \-\-help
-+Prints a short usage message and exits.
-+.TP
- .B \-c
- The location of the
- .I dkms.conf
-diff --git a/dkms.in b/dkms.in
-index 2815b53..93a080f 100644
---- a/dkms.in
-+++ b/dkms.in
-@@ -190,7 +190,7 @@ show_usage()
- echo " [--kernelsourcedir=source-location] [--rpm_safe_upgrade]"
- echo " [--dkmstree path] [--sourcetree path] [--installtree path]"
- echo " [--binaries-only] [--source-only] [--verbose]"
-- echo " [--no-depmod] [--modprobe-on-install] [-j number] [--version]"
-+ echo " [--no-depmod] [--modprobe-on-install] [-j number] [--version] [--help]"
- }
-
- VER()
-@@ -2532,6 +2532,10 @@ while (($# > 0)); do
- -j)
- read_arg parallel_jobs "$1" "$2" || shift
- ;;
-+ --help|-h)
-+ show_usage
-+ exit 0
-+ ;;
- -*)
- error " Unknown option: $1"
- show_usage
---
-2.39.5
-
diff --git a/debian/patches/1003-run_test.sh-get-mod_compression_ext-from-.config.patch b/debian/patches/1003-run_test.sh-get-mod_compression_ext-from-.config.patch
deleted file mode 100644
index 9061f0d..0000000
--- a/debian/patches/1003-run_test.sh-get-mod_compression_ext-from-.config.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From 3603b32882265f75959819b43c4e8ff97221d667 Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Thu, 28 Dec 2023 01:29:46 +0100
-Subject: [PATCH] run_test.sh: get mod_compression_ext from .config
-
----
- run_test.sh | 22 +++++++++++++++++++---
- 1 file changed, 19 insertions(+), 3 deletions(-)
-
-diff --git a/run_test.sh b/run_test.sh
-index d139003..1c4c05c 100755
---- a/run_test.sh
-+++ b/run_test.sh
-@@ -233,9 +233,22 @@ kmod_broken_hashalgo() {
- (( kmod_ver < 26 ))
- }
-
-+mod_compression_ext=
-+kernel_config="/lib/modules/${KERNEL_VER}/build/.config"
-+if [ -f "${kernel_config}" ]; then
-+ if grep -q "^CONFIG_MODULE_COMPRESS_NONE=y" "${kernel_config}" ; then
-+ mod_compression_ext=
-+ elif grep -q "^CONFIG_MODULE_COMPRESS_GZIP=y" "${kernel_config}" ; then
-+ mod_compression_ext=.gz
-+ elif grep -q "^CONFIG_MODULE_COMPRESS_XZ=y" "${kernel_config}" ; then
-+ mod_compression_ext=.xz
-+ elif grep -q "^CONFIG_MODULE_COMPRESS_ZSTD=y" "${kernel_config}" ; then
-+ mod_compression_ext=.zst
-+ fi
-+fi
-+
- # Compute the expected destination module location
- os_id="$(sed -n 's/^ID\s*=\s*\(.*\)$/\1/p' /etc/os-release | tr -d '"')"
--mod_compression_ext=
- case "${os_id}" in
- centos | fedora | rhel | ovm | almalinux)
- expected_dest_loc=extra
-@@ -244,12 +257,15 @@ case "${os_id}" in
- sles | suse | opensuse)
- expected_dest_loc=updates
- ;;
-- arch | debian | ubuntu | linuxmint)
-+ arch)
-+ expected_dest_loc=updates/dkms
-+ mod_compression_ext=
-+ ;;
-+ debian | ubuntu | linuxmint)
- expected_dest_loc=updates/dkms
- ;;
- alpine)
- expected_dest_loc=kernel/extra
-- mod_compression_ext=.gz
- ;;
- gentoo)
- expected_dest_loc=kernel/extra
---
-2.20.1
-
diff --git a/debian/patches/1004-common.postinst-source-etc-dkms-framework.conf.d-.co.patch b/debian/patches/1004-common.postinst-source-etc-dkms-framework.conf.d-.co.patch
deleted file mode 100644
index 9105e64..0000000
--- a/debian/patches/1004-common.postinst-source-etc-dkms-framework.conf.d-.co.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From f56a77d7bcd06a968eb37f64bffc599b67f39766 Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Fri, 18 Oct 2024 02:33:42 +0200
-Subject: [PATCH] common.postinst: source /etc/dkms/framework.conf.d/*.conf,
- too
-
----
- dkms_common.postinst.in | 8 +++++---
- 1 file changed, 5 insertions(+), 3 deletions(-)
-
-diff --git a/dkms_common.postinst.in b/dkms_common.postinst.in
-index 2c54058..e290028 100644
---- a/dkms_common.postinst.in
-+++ b/dkms_common.postinst.in
-@@ -114,9 +114,11 @@ if [ -f /etc/dkms/no-autoinstall ]; then
- fi
-
- # read framework configuration options
--if [ -r /etc/dkms/framework.conf ]; then
-- . /etc/dkms/framework.conf
--fi
-+for fwcf in /etc/dkms/framework.conf /etc/dkms/framework.conf.d/*.conf ; do
-+ if [ -f "$fwcf" ] && [ -r "$fwcf" ]; then
-+ . "$fwcf"
-+ fi
-+done
-
- KERNELS=$(ls -dv @MODDIR@/*/build 2>/dev/null | cut -d/ -f4 || true)
- CURRENT_KERNEL=$(uname -r)
---
-2.39.5
-
diff --git a/debian/patches/1004-use-bash-arrays-in-some-tests.patch b/debian/patches/1004-use-bash-arrays-in-some-tests.patch
deleted file mode 100644
index 7ab0826..0000000
--- a/debian/patches/1004-use-bash-arrays-in-some-tests.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From 30ce11253f6371a28864fc0faa80f72ae9f58130 Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Wed, 3 Jan 2024 12:07:33 +0100
-Subject: [PATCH] use bash arrays in some tests
-
----
- test/dkms_noautoinstall_test-1.0/dkms.conf | 6 ++----
- test/dkms_test-1.0/dkms.conf | 6 ++----
- 2 files changed, 4 insertions(+), 8 deletions(-)
-
-diff --git a/test/dkms_noautoinstall_test-1.0/dkms.conf b/test/dkms_noautoinstall_test-1.0/dkms.conf
-index f816acb..86ede1e 100644
---- a/test/dkms_noautoinstall_test-1.0/dkms.conf
-+++ b/test/dkms_noautoinstall_test-1.0/dkms.conf
-@@ -1,7 +1,5 @@
- PACKAGE_NAME="dkms_noautoinstall_test"
- PACKAGE_VERSION="1.0"
--BUILT_MODULE_NAME="dkms_noautoinstall_test"
--
-+BUILT_MODULE_NAME[0]="dkms_noautoinstall_test"
-+DEST_MODULE_LOCATION[0]="/kernel/extra"
- AUTOINSTALL=""
--
--DEST_MODULE_LOCATION="/kernel/extra"
-diff --git a/test/dkms_test-1.0/dkms.conf b/test/dkms_test-1.0/dkms.conf
-index 1009b95..b743154 100644
---- a/test/dkms_test-1.0/dkms.conf
-+++ b/test/dkms_test-1.0/dkms.conf
-@@ -1,7 +1,5 @@
- PACKAGE_NAME="dkms_test"
- PACKAGE_VERSION="1.0"
--BUILT_MODULE_NAME="dkms_test"
--
-+BUILT_MODULE_NAME[0]="dkms_test"
-+DEST_MODULE_LOCATION[0]="/kernel/extra"
- AUTOINSTALL="yes"
--
--DEST_MODULE_LOCATION="/kernel/extra"
---
-2.20.1
-
diff --git a/debian/patches/2001-do-not-perform-rpm-queries-on-Debian-Ubuntu-Arch-bas.patch b/debian/patches/2001-do-not-perform-rpm-queries-on-Debian-Ubuntu-Arch-bas.patch
deleted file mode 100644
index ec6b704..0000000
--- a/debian/patches/2001-do-not-perform-rpm-queries-on-Debian-Ubuntu-Arch-bas.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-From 0e69615135244378ade7063ea6da76c7d68474ba Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Wed, 19 Apr 2023 17:37:54 +0200
-Subject: [PATCH] do not perform rpm queries on Debian/Ubuntu/Arch based
- distributions
-
-Closes #329
----
- dkms.in | 15 +++++++++++++++
- 1 file changed, 15 insertions(+)
-
---- a/dkms.in
-+++ b/dkms.in
-@@ -312,6 +312,11 @@ setup_kernels_arches()
- kernelver[0]=$(uname -r)
- fi
- if [[ ! $arch ]]; then
-+ case "$running_distribution" in
-+ debian* | ubuntu* | arch*)
-+ arch[0]=$(uname -m)
-+ ;;
-+ *)
- kernelver_rpm=$(rpm -qf "$install_tree/$kernelver" 2>/dev/null | \
- grep -v "not owned by any package" | grep kernel | head -n 1)
- if ! arch[0]=$(rpm -q --queryformat "%{ARCH}" "$kernelver_rpm" 2>/dev/null); then
-@@ -320,6 +325,8 @@ setup_kernels_arches()
- arch[0]="ia32e"
- fi
- fi
-+ ;;
-+ esac
- fi
- if [[ ! $arch ]]; then
- die 12 "Could not determine architecture."
-@@ -1557,7 +1564,15 @@ do_uninstall()
- while [[ ${dir_to_remove} != ${dir_to_remove#/} ]]; do
- dir_to_remove="${dir_to_remove#/}"
- done
-+
-+ case "$running_distribution" in
-+ debian* | ubuntu* | arch*)
-+ (if cd "$install_tree/$1"; then rmdir -p --ignore-fail-on-non-empty "${dir_to_remove}"; fi || true)
-+ ;;
-+ *)
- (if cd "$install_tree/$1"; then rpm -qf "${dir_to_remove}" >/dev/null 2>&1 || rmdir -p --ignore-fail-on-non-empty "${dir_to_remove}"; fi || true)
-+ ;;
-+ esac
- else
- echo "Module was not found within $install_tree/$1/"
- fi
diff --git a/debian/patches/2002-fix-bug-when-dkms-status-original_module-exists.patch b/debian/patches/2002-fix-bug-when-dkms-status-original_module-exists.patch
deleted file mode 100644
index d7e5072..0000000
--- a/debian/patches/2002-fix-bug-when-dkms-status-original_module-exists.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From 3d1eb96107b3c8a6e9fd42c3b27c729d1d62fe19 Mon Sep 17 00:00:00 2001
-From: shaoyang
-Date: Fri, 7 Nov 2025 15:04:38 +0800
-Subject: [PATCH] fix bug when dkms status, (original_module exists)
-
-Signed-off-by: shaoyang
----
- kernel_prerm.d_dkms | 6 +++++-
- kernel_prerm.d_dkms.in | 10 +++++++---
- 2 files changed, 12 insertions(+), 4 deletions(-)
-
-diff --git a/kernel_prerm.d_dkms b/kernel_prerm.d_dkms
-index aeb8e3a..4ccc353 100755
---- a/kernel_prerm.d_dkms
-+++ b/kernel_prerm.d_dkms
-@@ -4,7 +4,11 @@
- inst_kern=$1
-
- if command -v dkms > /dev/null; then
-- dkms status -k "$inst_kern" 2>/dev/null | while IFS=",:/ " read -r name vers _ arch status; do
-+ dkms status -k "$inst_kern" 2>/dev/null | while IFS= read -r line; do
-+ name=$(echo "$line" | cut -d'/' -f1)
-+ vers=$(echo "$line" | cut -d'/' -f2 | cut -d',' -f1)
-+ arch=$(echo "$line" | awk -F', ' '{print $3}' | cut -d':' -f1)
-+ status=$(echo "$line" | awk -F': ' '{print $2}' | awk '{print $1}')
- [ "$status" = "installed" ] || continue
- echo "dkms: removing: $name $vers ($inst_kern) ($arch)" >&2
- dkms remove -m "$name" -v "$vers" -k "$inst_kern" -a "$arch"
-diff --git a/kernel_prerm.d_dkms.in b/kernel_prerm.d_dkms.in
-index cbf0c94..c30f2aa 100755
---- a/kernel_prerm.d_dkms.in
-+++ b/kernel_prerm.d_dkms.in
-@@ -5,9 +5,13 @@
- inst_kern=$1
-
- if command -v dkms > /dev/null; then
-- dkms status -k "$inst_kern" 2>/dev/null | while IFS=",:/ " read -r name vers _ arch status; do
-- [ "$status" = "installed" ] || continue
-- echo "dkms: removing: $name $vers ($inst_kern) ($arch)" >&2
-+ dkms status -k "$inst_kern" 2>/dev/null | while IFS= read -r line; do
-+ name=$(echo "$line" | cut -d'/' -f1)
-+ vers=$(echo "$line" | cut -d'/' -f2 | cut -d',' -f1)
-+ arch=$(echo "$line" | awk -F', ' '{print $3}' | cut -d':' -f1)
-+ status=$(echo "$line" | awk -F': ' '{print $2}' | awk '{print $1}')
-+ [ "$status" = "installed" ] || continue
-+ echo "dkms: removing: $name $vers ($inst_kern) ($arch)" >&2
- # Compromise on using 'unbuild' to remove the module when a
- # kernel is being removed. The 'remove' command is too
- # destructive. The 'uninstall' command leaves built files
---
-2.20.1
-
diff --git a/debian/patches/do-not-perform-rpm-queries-on-Debian-Ubuntu-Arch-bas.patch b/debian/patches/do-not-perform-rpm-queries-on-Debian-Ubuntu-Arch-bas.patch
deleted file mode 100644
index 3676da7..0000000
--- a/debian/patches/do-not-perform-rpm-queries-on-Debian-Ubuntu-Arch-bas.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-From 69463d6ccd991fe76524da56262f1a00e2123dae Mon Sep 17 00:00:00 2001
-From: Andreas Beckmann
-Date: Wed, 19 Apr 2023 17:37:54 +0200
-Subject: [PATCH] do not perform rpm queries on Debian/Ubuntu/Arch based
- distributions
-
-Closes #329
----
- dkms.in | 15 +++++++++++++++
- 1 file changed, 15 insertions(+)
-
---- a/dkms.in
-+++ b/dkms.in
-@@ -278,6 +278,11 @@ setup_kernels_arches()
- kernelver[0]=$(uname -r)
- fi
- if [[ ! $arch ]]; then
-+ case "$running_distribution" in
-+ debian* | ubuntu* | arch*)
-+ arch[0]=$(uname -m)
-+ ;;
-+ *)
- kernelver_rpm=$(rpm -qf "/lib/modules/$kernelver" 2>/dev/null | \
- grep -v "not owned by any package" | grep kernel | head -n 1)
- if ! arch[0]=$(rpm -q --queryformat "%{ARCH}" "$kernelver_rpm" 2>/dev/null); then
-@@ -286,6 +291,8 @@ setup_kernels_arches()
- arch[0]="ia32e"
- fi
- fi
-+ ;;
-+ esac
- fi
- if [[ ! $arch ]]; then
- die 12 $"Could not determine architecture."
-@@ -1530,7 +1537,15 @@ do_uninstall()
- while [ "${dir_to_remove}" != "${dir_to_remove#/}" ]; do
- dir_to_remove="${dir_to_remove#/}"
- done
-+
-+ case "$running_distribution" in
-+ debian* | ubuntu* | arch*)
-+ (if cd "$install_tree/$1"; then rmdir -p --ignore-fail-on-non-empty "${dir_to_remove}"; fi || true)
-+ ;;
-+ *)
- (if cd "$install_tree/$1"; then rpm -qf "${dir_to_remove}" >/dev/null 2>&1 || rmdir -p --ignore-fail-on-non-empty "${dir_to_remove}"; fi || true)
-+ ;;
-+ esac
- else
- echo $" - Module was not found within $install_tree/$1/"
- fi
diff --git a/debian/patches/no-CLEAN-deprecation-warning.patch b/debian/patches/no-CLEAN-deprecation-warning.patch
new file mode 100644
index 0000000..6601584
--- /dev/null
+++ b/debian/patches/no-CLEAN-deprecation-warning.patch
@@ -0,0 +1,15 @@
+Author: Andreas Beckmann
+Description: suppress the CLEAN deprecation warning for trixie
+Forwarded: not-needed
+
+--- a/dkms.in
++++ b/dkms.in
+@@ -577,7 +577,7 @@ safe_source() {
+ if (( ${#CLEAN[@]} )); then
+ case "$CLEAN" in
+ true|/bin/true|/usr/bin/true) ;;
+- *) deprecated "CLEAN ($to_source_file)" ;;
++# *) deprecated "CLEAN ($to_source_file)" ;;
+ esac
+ fi
+ (( ${#REMAKE_INITRD[@]} )) && deprecated "REMAKE_INITRD ($to_source_file)"
diff --git a/debian/patches/only-autobuild-AUTOINSTALL-yes-modules.patch b/debian/patches/only-autobuild-AUTOINSTALL-yes-modules.patch
deleted file mode 100644
index a1464bc..0000000
--- a/debian/patches/only-autobuild-AUTOINSTALL-yes-modules.patch
+++ /dev/null
@@ -1,16 +0,0 @@
---- a/dkms_common.postinst.in
-+++ b/dkms_common.postinst.in
-@@ -155,6 +155,13 @@ if [ -z "$autoinstall" ]; then
- exit 0
- fi
-
-+dkms_conf="/var/lib/dkms/$NAME/$VERSION/source/dkms.conf"
-+autoinstall=$(bash -c 'AUTOINSTALL=; . "'"$dkms_conf"'" >/dev/null 2>&1; echo $AUTOINSTALL')
-+if [ -z "$autoinstall" ]; then
-+ echo "Not building the $NAME module which does not have AUTOINSTALL enabled."
-+ exit 0
-+fi
-+
- # On 1st installation, let us look for a directory
- # in @MODDIR@ which matches $(uname -r). If none
- # is found it is possible that buildd is being used
diff --git a/debian/patches/rebuild-modules-on-header-upgrade.patch b/debian/patches/rebuild-modules-on-header-upgrade.patch
deleted file mode 100644
index c944d62..0000000
--- a/debian/patches/rebuild-modules-on-header-upgrade.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/kernel_postinst.d_dkms.in
-+++ b/kernel_postinst.d_dkms.in
-@@ -19,6 +19,19 @@ _check_kernel_dir() {
- header_pkg="linux-headers-$inst_kern"
- kernel="Linux"
-
-+case $0 in *header_postinst.d*)
-+ # unbuild all autoinstalled modules for this kernel to ensure they get
-+ # rebuilt against the updated headers by the next autoinstall below
-+ for mod_ver in $(dkms status -k "$inst_kern" 2>/dev/null | grep ': installed' | cut -d, -f1 | sort -u)
-+ do
-+ dkms_conf="/var/lib/dkms/$mod_ver/source/dkms.conf"
-+ autoinstall=$(bash -c 'AUTOINSTALL=; . "'"$dkms_conf"'" >/dev/null 2>&1; echo $AUTOINSTALL')
-+ test -n "$autoinstall" || continue
-+ dkms unbuild -k "$inst_kern" "$mod_ver"
-+ done
-+ ;;
-+esac
-+
- if [ -x @LIBDIR@/dkms_autoinstaller ]; then
- exec @LIBDIR@/dkms_autoinstaller start "$inst_kern"
- fi
diff --git a/debian/patches/series b/debian/patches/series
index ffb8da6..9f00bde 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,11 +1,5 @@
-0001-Remove-last-remnants-of-log_action_msg-from-dkms_aut.patch
-0002-Drop-GNU-kFreeBSD.patch
-
-1001-remove-trailing-whitespace.patch
-1002-initially-clear-variables-that-can-contain-cleanup-c.patch
-1003-add-help-h-options.patch
-1004-common.postinst-source-etc-dkms-framework.conf.d-.co.patch
-2001-do-not-perform-rpm-queries-on-Debian-Ubuntu-Arch-bas.patch
-2002-fix-bug-when-dkms-status-original_module-exists.patch
-rebuild-modules-on-header-upgrade.patch
-only-autobuild-AUTOINSTALL-yes-modules.patch
+0001-run_test.sh-show-make.log-on-unexpected-errors.patch
+0002-common.postinst-emit-a-warning-if-no-kernel-headers-.patch
+0003-common.postinst-fix-warning-message.patch
+0003-document-CLEAN-true.patch
+no-CLEAN-deprecation-warning.patch
diff --git a/debian/rules b/debian/rules
index e2ae425..cb34d3e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -20,7 +20,7 @@ override_dh_auto_build: debian/scripts/dh_dkms
override_dh_auto_build: debian/scripts/dh_dkms.1
override_dh_auto_install:
- $(MAKE) install-debian DESTDIR=$(CURDIR)/debian/dkms
+ $(MAKE) install-debian DESTDIR=$(CURDIR)/debian/tmp
execute_after_dh_install:
DH_AUTOSCRIPTDIR=debian/scripts debian/scripts/dh_dkms
diff --git a/debian/salsa-ci.yml b/debian/salsa-ci.yml
new file mode 100644
index 0000000..8424db4
--- /dev/null
+++ b/debian/salsa-ci.yml
@@ -0,0 +1,3 @@
+---
+include:
+ - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/recipes/debian.yml
diff --git a/debian/scripts/dkms-autopkgtest b/debian/scripts/dkms-autopkgtest
index 7444368..1d4d948 100755
--- a/debian/scripts/dkms-autopkgtest
+++ b/debian/scripts/dkms-autopkgtest
@@ -4,6 +4,9 @@
# Copyright: (C) 2014 Canonical Ltd.
set -eu
+# The i386 kernels are gone.
+test "$(dpkg --print-architecture)" = "i386" && exit 0
+
export DEBIAN_FRONTEND=noninteractive
result=0
@@ -32,7 +35,10 @@ check_for_linux_headers() {
# linux-doc is a dependency generated by autodep8 for autopkgtest-pkg-dkms
# install only linux-headers-* matching the source version of linux-doc
wanted_source_version=$(dpkg-query -f '${source:Version}' -W linux-doc 2>/dev/null || true)
- candidates=$(apt-cache search --names-only '^linux-headers-' | awk '{print $1}' | grep -v -E -e '-common(-rt)?$')
+ if ! candidates=$(apt-cache search --names-only '^linux-headers-' | awk '{print $1}' | grep -v -E -e '-common(-rt)?$'); then
+ echo "I: No Linux header packages seem to exist."
+ exit 77
+ fi
echo "I: No Linux header packages are installed."
echo "I: Installing all available ones from src:linux $wanted_source_version:"
for p in $candidates ; do
@@ -64,27 +70,34 @@ run_pkg() {
test -x /usr/bin/openssl || apt-get install --no-install-recommends -yq openssl &1
+ instpkg=$pkg
+ case "$pkg" in
+ /*.deb)
+ pkg=$(dpkg -f $pkg Package)
+ ;;
+ esac
+
echo "I: Removing binary package $pkg, to get clean state."
apt-get purge -yq $pkg &1 >/dev/null || true
- echo "I: Installing binary package $pkg"
+ echo "I: Installing binary package $instpkg"
RC=0
- apt-get install --no-install-recommends -yq $pkg &1 || RC=$?
+ apt-get install --no-install-recommends -yq $instpkg &1 || RC=$?
if [ "$RC" -ne 0 ]; then
- echo "E: Package $pkg failed to install." >&2
+ echo "E: Package $instpkg failed to install." >&2
result=1
return
fi
- # Try and remove dkms to spot packages which miss a dkms dependency
- echo "I: Checking for missing dkms dependency by trying to deinstall dkms"
- dpkg --remove dkms || true
-
if ! dkms_conf=$(dpkg -L $pkg | grep '/usr/src' | grep '/dkms.conf$'); then
echo "I: Package $pkg has no dkms.conf, skipping."
return
fi
+ # Try and remove dkms to spot packages which miss a dkms dependency
+ echo "I: Checking for missing dkms dependency by trying to deinstall dkms"
+ dpkg --remove dkms || true
+
check_for_linux_headers
echo "I: Testing binary package $pkg"
@@ -167,7 +180,7 @@ run_pkg() {
continue
fi
- if ! echo "$dkmsstatus" | grep -q "installed$"; then
+ if ! echo "$dkmsstatus" | grep -q -E 'installed( \(Original modules exist\))?$'; then
echo "E: not installed" >&2
summary="${summary}I: FAIL $dkms_pkg/$dkms_ver $kver${crlf}"
result=1
diff --git a/debian/tests/control b/debian/tests/control
index 61159ee..419d94e 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,5 +1,6 @@
Test-Command: sh debian/tests/run_test_wrapper.sh
Features: test-name=run_test.sh
+Architecture: !i386
Depends:
dkms,
openssl,
@@ -9,7 +10,20 @@ Restrictions:
allow-stderr,
needs-root,
breaks-testbed,
- skip-not-installable,
+
+Test-Command: umount /proc || exit 77 && sh debian/tests/run_test_wrapper.sh
+Features: test-name=run_test.sh_without_proc
+Architecture: !i386
+Depends:
+ dkms,
+ openssl,
+ linux-headers-generic
+ | linux-headers-rpi [armel]
+Restrictions:
+ allow-stderr,
+ needs-root,
+ breaks-testbed,
+ skippable,
# install some-dkms after linux-headers
Test-Command: apt-get install -yf dkms-test-dkms && dkms status
diff --git a/kernel_install.d_dkms.in b/debian_kernel_install.d.in
old mode 100755
new mode 100644
similarity index 100%
rename from kernel_install.d_dkms.in
rename to debian_kernel_install.d.in
diff --git a/debian_kernel_postinst.d.in b/debian_kernel_postinst.d.in
new file mode 100644
index 0000000..4988f9b
--- /dev/null
+++ b/debian_kernel_postinst.d.in
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# We're passed the version of the kernel being installed
+inst_kern=$1
+
+if [ -x @LIBDIR@/dkms_autoinstaller ]; then
+ exec @LIBDIR@/dkms_autoinstaller start "$inst_kern"
+fi
diff --git a/debian_kernel_preinst.d.in b/debian_kernel_preinst.d.in
new file mode 100644
index 0000000..bfc175d
--- /dev/null
+++ b/debian_kernel_preinst.d.in
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# This script is triggered when the kernel (linux-image) package is being
+# installed/upgraded. We're passed the version of the kernel being installed.
+inst_kern=$1
+
+if command -v dkms > /dev/null; then
+ dkms kernel_preinst -k "$inst_kern"
+fi
+
+exit 0
diff --git a/debian_kernel_prerm.d.in b/debian_kernel_prerm.d.in
new file mode 100644
index 0000000..038f68f
--- /dev/null
+++ b/debian_kernel_prerm.d.in
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# This script is triggered when the kernel (linux-image) package is being
+# removed. We're passed the version of the kernel being removed.
+inst_kern=$1
+
+if command -v dkms > /dev/null; then
+ dkms kernel_prerm -k "$inst_kern"
+fi
+
+exit 0
diff --git a/dkms.8.in b/dkms.8.in
index 5c829d9..4ad5f6b 100644
--- a/dkms.8.in
+++ b/dkms.8.in
@@ -105,7 +105,7 @@ the
.I \-k
option is not specified it builds for the currently running kernel and arch. All builds
occur in the directory
-.I /var/lib/dkms///build/.
+.I /var/lib/dkms///build/ .
If the module/module\-version combo has not been added, dkms will try to add it, and in that
case
.B build
@@ -190,8 +190,9 @@ Creates a tarball archive for the specified module/version of all files
in the DKMS tree for that module/version combination. This includes
the source and any built modules for kernels in the tree (as specified).
Otherwise, you can specify
-a singular kernel to archive only, or multiple kernels to archive
-(\-k kernel1/arch1 \-k kernel2/arch2). Optionally, you can use
+a singular kernel to archive only, or multiple kernels to archive (
+.I \-k kernel1/arch1 \-k kernel2/arch2
+). Optionally, you can use
.B \-\-archive
to specify the file that you would like to save this
tarball to. You can also specify
@@ -243,7 +244,7 @@ action may be used to re-add the module/version combination to dkms.
.YS
.IP "" 4
Attempt to install the latest revision of all modules that have been installed for other kernel revisions.
-dkms_autoinstaller is a stub that uses this action to perform its work.
+The DKMS autoinstaller service is a stub that uses this action to perform its work.
.SY generate_mok
.YS
.IP "" 4
@@ -276,15 +277,29 @@ system.
The system architecture to perform the action upon. It is optional if you pass it as part of the
.B \-k
option. If not specified, it assumes
-the arch of the currently running system (`uname \-m`). You can specify multiple
-arch parameters on the same command line by repeating the \-a argument with a
-different arch name. When multiple architectures are specified, there must
-be a 1:1 relationship between \-k arguments to \-a arguments. DKMS will then
-assume the first \-a argument aligns with the first \-k kernel and so on for the
-second, third, etc.
+the arch of the currently running system (
+.B uname \-m
+). You can specify multiple arch parameters on the same command line by repeating the
+.B \-a
+argument with a different architecture name. When multiple architectures are specified, there must
+be a 1:1 relationship between
+.B \-k
+arguments to
+.B \-a
+arguments. DKMS will then assume the first
+.B \-a
+argument aligns with the first
+.B \-k
+and so on for the second, third, etc.
-For example, if you were to specify: \-k kernel1 \-k kernel2 \-a i386 \-k kernel3 \-a i686 \-a x86_64,
-DKMS would process this as: kernel1-i386, kernel2-i686, kernel3-x86_64.
+For example, if you were to specify:
+.B \-k kernel1 \-k kernel2 \-a i386 \-k kernel3 \-a i686 \-a x86_64
+, DKMS would process this as:
+.B kernel1-i386
+,
+.B kernel2-i686
+,
+.B kernel3-x86_64.
.TP
.B \-q, \-\-quiet
Quiet.
@@ -292,29 +307,32 @@ Quiet.
.B \-V, \-\-version
Prints the currently installed version of dkms and exits.
.TP
+.B \-h, \-\-help
+.TP
.B \-c
The location of the
.I dkms.conf
file. This is needed for the add action and if not specified,
it is assumed to be located in
-.I /usr/src/\-/.
+.I /usr/src/\-/ .
See below for more information on the format of
.I dkms.conf.
.TP
-.B \-\-config
+.B \-\-config
During a
.B build
-this option is used to specify an alternate location for the kernel .config
-file which was used to compile that kernel. Normally,
+this option is used to specify an alternate location for the kernel
+.I include/config/auto.conf
+configuration file which contains that kernel configuration. Normally,
.B dkms
-uses the Red Hat standard location and config filenames located in
-.I /usr/src/linux\-/configs/.
-If the config for the kernel that you
-are building a module for is not located here or does not have the expected
-name in this location, you will need to tell
+is able to derive the location of the configuration file from the filesystem, but if there is a problem
+in the detection, you will need to tell
.B dkms
-where the necessary .config can be found so that your kernel can be properly
-prepared for the module build.
+where the necessary
+.I include/config/auto.conf file
+(or the legacy
+.I .config
+file) can be found so that your kernel can be properly prepared for the module build.
.TP
.B \-\-archive
This option is used during a
@@ -333,8 +351,8 @@ combinations on the other kernel.
.TP
.B \-\-force
This option can be used in conjunction with
-.B build, install
-and
+.B build, install
+and
.B ldtarball
to force copying over existing files.
.TP
@@ -449,45 +467,60 @@ above) will be considered the "original_module". As well, all copies of the same
module will be removed from your kernel tree and placed into
.I /var/lib/dkms//original_module/$kernelver/collisions
so that they can be *manually* accessible later. DKMS will never actually do anything
-with the modules found underneath the /collisions directory, and they will be stored there
-until you manually delete them.
+with the modules found underneath the
+.B /collisions
+directory, and they will be stored there until you manually delete them.
.SH DKMS.CONF
When performing an
.BR add ,
a proper
.I dkms.conf
-file must be found. A properly formatted conf file is essential
-for communicating to
-.B dkms
-how and where the module should be installed. While not all the directives
-are required, providing as many as possible helps to limit any ambiguity. Note
-that the
+file must be found. A properly formatted configuration file is essential
+for communicating to DKMS how and where the module should be installed.
+While not all the directives are required, providing as many as possible helps to limit any ambiguity.
+Note that
.I dkms.conf
-is really only a shell\-script of variable definitions which are then sourced in
-by the
+is really only a shell\-script of variable definitions which are then sourced in by the
.B dkms
-executable (of the format, DIRECTIVE="directive text goes here"). As well, the
-directives are case\-sensitive and should be given in
-.B ALL CAPS.
+executable (of the format,
+.I DIRECTIVE="directive text goes here"
+). As well, the directives are case\-sensitive and should be given in ALL CAPS.
It is important to understand that many of the DKMS directives are arrays whose index
values are tied together. These array associations can be considered families, and there
-are currently three such families of directive arrays. MAKE[#] and MAKE_MATCH[#] make up
-one family. PATCH[#] and PATCH_MATCH[#] make up the second family. The third and
-largest family consists of BUILT_MODULE_NAME[#], BUILT_MODULE_LOCATION[#], DEST_MODULE_NAME[#],
-DEST_MODULE_LOCATION[#] and STRIP[#]. When indexing these arrays when creating your
-dkms.conf, each family should start at index value 0.
+are currently three such families of directive arrays.
+.B MAKE[#]
+and
+.B MAKE_MATCH[#]
+make up one family.
+.B PATCH[#]
+and
+.B PATCH_MATCH[#]
+make up the second family. The third and largest family consists of
+.B BUILT_MODULE_NAME[#]
+,
+.B BUILT_MODULE_LOCATION[#]
+,
+.B DEST_MODULE_NAME[#]
+,
+.B DEST_MODULE_LOCATION[#]
+and
+.B STRIP[#] .
+When indexing these arrays when creating your
+.I dkms.conf
+, each family should start at index value 0.
.TP
.B PACKAGE_NAME=
This directive is used to give the name associated with the entire package of modules. This is the same
name that is used with the
.B \-m
-option when building, adding, etc. and may not necessarily be the same as the MODULE_NAME. This
-directive must be present in every dkms.conf.
+option when building, adding, etc. and may not necessarily be the same as the
+.B MODULE_NAME.
+This directive must be present in every DKMS configuration file.
.TP
.B PACKAGE_VERSION=
This directive is used to give the version associated with the entire package of modules being installed within that dkms
-package. This directive must be present in every dkms.conf.
+package. This directive must be present in every DKMS configuration file.
.TP
.B BUILT_MODULE_NAME[#]=
This directive gives the name of the module just after it is built. If your DKMS module
@@ -497,21 +530,38 @@ directive for all of the modules. This directive should explicitly not contain a
trailing ".o" or ".ko".
Note that for each module within a dkms package, the numeric value of
.B #
-must be the same for each of BUILT_MODULE_NAME, BUILT_MODULE_LOCATION, DEST_MODULE_NAME and
-DEST_MODULE_LOCATION and that the numbering should start at 0 (eg. BUILT_MODULE_NAME[0]="qla2200"
-BUILT_MODULE_NAME[1]="qla2300").
+must be the same for each of
+.B BUILT_MODULE_NAME
+,
+.B BUILT_MODULE_LOCATION
+,
+.B DEST_MODULE_NAME
+and
+.B DEST_MODULE_LOCATION
+and that the numbering should start at 0 (eg.
+.B BUILT_MODULE_NAME[0]="qla2200" BUILT_MODULE_NAME[1]="qla2300"
+).
.TP
.B BUILT_MODULE_LOCATION[#]=
This directive tells DKMS where to find your built module after it has been built. This
pathname should be given relative to the root directory of your source files (where your
-dkms.conf file can be found). If unset, DKMS expects to find your
+.I dkms.conf
+file can be found). If unset, DKMS expects to find your
.B BUILT_MODULE_NAME[#]
in the root directory of your source files.
Note that for each module within a dkms package, the numeric value of
.B #
-must be the same for each of BUILT_MODULE_NAME, BUILT_MODULE_LOCATION, DEST_MODULE_NAME and
-DEST_MODULE_LOCATION and that the numbering should start at 0 (eg. BUILT_MODULE_LOCATION[0]="some/dir/"
-BUILT_MODULE_LOCATION[1]="other/dir/").
+must be the same for each of
+.B BUILT_MODULE_NAME
+,
+.B BUILT_MODULE_LOCATION
+,
+.B DEST_MODULE_NAME
+and
+.B DEST_MODULE_LOCATION
+and that the numbering should start at 0 (eg.
+.B BUILT_MODULE_LOCATION[0]="some/dir/" BUILT_MODULE_LOCATION[1]="other/dir/"
+).
.TP
.B DEST_MODULE_NAME[#]=
This directive can be used to specify the name of the module as it should be installed. This
@@ -524,29 +574,51 @@ assumed to be the same value as
.B BUILT_MODULE_NAME[#].
Note that for each module within a dkms package, the numeric value of
.B #
-must be the same for each of BUILT_MODULE_NAME, BUILT_MODULE_LOCATION, DEST_MODULE_NAME and
-DEST_MODULE_LOCATION and that the numbering should start at 0 (eg. DEST_MODULE_NAME[0]="qla2200_6x"
-DEST_MODULE_NAME[1]="qla2300_6x").
+must be the same for each of
+.B BUILT_MODULE_NAME
+,
+.B BUILT_MODULE_LOCATION
+,
+.B DEST_MODULE_NAME
+and
+.B DEST_MODULE_LOCATION
+and that the numbering should start at 0 (eg.
+.B DEST_MODULE_NAME[0]="qla2200_6x" DEST_MODULE_NAME[1]="qla2300_6x"
+).
.TP
.B DEST_MODULE_LOCATION[#]=
This directive specifies the destination where a module should be installed to, once compiled. It also
is used for finding original_modules. This is a
.B required
directive, except as noted below. This directive must start with the text "/kernel" which is in reference to
-@MODDIR@//kernel.
+.I @MODDIR@//kernel.
Note that for each module within a dkms package, the numeric value of
.B #
-must be the same for each of BUILT_MODULE_NAME, BUILT_MODULE_LOCATION, DEST_MODULE_NAME and
-DEST_MODULE_LOCATION and that the numbering should start at 0 (eg. DEST_MODULE_LOCATION[0]="/kernel/drivers/something/"
-DEST_MODULE_LOCATION[1]="/kernel/drivers/other/").
+must be the same for each of
+.B BUILT_MODULE_NAME
+,
+.B BUILT_MODULE_LOCATION
+,
+.B DEST_MODULE_NAME
+and
+.B DEST_MODULE_LOCATION
+and that the numbering should start at 0 (eg.
+.B DEST_MODULE_LOCATION[0]="/kernel/drivers/something/" DEST_MODULE_LOCATION[1]="/kernel/drivers/other/"
+).
-DEST_MODULE_LOCATION is ignored on Fedora and Red Hat Enterprise Linux, Novell SuSE Linux Enterprise Server 10
-and higher, Novell SuSE Linux 10.0 and higher, and Ubuntu. Instead, the proper distribution-specific directory is used.
+.B DEST_MODULE_LOCATION
+is ignored on Fedora, Red Hat Enterprise Linux, SuSE Linux Enterprise Server, openSUSE and Ubuntu.
+Instead, the proper distribution-specific directory is used.
.TP
.B STRIP[#]=
By default strip is considered to be "yes". If set to "no", DKMS will not
-run strip \-g against your built module to remove debug symbols from it.
-STRIP[0] is used as the default for any unset entries in the STRIP array.
+run strip
+.B \-g
+against your built module to remove debug symbols from it.
+.B STRIP[0]
+is used as the default for any unset entries in the
+.B STRIP
+array.
.TP
.B MAKE[#]=
The MAKE directive array tells DKMS which make command should be used for building your module. The default make command
@@ -568,12 +640,16 @@ if MAKE[0] should be used to build the module for that kernel. If multiple
.B MAKE_MATCH
directives match against the kernel being built for, the last matching
.B MAKE[#]
-will be used to build your module. If no MAKE directive is specified or if no
-MAKE_MATCH matches the kernel being built for, DKMS
-will attempt to use a generic MAKE command to build your module.
+will be used to build your module. If no
+.B MAKE
+directive is specified or if no
+.B MAKE_MATCH
+matches the kernel being built for, DKMS will attempt to use a generic make command to build your module.
-KERNELRELEASE will be automatically appended to MAKE[#]. If you want to
-suppress this behavior, you can quote the make command: 'make'.
+.B KERNELRELEASE=$kernelver -j$parallel_jobs
+will be automatically appended to
+.B MAKE[#].
+If you want to suppress this behavior, you can quote the make command: 'make'.
.TP
.B MAKE_MATCH[#]=
See the above entry on
@@ -585,20 +661,14 @@ to use the corresponding make command in the
.B MAKE[#]
directive array to build your module.
.TP
-.B CLEAN=
-CLEAN specifies the make clean command to be used to clean up both before and after building the
-module. If unset, it is assumed to be "make clean".
-.TP
.B NO_WEAK_MODULES=
The
.B NO_WEAK_MODULES
-parameter prevents dkms from creating a symlink into the weak-updates directory, which is the
-default on Red Hat derivatives. The weak modules facility was designed to eliminate the need to
-rebuild kernel modules when kernel upgrades occur and relies on the symbols within the kABI.
-
-Fedora does not guaranteed a stable kABI so it should be disabled in the specific module override by setting it to "yes". For example, for an Nvidia DKMS module you would set the following in /etc/dkms/nvidia.conf:
+directive, when set to "yes", prevents dkms from creating a symlink into the
+.B weak-updates
+directory. The weak modules facility was designed to eliminate the need to rebuild kernel modules when kernel upgrades occur and relies on the symbols within the kABI. Valid values are "yes" or "no".
-NO_WEAK_MODULES="yes"
+The kABI kernel module interface is currently supported on Red Hat Enterprise Linux (and derivatives), SUSE Linux Enterprise Server and openSUSE Leap; on other distributions this directive is ignored.
.TP
.B OBSOLETE_BY=
This directive allows you to specify a kernel version that obsoletes the necessity for this
@@ -606,6 +676,12 @@ particular DKMS module. This can be specified as a particular upstream kernel or
bump of a kernel. For example, "2.6.24" would be an upstream kernel and "2.6.24\-16" would
represent an ABI bump for a kernel. Both are valid in this area.
+Please consider using
+.B BUILD_EXCLUSIVE_KERNEL_MAX
+instead of
+.B OBSOLETE_BY
+as the former is a more general approach to solve the same problem.
+
Please avoid the use of
.B OBSOLETE_BY
wherever possible. It's use indicates a lack of proper module
@@ -622,14 +698,18 @@ is meaningful only in the context of a single distribution/version.
.TP
.B PATCH[#]=
Use the PATCH directive array to specify patches which should be applied to your source before a build occurs.
-All patches are expected to be in \-p1 format and are applied with the patch \-p1 command.
+All patches are expected to be in
+.B \-p1
+format and are applied with the patch
+.B \-p1
+command.
Each directive should specify the filename of the patch to apply, and all patches must
be located in the patches subdirectory of your source directory (
.I /usr/src/\-/patches/
). If any patch fails to apply, the build will be halted and the rejections can be
inspected in
.I /var/lib/dkms///build/.
-If a PATCH should only be applied conditionally, the
+If a patch should only be applied conditionally, the
.B PATCH_MATCH[#]
array should be used, and a corresponding regular expression should be placed in
.B PATCH_MATCH[#]
@@ -648,22 +728,35 @@ the kernels you intend the corresponding
to be applied to before building that module.
.TP
.B AUTOINSTALL=
-If this directive is set to
-.B yes
-then the service
-.I /etc/rc.d/init.d/dkms_autoinstaller
-will automatically try to install this module on any kernel you boot into. See the section
-on
-.B dkms_autoinstaller
-for more information.
+If this directive is set to "yes" then the DKMS autoinstaller service
+will automatically try to install this module on any kernel you boot into.
+See the section on
+.B DKMS AUTOINSTALLER
+for more information. Valid values are "yes" or "no".
.TP
.B BUILD_DEPENDS[#]=
This optional directive is an array that allows you to specify other modules as
dependencies for your module. Each array element should be the
.B PACKAGE_NAME
of another module that is managed by dkms. Do not specify a version or
-architecture in the dependency. Note that this directive is only advisory;
-missing or broken dependencies cause non-fatal warnings.
+architecture in the dependency. A missing dependency requires the parameter
+.OP --force
+to still attempt the build of the module.
+.TP
+.B BUILD_DEPENDS_REBUILD=
+If this directive is set to
+.B yes
+then the module which has
+.B BUILD_DEPENDS
+being set, will get rebuilt every time a dependency changes version. This is usually provided in a specific
+.I /etc/dkms/.conf
+on a per installation basis.
+
+To keep track of the dependency change, the version of the module that was used at build time is recorded in the file
+.I /var/lib/dkms//-/.dep_.
+As soon as the module version changes, this is compared and the dependent module is rebuilt. With the parameter
+.I --force
+the dependency is not tracked.
.TP
.B BUILD_EXCLUSIVE_KERNEL=
This optional directive allows you to specify a regular expression which defines
@@ -671,9 +764,10 @@ the subset of kernels which DKMS is allowed to build your module for.
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.
+directive), the build will error out with exit code 77.
+Note that
+.B 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
@@ -740,16 +834,14 @@ is performed. The path should be given relative to the root directory
of your source. If the script exits with a non\-zero value, the
install will be aborted. This is typically used to perform a custom
version comparison.
-.TP
+.PP
.SH DKMS.CONF VARIABLES
-Within your
-.I dkms.conf
-file, you can use certain variables which will be replaced at run\-time with their
-values.
+Within your DKMS configuration file, you can use certain variables which will be replaced at run\-time with their values.
.TP
.B $kernelver
This variable can be used within a directive definition and during use, the actual kernel
-version in question will be substituted in its place. This is especially useful in MAKE
+version in question will be substituted in its place. This is especially useful in
+.B MAKE
commands when specifying which INCLUDE statements should be used when compiling your
module (eg. MAKE="make all INCLUDEDIR=@MODDIR@/${kernelver}/build/include").
.TP
@@ -761,9 +853,11 @@ unless otherwise specified with the
.B \-\-kernelsourcedir
option.
.SH DKMS.CONF OVERRIDES
-You can override the module-provided
+You can override directives provided in the module-provided
.I dkms.conf
-files. Every time after a dkms.conf file is read, dkms will look for and read the following files in order:
+files. Every time after a
+.I dkms.conf
+file is read, dkms will look for and read the following files in order:
.PP
.I /etc/dkms/.conf
.br
@@ -773,61 +867,120 @@ files. Every time after a dkms.conf file is read, dkms will look for and read th
.br
.I /etc/dkms/\-\-\-.conf
.PP
-You can use these files to override settings in the module-provided dkms.conf files.
-.SH /etc/dkms/framework.conf
-This configuration file controls how the overall DKMS framework handles. It is sourced
-in every time the dkms command is run. Mainly it can currently be used to set different
-default values for the variables.
+You can use these files to override settings in the module-provided
+.I dkms.conf
+file.
+.SH FRAMEWORK.CONF MAIN CONFIGURATION
+The
+.B /etc/dkms/framework.conf
+configuration file controls how the overall DKMS framework handles. It is sourced
+in every time the
+.B dkms
+command is run. Mainly it can currently be used to set different default values for the variables.
The file contains descriptions for each directive it supports.
-Additionally to /etc/dkms/framework.conf,
-.B any file matching the glob
-/etc/dkms/framework.conf.d/*.conf will be loaded as well.
+Additionally to
+.B /etc/dkms/framework.conf
+, any file matching the glob
+.B /etc/dkms/framework.conf.d/*.conf
+will be loaded as well.
.TP
-.B $dkms_tree, $source_tree, $install_tree, $tmp_location
+.B dkms_tree, source_tree, install_tree, tmp_location
Control which folders DKMS uses for components and artifacts.
.TP
-.B $verbose
+.B verbose
Can be set to anything but a null value to enable verbose output of external commands executed in DKMS.
.TP
-.B $symlink_modules
+.B symlink_modules
Controls whether binary modules are copied to @MODDIR@ or if only symlinks are created there. Note that these variables can also
-be manipulated on the command line with \-\-dkmstree, \-\-sourcetree, \-\-installtree
-and \-\-symlink-modules options.
+be manipulated on the command line with
+.B \-\-dkmstree
+,
+.B \-\-sourcetree
+,
+.B \-\-installtree
+and
+.B \-\-symlink-modules
+options.
.TP
-.B $autoinstall_all_kernels
+.B autoinstall_all_kernels
Used by the common postinst for DKMS modules. It controls if the build should be done for all installed kernels or only for the current and latest installed kernel. It has no command
line equivalent.
.TP
-.B $sign_file
+.B sign_file
This is the path of the
-.I sign-file
+.B sign-file
kernel binary that is used to sign the kernel modules. The variable
.B $kernelver
can be used in path to represent the target kernel version. The path for the binary depends on the distribution.
.TP
-.B $mok_signing_key, $mok_certificate
+.B mok_signing_key, mok_certificate
Location of the key and certificate files used for Secure boot. The variable
.B $kernelver
can be used in path to represent the target kernel version.
-NOTE: If any of the files specified by $mok_signing_key and
-$mok_certificate are non-existant, dkms will re-create both files.
+NOTE: If any of the files specified by
+.B mok_signing_key
+and
+.B mok_certificate
+are non-existant, dkms will re-create both files.
-.I mok_signing_key
-can also be a "pkcs11:..." string for PKCS#11 engine, as long as the sign_file program supports it.
+.B mok_signing_key
+can also be a "pkcs11:..." string for PKCS#11 engine, as long as the
+.B sign-file
+program supports it.
.TP
-.B $modprobe_on_install
+.B modprobe_on_install
Automatically load the built modules upon successful installation.
.TP
-.B $parallel_jobs
+.B parallel_jobs
Run no more than this number of jobs in parallel.
-.SH dkms_autoinstaller
-This boot\-time service automatically installs any module which has
+.TP
+.B compress_gzip_opts, compress_xz_opts, compress_zstd_opts
+Control how modules are compressed. By default, the highest available level of compression is used.
+.TP
+.B post_transaction
+If the directive is set to any non null-value, the content of the directive will be executed with any command that change the content of the kernel modules folder, that is
+.B dkms autoinstall, dkms install
+and
+.B dkms remove/unbuild/uninstall.
+Can be used to trigger a global
+.B initrd
+rebuild or to call a script that performs some other tasks (calling
+.B kexec,
+triggering the restart of services not contained in a DKMS package, etc.). The command is constructed with the shell built-in
+.B eval
+and the variable
+.B $kernelver
+can be used to represent the target kernel version. Some examples:
+
+Regenerate the ram disk for the target kernel:
+.B post_transaction="dracut --force --kver $kernelver"
+(Red Hat style) or
+.B post_transaction="update-initramfs -k $kernelver"
+(Debian style).
+
+Launch an arbitrary script:
+.B post_transaction="/path/to/script.sh"
+
+Restart a service:
+.B post_transaction="systemctl restart something.service"
+
+Regenerate the ram disk for all installed kernels, ignoring the kernel version passed as the parameter:
+.B post_transaction="dracut --force --regenerate-all"
+(Red Hat style) or
+.B post_transaction="update-initramfs -k all"
+(Debian style).
+.SH DKMS AUTOINSTALLER
+The DKMS autoinstaller service (which can be
+.B dkms_autoinstaller
+or
+.B dkms.service
+depending on your distribution) is a boot\-time service automatically installs any module which has
.B AUTOINSTALL="yes"
set in its
-.B dkms.conf
+.I dkms.conf
file. The service works quite simply and if multiple versions of a module are in
your system's DKMS tree, it will not do anything and instead explain that manual
intervention is required.
diff --git a/dkms.bash-completion b/dkms.bash-completion
deleted file mode 100644
index 4bff927..0000000
--- a/dkms.bash-completion
+++ /dev/null
@@ -1,112 +0,0 @@
-# bash completion for dkms
-# Copied from the Mandriva dkms package
-
-# This function complete on available kernels
-#
-_kernels()
-{
- COMPREPLY=( $( cd /lib/modules && compgen -d -- "$cur" ) )
-}
-
-# complete on full directory names under $1
-_subdirectories()
-{
- COMPREPLY=( $( cd $1 && compgen -d -- "$cur" ) )
-}
-
-# complete on $2 part of filenames matching pattern $1 under /usr/src
-_filename_parts()
-{
- COMPREPLY=( $( command ls -F /usr/src/ 2>/dev/null | grep -E '^'$1'/$' \
- | sed -r -e 's/^([^-]+)-(.+)\/$/\'$2'/' | grep "^$cur" ) )
-}
-
-_dkms()
-{
- local cur prev command module i
-
- COMPREPLY=()
- cur=${COMP_WORDS[COMP_CWORD]}
-
- if [[ $COMP_CWORD -eq 1 ]] ; then
- COMPREPLY=( $( compgen -W "add autoinstall remove build unbuild install uninstall \
- match mktarball ldtarball \
- status" -- $cur ) )
- else
-
- prev=${COMP_WORDS[COMP_CWORD-1]}
- command=${COMP_WORDS[1]}
- case $prev in
- -m)
- if [ "$command" = 'add' ]; then
- _filename_parts '.*-.*' 1
- else
- _subdirectories /var/lib/dkms
- fi
- return 0
- ;;
- -v)
- for (( i=1; i < COMP_CWORD; i++ )); do
- if [[ "${COMP_WORDS[i]}" == -m ]]; then
- module=${COMP_WORDS[i+1]}
- break
- fi
- done
- if [ -n "$module" ]; then
- if [ "$command" = 'add' ]; then
- _filename_parts "$module-.*" 2
- else
- _subdirectories /var/lib/dkms/$module
- fi
- return 0
- fi
- ;;
- -k)
- _kernels
- return 0
- ;;
- -@\(c|-spec|-archive|-config\))
- _filedir
- return 0
- ;;
- --kernelsourcedir)
- _filedir -d
- return 0
- ;;
- esac
-
-
- if [[ "$cur" == -* ]]; then
- case $command in
- add)
- options='-c --rpm_safe_upgrade'
- ;;
- remove)
- options='--rpm_safe_upgrade'
- ;;
- build)
- options='--config --force'
- ;;
- install)
- options='--force'
- ;;
- ldtarball)
- options='--archive --force'
- ;;
- mktarball)
- options='--source-only --binaries-only'
- ;;
- match)
- options='--templatekernel'
- ;;
- esac
-
- options="$options -m -v -k -a --arch -q --quiet -V \
- --version --all --kernelsourcedir \
- --directive"
-
- COMPREPLY=( $( compgen -W "$options" -- $cur ) )
- fi
- fi
-}
-complete -F _dkms dkms
diff --git a/dkms.bash-completion.in b/dkms.bash-completion.in
index 9374e29..e35ae3c 100644
--- a/dkms.bash-completion.in
+++ b/dkms.bash-completion.in
@@ -17,8 +17,10 @@ _subdirectories()
# complete on $2 part of filenames matching pattern $1 under /usr/src
_filename_parts()
{
- COMPREPLY=( $( command ls -F /usr/src/ 2>/dev/null | grep -E '^'$1'/$' \
- | sed -r -e 's/^([^-]+)-(.+)\/$/\'$2'/' | grep "^$cur" ) )
+ # shellcheck disable=SC1003
+ # TODO: figure out what is going on here
+ COMPREPLY=( $( command ls -F /usr/src/ 2>/dev/null | grep -E '^'"$1"'/$' \
+ | sed -r -e 's/^([^-]+)-(.+)\/$/\'"$2"'/' | grep "^$cur" ) )
}
_dkms()
@@ -31,13 +33,13 @@ _dkms()
if [[ $COMP_CWORD -eq 1 ]] ; then
COMPREPLY=( $( compgen -W "add remove build unbuild install uninstall autoinstall \
match mktarball ldtarball generate_mok \
- status" -- $cur ) )
+ status" -- "$cur" ) )
else
prev=${COMP_WORDS[COMP_CWORD-1]}
command=${COMP_WORDS[1]}
case $prev in
-a)
- COMPREPLY=( $( compgen -W "$(uname -m)" -- $cur ) )
+ COMPREPLY=( $( compgen -W "$(uname -m)" -- "$cur" ) )
return 0
;;
-m)
@@ -59,7 +61,7 @@ _dkms()
if [ "$command" = 'add' ]; then
_filename_parts "$module-.*" 2
else
- _subdirectories /var/lib/dkms/$module
+ _subdirectories "/var/lib/dkms/$module"
fi
return 0
fi
@@ -123,7 +125,7 @@ _dkms()
--version --all --kernelsourcedir \
--directive"
- COMPREPLY=( $( compgen -W "$options" -- $cur ) )
+ COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
fi
fi
}
diff --git a/dkms.in b/dkms.in
index 1cd55b1..834bb2d 100644
--- a/dkms.in
+++ b/dkms.in
@@ -20,12 +20,71 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
+# Exit status values and error messages used by dkms:
+# (as parameters to die, diewarn, report_build_problem, exit)
+#
+# 0: global: SUCCESS
+# 0: remove_module(): Remove cancelled because --rpm_safe_upgrade scenario detected.
+# 1: ldtarball: You must be root to use this command with the --force option.
+# 1: check_root(): You must be root to use this command.
+# 1: check_rw_dkms_tree(): No write access to DKMS tree at ...
+# 1: mktemp_or_die(): Unable to make temporary file/directory.
+# 1: check_module_args(): Arguments and are not specified.
+# 1: run_match(): Invalid number of parameters passed.
+# 1: global: If more than one arch is specified on the command line, then there "must be an equal number of kernel versions also specified (1:1 relationship).
+# 2: global: Unknown option: ...
+# 2: global: You cannot specify a kernel version and also specify --all on the command line.
+# 2: run_match(): The templatekernel and the specified kernel version are the same.
+# 2: add_module(): Could not find module source directory.
+# 2: load_tarball(): ... does not exist.
+# 3: global: You cannot specify an arch and also specify --all on the command line.
+# 3: load_tarball(): Tarball does not appear to be a correctly formed DKMS archive. No dkms.conf found within it.
+# 3: run_match(): The module: $module is not located in the DKMS tree.
+# 3: add_module(): You cannot add the same module/version combo more than once.
+# 3: prepare_build(): This module/version has already been built on: ...
+# 3: module_is_added_or_die(): The module/version combo: ... is not located in the DKMS tree.
+# 4: global: Cannot specify more than one action.
+# 4: distro_version(): System is missing os-release file.
+# 4: read_conf(): Could not locate dkms.conf file.
+# 4: have_one_kernel(): The action ... does not support multiple kernel version parameters on the command line.
+# 4: module_is_broken_and_die(): ... is broken!
+# 5: check_all_is_banned(): The action ... does not support the --all parameter.
+# 5: prepare_build(): Patch ... as specified in dkms.conf contains '..' path component.
+# 5: prepare_build(): Patch ... as specified in dkms.conf cannot be found in ...
+# 5: install: This module/version combo is already installed for kernel ...
+# 6: prepare_build(): Application of patch ... failed.
+# 6: install: You cannot install a module onto a non-existant kernel.
+# 6: install: Installation aborted.
+# 6: install: Install Failed (depmod problems). Module rolled back to built state.
+# 6: make_tarball(): Modules must already be in the built state before using mktarball.
+# 6: make_tarball(): Failed to make tarball.
+# 7: load_tarball(): No valid dkms.conf in dkms_source_tree or dkms_binaries_only.
+# 7: actual_build(): Build of ... failed for: ...
+# 8: load_tarball(): ... is already added!
+# 8: global: You have specified both --binaries-only and --source-only.
+# 8: read_conf_or_die(): Bad conf file.
+# 8: prepare_build(): The directory $source_dir does not appear to have module source located within it.
+# 9: add_source_tree(): ... must contain a dkms.conf file!
+# 9: make_tarball(): Missing write permissions for ...
+# 9: load_tarball(): Unable to install ... using rpm.
+# 10: add_source_tree(): Malformed dkms.conf file. Cannot load source tree.
+# 10: build: Bad return status for module build on kernel: ...
+# 11: autoinstall: One or more modules failed to install during autoinstall.
+# 12: setup_kernels_arches(): Could not determine architecture.
+# 13: build: Aborting build of module ... for kernel ... due to missing BUILD_DEPENDS: ...
+# 14: kernel_preinst/prerm: dkms kernel_preinst/prerm for kernel ... failed for module(s) ...
+# 15: gloabl: a call to cd failed
+# 16: setup_kernels_arches()/do_build()/do_install(): empty $kernelver or $arch
+# 21: prepare_kernel(): Your kernel headers for kernel ... cannot be found ...
+# 77: skipped due to BUILD_EXCLUSIVE
+# 101: install: pre_install failed, aborting install.
+
shopt -s extglob
# All of the variables we will accept from dkms.conf.
# Does not include directives
# The last group of variables has been deprecated
-readonly dkms_conf_variables="CLEAN PACKAGE_NAME
+readonly dkms_conf_variables="PACKAGE_NAME
PACKAGE_VERSION POST_ADD POST_BUILD POST_INSTALL POST_REMOVE PRE_BUILD
PRE_INSTALL BUILD_DEPENDS BUILD_EXCLUSIVE_ARCH BUILD_EXCLUSIVE_CONFIG
BUILD_EXCLUSIVE_KERNEL BUILD_EXCLUSIVE_KERNEL_MIN BUILD_EXCLUSIVE_KERNEL_MAX
@@ -34,53 +93,52 @@ readonly dkms_conf_variables="CLEAN PACKAGE_NAME
built_module_name BUILT_MODULE_LOCATION built_module_location
DEST_MODULE_NAME dest_module_name
DEST_MODULE_LOCATION dest_module_location
- STRIP strip AUTOINSTALL NO_WEAK_MODULES
- SIGN_FILE MOK_SIGNING_KEY MOK_CERTIFICATE
+ STRIP strip AUTOINSTALL NO_WEAK_MODULES BUILD_DEPENDS_REBUILD
+ CLEAN
REMAKE_INITRD MODULES_CONF MODULES_CONF_OBSOLETES
MODULES_CONF_ALIAS_TYPE MODULES_CONF_OBSOLETE_ONLY"
+show_deprecation_warnings=0
# All of the variables not related to signing we will accept from framework.conf.
readonly dkms_framework_nonsigning_variables="source_tree dkms_tree install_tree tmp_location
- verbose symlink_modules autoinstall_all_kernels
- modprobe_on_install parallel_jobs"
+ verbose symlink_modules autoinstall_all_kernels modprobe_on_install parallel_jobs
+ compress_gzip_opts compress_xz_opts compress_zstd_opts
+ post_transaction"
# All of the signing related variables we will accept from framework.conf.
readonly dkms_framework_signing_variables="sign_file mok_signing_key mok_certificate"
+# The post transaction command we will accept from framework.conf
+readonly dkms_framework_post_transaction="post_transaction"
+
# Some important regular expressions. Requires bash 3 or above.
# Any poor souls still running bash 2 or older really need an upgrade.
readonly mv_re='^([^/]*)/(.*)$'
# Areas that will vary between Linux and other OS's
_get_kernel_dir() {
- if [[ -z $ksourcedir_fromcli ]]; then
+ if [[ ! $ksourcedir_fromcli ]]; then
KVER=$1
- case ${current_os} in
- Linux) DIR="$install_tree/$KVER/build" ;;
- GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
- esac
- echo $DIR
+ DIR="$install_tree/$KVER/build"
+ echo "$DIR"
else
- echo $kernel_source_dir
+ echo "$kernel_source_dir"
fi
}
_check_kernel_dir() {
- DIR=$(_get_kernel_dir $1)
- case ${current_os} in
- Linux) test -e $DIR/include ;;
- GNU/kFreeBSD) test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;;
- *) return 1 ;;
- esac
+ DIR=$(_get_kernel_dir "$1")
+ [[ -e "$DIR/include" ]]
return $?
}
on_exit()
{
- local exitcode_on_exit=$?
- local j="$(jobs -p)"
+ local exitcode_on_exit=$? # must be one line or $? captures rc from `local`
+ local j
+ j="$(jobs -p)"
- [[ -n "$j" ]] && kill $j 2>/dev/null
+ [[ $j ]] && kill "$j" 2>/dev/null
[[ $make_tarball_rm_temp_dir_name ]] && eval "$make_tarball_rm_temp_dir_name"
[[ $load_tarball_rm_temp_dir_name ]] && eval "$load_tarball_rm_temp_dir_name"
@@ -88,8 +146,14 @@ on_exit()
exit $exitcode_on_exit
}
+unset make_tarball_rm_temp_dir_name load_tarball_rm_temp_dir_name
trap on_exit EXIT
+CP()
+{
+ cp --reflink=auto "$@"
+}
+
# Run a command that we may or may not want to be detailed about.
invoke_command()
{
@@ -97,44 +161,64 @@ invoke_command()
# $2 = Description of command to run
# $3 = Redirect command output (including stderr) to this file
# $4 = background, if you want print . each 3 seconds while command runs
- local cmd="$1"
- local cmd_description="$2"
- local cmd_output_file="$3"
- local cmd_mode="$4"
- local exitval=0
+ local cmd
+ local cmd_description
+ local cmd_output_file
+ local cmd_mode
+ local exitval
local progresspid
-
- [[ $verbose ]] && echo -e "$cmd" || echo -en "$cmd_description..."
+ cmd="$1"
+ cmd_description="$2"
+ cmd_output_file="$3"
+ cmd_mode="$4"
+ exitval=0
- if [[ $cmd_mode == background && ! $verbose && $package_name != dkms*_test ]]; then
- while true ; do
- sleep 3
- echo -n "."
- done &
- progresspid=$!
- fi
+ [[ $verbose ]] && echo -e "$cmd" || echo -en "$cmd_description..."
- if [[ -n "$cmd_output_file" ]]; then
- ( eval "$cmd" ) >> "$cmd_output_file" 2>&1
+ if [[ $cmd_mode == background && ! $verbose && $package_name != dkms*_test ]]; then
+ while true ; do
+ sleep 3
+ echo -n "."
+ done &
+ progresspid=$!
+ fi
+
+ if [[ $cmd_output_file ]]; then
+ local t_start
+ local t_end
+ # shellcheck disable=SC2129
+ echo "" >> "$cmd_output_file"
+ echo -e "$cmd_description" >> "$cmd_output_file"
+ echo -e "# command: $cmd" >> "$cmd_output_file"
+ t_start=$SECONDS
+ ( eval "$cmd" ) >> "$cmd_output_file" 2>&1
exitval=$?
- elif [[ -z "$cmd_output_file" && $cmd_mode == background && ! $verbose ]]; then
+ t_end=$SECONDS
+ # shellcheck disable=SC2129
+ echo -e "\n# exit code: $exitval" >> "$cmd_output_file"
+ echo "# elapsed time: $(date -u -d "0 $t_end sec - $t_start sec" +%T)" >> "$cmd_output_file"
+ echo "----------------------------------------------------------------" >> "$cmd_output_file"
+ elif [[ ! $cmd_output_file && $cmd_mode = background && ! $verbose ]]; then
( eval "$cmd" ) >/dev/null 2>&1
exitval=$?
else
- ( eval "$cmd" )
- exitval=$?
+ ( eval "$cmd" )
+ exitval=$?
fi
- [ -n "$progresspid" ] && kill "$progresspid" >/dev/null 2>&1
-
- if (( exitval > 0)); then
+ if [[ $progresspid ]]; then
+ kill -9 "$progresspid" >/dev/null 2>&1
+ wait "$progresspid" 2>/dev/null
+ fi
+
+ if (( exitval > 0 )); then
echo -en "(bad exit status: $exitval)"
# Print the failing command without the clunky redirection
- [[ ! $verbose ]] && echo -en "\nFailed command:\n$1"
+ [[ ! $verbose ]] && echo -e "\nFailed command:\n$1"
else
echo " done."
fi
-
+
return "$exitval"
}
@@ -164,7 +248,7 @@ die() {
ret=$1
shift
error "$@"
- [[ $die_is_fatal = yes ]] && exit $ret || return $ret
+ [[ $die_is_fatal = yes ]] && exit "$ret" || return "$ret"
}
# Print a warning message and die with the passed error code.
@@ -174,13 +258,13 @@ diewarn() {
ret=$1
shift
warn "$@"
- [[ $die_is_fatal = yes ]] && exit $ret || return $ret
+ [[ $die_is_fatal = yes ]] && exit "$ret" || return "$ret"
}
mktemp_or_die() {
local t
t=$(mktemp "$@") && echo "$t" && return
- [[ $* = *-d* ]] && die 1 "Unable to make temporary directory"
+ [[ $* = *-d* ]] && die 1 "Unable to make temporary directory."
die 1 "Unable to make temporary file."
}
@@ -188,15 +272,16 @@ show_usage()
{
echo "Usage: $0 [action] [options]"
echo " [action] = { add | remove | build | unbuild | install | uninstall | match |"
- echo " autoinstall | mktarball | ldtarball | status | generate_mok }"
+ echo " autoinstall | mktarball | ldtarball | status | generate_mok |"
+ echo " kernel_preinst | kernel_postinst | kernel_prerm }"
echo " [options] = [-m module] [-v module-version] [-k kernel-version] [-a arch]"
echo " [-c dkms.conf-location] [-q] [--force] [--force-version-override] [--all]"
echo " [--templatekernel=kernel] [--directive='cli-directive=cli-value']"
- echo " [--config=kernel-.config-location] [--archive=tarball-location]"
+ echo " [--config=kernel-include/config/auto.conf-location] [--archive=tarball-location]"
echo " [--kernelsourcedir=source-location] [--rpm_safe_upgrade]"
echo " [--dkmstree path] [--sourcetree path] [--installtree path]"
echo " [--binaries-only] [--source-only] [--verbose]"
- echo " [--no-depmod] [--modprobe-on-install] [-j number] [--version]"
+ echo " [--no-depmod] [--modprobe-on-install] [-j number] [--version] [--help]"
}
VER()
@@ -207,7 +292,7 @@ VER()
# 2.6.9-1cvs200409091247 => 002.006.009-001cvs200409091247
# The result should compare correctly as a string.
- echo $1 | sed -e 's:\([^0-9]\)\([0-9]\):\1 \2:g' \
+ echo "$1" | sed -e 's:\([^0-9]\)\([0-9]\):\1 \2:g' \
-e 's:\([0-9]\)\([^0-9]\):\1 \2:g' \
-e 's:\(.*\): \1 :' \
-e 's: \([0-9]\) : 00\1 :g' \
@@ -233,8 +318,10 @@ compressed_or_uncompressed()
{
# module dir = $1
# module = $2
- local test1="$1/$2$module_uncompressed_suffix"
- local test2="$1/$2$module_uncompressed_suffix$module_compressed_suffix"
+ local test1
+ local test2
+ test1="$1/$2$module_uncompressed_suffix"
+ test2="$1/$2$module_uncompressed_suffix$module_compressed_suffix"
if [[ -e "$test1" ]]; then
echo "$test1"
elif [[ -e "$test2" ]]; then
@@ -252,28 +339,33 @@ find_module()
return $?
}
-
-# Figure out the correct module suffix for the kernel we are currently
-# dealing with, which may or may not be the currently installed kernel.
+# Figure out the correct module suffix for the kernel we are currently dealing
+# with, which may or may not be the currently installed kernel. Do not use modules.dep
+# as it might not be available (in Red Hat removal is triggered with kernel-core but modules.dep
+# is contained in kernel-modules-core).
set_module_suffix()
{
# $1 = the kernel to base the module_suffix on
kernel_test="${1:-$(uname -r)}"
module_uncompressed_suffix=".ko"
- grep -q '\.gz:' $install_tree/$kernel_test/modules.dep 2>/dev/null && module_compressed_suffix=".gz"
- grep -q '\.xz:' $install_tree/$kernel_test/modules.dep 2>/dev/null && module_compressed_suffix=".xz"
- grep -q '\.zst:' $install_tree/$kernel_test/modules.dep 2>/dev/null && module_compressed_suffix=".zst"
+ find "$install_tree/$kernel_test/" -name "*.ko.gz" 2>/dev/null | grep -q . && module_compressed_suffix=".gz"
+ find "$install_tree/$kernel_test/" -name "*.ko.xz" 2>/dev/null | grep -q . && module_compressed_suffix=".xz"
+ find "$install_tree/$kernel_test/" -name "*.ko.zst" 2>/dev/null | grep -q . && module_compressed_suffix=".zst"
module_suffix="$module_uncompressed_suffix$module_compressed_suffix"
}
set_kernel_source_dir_and_kconfig()
{
- if [[ -z "${ksourcedir_fromcli}" ]]; then
+ if [[ ! $ksourcedir_fromcli ]]; then
# $1 = the kernel to base the directory on
kernel_source_dir="$(_get_kernel_dir "$1")"
fi
- if [[ -z "${kconfig_fromcli}" ]]; then
- kernel_config="${kernel_source_dir}/.config"
+ if [[ ! $kconfig_fromcli ]]; then
+ if [[ -e "${kernel_source_dir}/include/config/auto.conf" ]]; then
+ kernel_config="${kernel_source_dir}/include/config/auto.conf"
+ else
+ kernel_config="${kernel_source_dir}/.config"
+ fi
fi
}
@@ -286,10 +378,11 @@ check_all_is_banned()
# A little test function for DKMS commands that only work on one kernel.
have_one_kernel() {
+ check_all_is_banned "$1"
if (( ${#kernelver[@]} != 1 )); then
+ [[ $1 =~ kernel_(preinst|postinst|prerm) ]] && die 4 "The action $1 requires exactly one kernel version parameter on the command line."
die 4 "The action $1 does not support multiple kernel version parameters on the command line."
fi
- check_all_is_banned $1
}
# Set up the kernelver and arch arrays. You must have a 1:1 correspondence --
@@ -301,33 +394,44 @@ setup_kernels_arches()
{
# If all is set, use dkms status to fill the arrays
if [[ $all && $1 != status ]]; then
- local i=0
- while read line; do
+ local i
+ i=0
+ while read -r line; do
+ [[ $line ]] || continue
line=${line#*/}; line=${line#*/};
# (I would leave out the delimiters in the status output
# in the first place.)
- kernelver[$i]=${line%/*}
- arch[$i]=${line#*/}
- i=$(($i + 1))
- done < <(module_status_built "$module" "$module_version" | sort -V)
+ kernelver[i]=${line%/*}
+ arch[i]=${line#*/}
+ i=$((i + 1))
+ done <<< "$(module_status_built "$module" "$module_version" | sort -V)"
fi
# Set default kernel version and arch, if none set (but only --all isn't set)
if [[ $1 != status ]]; then
- if [[ ! $kernelver && ! $all ]]; then
+ if [[ ${#kernelver[@]} -eq 0 && ! $all ]]; then
kernelver[0]=$(uname -r)
fi
- if [[ ! $arch ]]; then
- kernelver_rpm=$(rpm -qf "$install_tree/$kernelver" 2>/dev/null | \
- grep -v "not owned by any package" | grep kernel | head -n 1)
- if ! arch[0]=$(rpm -q --queryformat "%{ARCH}" "$kernelver_rpm" 2>/dev/null); then
- arch[0]=$(uname -m)
- if [[ $arch = x86_64 ]] && grep -q Intel /proc/cpuinfo && ls $install_tree/$kernelver/build/configs 2>/dev/null | grep -q "ia32e"; then
- arch[0]="ia32e"
- fi
- fi
+ if [[ ${#arch[@]} -eq 0 ]]; then
+ case "$running_distribution" in
+ debian* | ubuntu* | arch* | gentoo*)
+ arch[0]=$(uname -m)
+ ;;
+ *)
+ kernelver_rpm=$(rpm -qf "$install_tree/${kernelver[0]}" 2>/dev/null | \
+ grep -v "not owned by any package" | grep kernel | head -n 1)
+ if ! arch[0]=$(rpm -q --queryformat "%{ARCH}" "$kernelver_rpm" 2>/dev/null); then
+ arch[0]=$(uname -m)
+ # shellcheck disable=SC2010
+ # TODO: replace ls | grep
+ if [[ ${arch[0]} = x86_64 ]] && [[ -r /proc/cpuinfo ]] && grep -q Intel /proc/cpuinfo && ls "$install_tree/${kernelver[0]}/build/configs" 2>/dev/null | grep -q "ia32e"; then
+ arch[0]="ia32e"
+ fi
+ fi
+ ;;
+ esac
fi
- if [[ ! $arch ]]; then
+ if [[ ${#arch[@]} -eq 0 ]]; then
die 12 "Could not determine architecture."
fi
fi
@@ -335,19 +439,19 @@ setup_kernels_arches()
# If only one arch is specified, make it so for all the kernels
if ((${#arch[@]} == 1 && ${#kernelver[@]} > 1)); then
while ((${#arch[@]} < ${#kernelver[@]})); do
- arch[${#arch[@]}]=$arch
+ arch[${#arch[@]}]=${arch[0]}
done
fi
- # Set global multi_arch
- multi_arch=""
- local i=0
- for ((i=0; $i < ${#arch[@]}; i++)); do
- [[ $arch != ${arch[$i]} ]] && {
- multi_arch="true"
- break
- }
- done
+ if [[ $1 != status ]]; then
+ local i
+ for ((i=0; i < ${#kernelver[@]}; i++)); do
+ [[ ${kernelver[i]} ]] || die 16 "Empty kernelver[$i]"
+ done
+ for ((i=0; i < ${#arch[@]}; i++)); do
+ [[ ${arch[i]} ]] || die 16 "Empty arch[$i]"
+ done
+ fi
}
do_depmod()
@@ -373,8 +477,8 @@ do_depmod()
if [[ -f $install_tree/$1/modules.dep && ! -s $install_tree/$1/modules.dep ]]; then
# if modules.dep is empty, we just removed the last kernel module from
# no longer installed kernel $1, so do not leave stale depmod files around
- rm -fv $install_tree/$1/modules.{alias,dep,devname,softdep,symbols,weakdep,*.bin}
- rmdir --ignore-fail-on-non-empty $install_tree/$1
+ rm -fv "${install_tree:?}/$1/"modules.{alias,dep,devname,softdep,symbols,weakdep,*.bin}
+ rmdir --ignore-fail-on-non-empty "${install_tree:?}/$1"
[[ -d $install_tree/$1 ]] || echo "removed directory $install_tree/$1"
fi
}
@@ -385,14 +489,15 @@ distro_version()
for f in /etc/os-release /usr/lib/os-release; do
if [[ -e $f ]]; then
(
+ # shellcheck disable=SC1090
. "$f"
if [[ "$ID" = "ubuntu" ]]; then
# ID_LIKE=debian in ubuntu
- echo $ID
+ echo "$ID"
elif [[ ${#ID_LIKE[@]} != 0 ]]; then
- echo ${ID_LIKE[0]}
+ echo "${ID_LIKE[0]}"
else
- echo $ID
+ echo "$ID"
fi
)
return
@@ -403,14 +508,10 @@ distro_version()
override_dest_module_location()
{
- local orig_location="$1"
+ local orig_location
+ orig_location="$1"
[[ ${addon_modules_dir} ]] && echo "/${addon_modules_dir}" && return
- if [[ $current_os = GNU/kFreeBSD ]] ; then
- # Does not support subdirs, regardless of distribution
- echo "" && return
- fi
-
case "$running_distribution" in
fedora* | rhel* | ovm*)
echo "/extra" && return
@@ -439,16 +540,25 @@ override_dest_module_location()
safe_source() {
# $1 = file to source
# $@ = environment variables to echo out
- local to_source_file="$1"; shift
- declare -a -r export_envs=("$@")
- local tmpfile=$(mktemp_or_die)
+ local to_source_file
+ to_source_file="$1"; shift
+ # shellcheck disable=SC2206
+ # we intentionally split the string into a multi-element array
+ declare -a -r export_envs=( $@ )
+ # shellcheck disable=SC2034
+ # false positive
+ local -r CR=$(echo -e '\r')
+ local tmpfile
+ tmpfile=$(mktemp_or_die)
( exec >"$tmpfile"
+ # shellcheck disable=SC1090
. "$to_source_file" >/dev/null
# This is really ugly, but a neat hack
# Remember, in bash 2.0 and greater all variables are really arrays.
for _export_env in "${export_envs[@]}"; do
- for _i in $(eval echo \${!$_export_env[@]}); do
- eval echo '$_export_env[$_i]=\"${'$_export_env'[$_i]}\"'
+ # shellcheck disable=SC1083,SC2294
+ for _i in $(eval echo \${!"${_export_env}"[@]}); do
+ eval echo '$_export_env[$_i]=\"${'"${_export_env}"'[$_i]%$CR}\"'
done
done
@@ -459,9 +569,17 @@ safe_source() {
echo "$directive_name=\"$directive_value\""
done
)
+ # shellcheck disable=SC1090
. "$tmpfile"
- rm "$tmpfile"
+ rm "${tmpfile:?}"
+ (( show_deprecation_warnings )) || return
+ if (( ${#CLEAN[@]} )); then
+ case "$CLEAN" in
+ true|/bin/true|/usr/bin/true) ;;
+ *) deprecated "CLEAN ($to_source_file)" ;;
+ esac
+ fi
(( ${#REMAKE_INITRD[@]} )) && deprecated "REMAKE_INITRD ($to_source_file)"
(( ${#MODULES_CONF[@]} )) && deprecated "MODULES_CONF ($to_source_file)"
(( ${#MODULES_CONF_OBSOLETES[@]} )) && deprecated "MODULES_CONF_OBSOLETES ($to_source_file)"
@@ -472,18 +590,21 @@ safe_source() {
# Source a dkms.conf file and perform appropriate postprocessing on it.
# Do our best to not repeatedly source the same .conf file -- this can happen
# when chaining module installation functions or autoinstalling.
-read_conf()
-{
+read_conf() {
# $1 kernel version (required)
# $2 arch (required)
# $3 dkms.conf location (optional)
- local return_value=0
- local read_conf_file="$dkms_tree/$module/$module_version/source/dkms.conf"
+ local return_value
+ local read_conf_file
+ return_value=0
+ read_conf_file="$dkms_tree/$module/$module_version/source/dkms.conf"
# Set variables supported in dkms.conf files (eg. $kernelver)
- local kernelver="$1"
- local arch="$2"
+ local kernelver
+ local arch
+ kernelver="$1"
+ arch="$2"
set_kernel_source_dir_and_kconfig "$1"
@@ -495,41 +616,53 @@ read_conf()
"File: $read_conf_file does not exist."
[[ $last_mvka = $module/$module_version/$1/$2 && \
- $last_mvka_conf = $(readlink -f $read_conf_file) ]] && return
+ $last_mvka_conf = $(readlink -f "$read_conf_file") ]] && return
# Clear variables and arrays
for var in $dkms_conf_variables; do
- unset $var
+ unset "$var"
done
# Source in the dkms.conf.
# Allow for user-specified overrides in order of specificity.
local _conf_file
- for _conf_file in "$read_conf_file" "/etc/dkms/$module.conf" \
- "/etc/dkms/$module-$module_version.conf" "/etc/dkms/$module-$module_version-$1.conf" \
- "/etc/dkms/$module-$module_version-$1-$2.conf"; do
- [[ -e $_conf_file ]] && safe_source "$_conf_file" $dkms_conf_variables
+ for _conf_file in \
+ "$read_conf_file" \
+ "/etc/dkms/$module.conf" \
+ "/etc/dkms/$module-$module_version.conf" \
+ "/etc/dkms/$module-$module_version-$1.conf" \
+ "/etc/dkms/$module-$module_version-$1-$2.conf" \
+ "/etc/dkms/$module--$1.conf" \
+ "/etc/dkms/$module--$1-$2.conf" \
+ ; do
+ [[ -e $_conf_file ]] && safe_source "$_conf_file" "$dkms_conf_variables"
done
# Source in the directive_array
for directive in "${directive_array[@]}"; do
directive_name=${directive%%=*}
directive_value=${directive#*=}
- export $directive_name="$directive_value"
+ export "$directive_name"="$directive_value"
echo "DIRECTIVE: $directive_name=\"$directive_value\""
done
# Set variables
- clean="$CLEAN"
package_name="$PACKAGE_NAME"
package_version="$PACKAGE_VERSION"
+ # shellcheck disable=SC2153
post_add="$POST_ADD"
+ # shellcheck disable=SC2153
post_build="$POST_BUILD"
+ # shellcheck disable=SC2153
post_install="$POST_INSTALL"
+ # shellcheck disable=SC2153
post_remove="$POST_REMOVE"
+ # shellcheck disable=SC2153
pre_build="$PRE_BUILD"
+ # shellcheck disable=SC2153
pre_install="$PRE_INSTALL"
+ # shellcheck disable=SC2153
obsolete_by="$OBSOLETE_BY"
# Fail if no PACKAGE_NAME
@@ -544,41 +677,50 @@ read_conf()
return_value=1
fi
- # Set module naming/location arrays
- local index array_size=0 s
- for s in ${#BUILT_MODULE_NAME[@]} \
- ${#BUILT_MODULE_LOCATION[@]} \
- ${#DEST_MODULE_NAME[@]} \
- ${#DEST_MODULE_LOCATION[@]}; do
- ((s > array_size)) && array_size=$s
+ # Determine number of modules
+ # The arrays are possibly sparse, so use the maximum index instead of the array length
+ local s
+ local max_index
+ max_index=-1
+ # shellcheck disable=SC2153
+ for s in "${!BUILT_MODULE_NAME[@]}" \
+ "${!BUILT_MODULE_LOCATION[@]}" \
+ "${!DEST_MODULE_NAME[@]}" \
+ "${!DEST_MODULE_LOCATION[@]}"; do
+ ((s > max_index)) && max_index=$s
done
- for ((index=0; index < array_size; index++)); do
+ num_modules=$((max_index + 1))
+
+ # Set module naming/location arrays
+ local index
+ for ((index=0; index < num_modules; index++)); do
# Set values
- built_module_name[$index]=${BUILT_MODULE_NAME[$index]}
- built_module_location[$index]=${BUILT_MODULE_LOCATION[$index]}
- dest_module_name[$index]=${DEST_MODULE_NAME[$index]}
- dest_module_location[$index]=${DEST_MODULE_LOCATION[$index]}
- case ${STRIP[$index]} in
+ built_module_name[index]=${BUILT_MODULE_NAME[index]}
+ built_module_location[index]=${BUILT_MODULE_LOCATION[index]}
+ dest_module_name[index]=${DEST_MODULE_NAME[index]}
+ dest_module_location[index]=${DEST_MODULE_LOCATION[index]}
+ # shellcheck disable=SC2153
+ case ${STRIP[index]} in
[nN]*)
- strip[$index]="no"
+ strip[index]="no"
;;
[yY]*)
- strip[$index]="yes"
+ strip[index]="yes"
;;
'')
- strip[$index]=${strip[0]:-yes}
+ strip[index]=${strip[0]:-yes}
;;
esac
# If unset, set by defaults
[[ ! ${built_module_name[$index]} ]] && \
- ((array_size == 1)) && \
- built_module_name[$index]=$PACKAGE_NAME
+ ((num_modules == 1)) && \
+ built_module_name[index]=$PACKAGE_NAME
[[ ! ${dest_module_name[$index]} ]] && \
- dest_module_name[$index]=${built_module_name[$index]}
+ dest_module_name[index]=${built_module_name[index]}
[[ ${built_module_location[$index]} && \
${built_module_location[$index]:(-1)} != / ]] && \
- built_module_location[$index]="${built_module_location[$index]}/"
+ built_module_location[index]="${built_module_location[index]}/"
# FAIL if no built_module_name
if [[ ! ${built_module_name[$index]} ]]; then
@@ -603,16 +745,14 @@ read_conf()
esac
# Override location for specific distributions
- dest_module_location[$index]="$(override_dest_module_location ${dest_module_location[$index]})"
-
- # Fail if no DEST_MODULE_LOCATION
- if [[ ! ${DEST_MODULE_LOCATION[$index]} ]]; then
- echo "dkms.conf: Error! No 'DEST_MODULE_LOCATION' directive specified for record #$index.">&2
- return_value=1
- fi
+ dest_module_location[index]="$(override_dest_module_location "${dest_module_location[index]}")"
# Fail if bad DEST_MODULE_LOCATION
case ${DEST_MODULE_LOCATION[$index]} in
+ "")
+ echo "dkms.conf: Error! No 'DEST_MODULE_LOCATION' directive specified for record #$index.">&2
+ return_value=1
+ ;;
/kernel*)
;;
/updates*)
@@ -620,17 +760,23 @@ read_conf()
/extra*)
;;
*)
- echo "dkms.conf: Error! Directive 'DEST_MODULE_LOCATION' does not begin with">&2
- echo "'/kernel', '/updates', or '/extra' in record #$index.">&2
- return_value=1
+ echo "dkms.conf: Error! Directive 'DEST_MODULE_LOCATION' does not begin with">&2
+ echo "'/kernel', '/updates', or '/extra' in record #$index.">&2
+ return_value=1
;;
esac
done
- # Warn if no modules are specified
- if ((array_size == 0)); then
- echo "dkms.conf: Warning! Zero modules specified." >&2
- fi
+ # Array length sanity check
+ for s in ${#built_module_name[@]} \
+ ${#built_module_location[@]} \
+ ${#dest_module_name[@]} \
+ ${#dest_module_location[@]}; do
+ if ((s != num_modules)); then
+ echo "dkms.conf: Error! Module name/location array length mismatch.">&2
+ return_value=1
+ fi
+ done
# Get the correct make command
[[ ${MAKE_MATCH[0]} ]] || make_command="${MAKE[0]}"
@@ -640,37 +786,32 @@ read_conf()
make_command="${MAKE[$index]}"
done
- # Use the generic make and make clean commands if not specified
+ # Use the generic make command if not specified
[[ ! $make_command ]] && make_command="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build"
- [[ ! $clean ]] && clean="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build clean"
# Check if clang was used to compile or lld was used to link the kernel.
if [[ -e $kernel_source_dir/vmlinux ]]; then
- if readelf -p .comment $kernel_source_dir/vmlinux | grep -q clang; then
- make_command="${make_command} CC=clang"
- fi
- if readelf -p .comment $kernel_source_dir/vmlinux | grep -q LLD; then
- make_command="${make_command} LD=ld.lld"
+ if readelf -p .comment "$kernel_source_dir/vmlinux" 2>&1 | grep -q clang; then
+ make_command="${make_command} LLVM=1"
fi
elif [[ -e "${kernel_config}" ]]; then
if grep -q CONFIG_CC_IS_CLANG=y "${kernel_config}"; then
- make_command="${make_command} CC=clang"
- fi
- if grep -q CONFIG_LD_IS_LLD=y "${kernel_config}"; then
- make_command="${make_command} LD=ld.lld"
+ make_command="${make_command} LLVM=1"
fi
fi
# Set patch_array (including kernel specific patches)
+ local count
count=0
for ((index=0; index < ${#PATCH[@]}; index++)); do
if [[ ${PATCH[$index]} && (! ${PATCH_MATCH[$index]} || $1 =~ ${PATCH_MATCH[$index]}) ]]; then
- patch_array[$count]="${PATCH[$index]}"
- count=$(($count+1))
+ patch_array[count]="${PATCH[index]}"
+ count=$((count+1))
fi
done
# Set build_exclude
+ [[ $obsolete_by && ! $BUILD_EXCLUSIVE_KERNEL_MAX ]] && BUILD_EXCLUSIVE_KERNEL_MAX=$obsolete_by
[[ $BUILD_EXCLUSIVE_KERNEL && ! $1 =~ $BUILD_EXCLUSIVE_KERNEL ]] && build_exclude="yes"
[[ $BUILD_EXCLUSIVE_KERNEL_MIN && "$(VER "$1")" < "$(VER "$BUILD_EXCLUSIVE_KERNEL_MIN")" ]] && build_exclude="yes"
[[ $BUILD_EXCLUSIVE_KERNEL_MAX && "$(VER "$1")" > "$(VER "$BUILD_EXCLUSIVE_KERNEL_MAX")" ]] && build_exclude="yes"
@@ -685,13 +826,83 @@ read_conf()
done
fi
- # Set clean
- [[ $clean ]] || clean="make clean"
+ # Helper function to check yes/no values
+ check_yes_no_value() {
+ local var_name="$1"
+ local var_value="$2"
+ case "$var_value" in
+ "")
+ ;;
+ [Yy][Ee][Ss])
+ ;;
+ [Nn][Oo])
+ eval "$var_name=''"
+ ;;
+ *)
+ echo "dkms.conf: Error! Unsupported $var_name value '$var_value'" >&2
+ return_value=1
+ ;;
+ esac
+ }
+
+ # Check for allowed values in boolean variables
+ check_yes_no_value "AUTOINSTALL" "$AUTOINSTALL"
+ check_yes_no_value "BUILD_DEPENDS_REBUILD" "$BUILD_DEPENDS_REBUILD"
+ check_yes_no_value "NO_WEAK_MODULES" "$NO_WEAK_MODULES"
((return_value == 0)) && last_mvka="$module/$module_version/$1/$2" && last_mvka_conf="$(readlink -f "$read_conf_file")"
return $return_value
}
+# read_conf() with additional dkms.conf checks that should prevent
+# add/build/install but not uninstall/unbuild/remove of bad modules.
+read_conf_strict()
+{
+ show_deprecation_warnings=1
+ read_conf "$@" || return $?
+ show_deprecation_warnings=0
+
+ local index
+ local names
+ local return_value
+ return_value=0
+
+ # Warn if no modules are specified
+ if ((num_modules == 0)); then
+ echo "dkms.conf: Warning! Zero modules specified." >&2
+ fi
+
+ # FAIL on duplicate modules in BUILT_MODULE_NAME[]
+ names=
+ for ((index=0; index < num_modules; index++)); do
+ local m
+ m="${built_module_location[index]}${built_module_name[index]}"
+ case " $names " in
+ *" $m "*)
+ echo "dkms.conf: Error! Duplicate module '$m' in 'BUILT_MODULE_NAME[$index]'." >&2
+ return_value=1
+ ;;
+ esac
+ names="$names $m"
+ done
+
+ # FAIL on duplicate modules in DEST_MODULE_NAME[]
+ names=
+ for ((index=0; index < num_modules; index++)); do
+ local m
+ m=${dest_module_name[index]}
+ case " $names " in
+ *" $m "*)
+ echo "dkms.conf: Error! Duplicate module '$m' in 'DEST_MODULE_NAME[$index]'." >&2
+ return_value=1
+ ;;
+ esac
+ names="$names $m"
+ done
+
+ return $return_value
+}
+
# Source specified variables from dkms framework configuration files.
read_framework_conf() {
for i in /etc/dkms/framework.conf /etc/dkms/framework.conf.d/*.conf; do
@@ -704,18 +915,20 @@ get_module_verinfo(){
local ver
local srcver
local checksum
- local vals=
- while read -a vals; do
- case "${vals[0]}" in
- version:)
- ver="${vals[1]}"
- checksum="${vals[2]}"
- ;;
- srcversion:)
- srcver="${vals[1]}"
- ;;
- esac
- done < <(modinfo "$1")
+ local vals
+ vals=
+ while read -ra vals; do
+ [[ ${#vals[@]} -eq 0 ]] && continue
+ case "${vals[0]}" in
+ version:)
+ ver="${vals[1]}"
+ checksum="${vals[2]}"
+ ;;
+ srcversion:)
+ srcver="${vals[1]}"
+ ;;
+ esac
+ done <<< "$(modinfo "$1")"
echo -E "${ver}"
# Use obsolete checksum info if srcversion is not available
@@ -741,7 +954,7 @@ compare_module_version()
echo "="
fi
return 0
- elif [[ ! "$ver1" ]] || [[ ! "$ver2" ]]; then
+ elif [[ ${#ver1[@]} -eq 0 ]] || [[ ${#ver2[@]} -eq 0 ]]; then
echo "?"
elif [[ "$(VER "${ver1[0]}")" > "$(VER "${ver2[0]}")" ]]; then
echo ">"
@@ -760,27 +973,32 @@ check_version_sanity()
# $3 = obs by kernel version
# $4 = dest_module_name
- local lib_tree="$install_tree/$1" res=
- local i=0
- if [[ -n $3 ]]; then
+ local lib_tree
+ local i
+ lib_tree="$install_tree/$1"
+ i=0
+ if [[ $3 ]]; then
# Magic split into array syntax saves trivial awk and cut calls.
- local -a obs=(${3//-/ })
- local -a my=(${1//-/ })
- local obsolete=0
- if [[ ${obs} && ${my} ]]; then
- if [[ $(VER ${obs}) == $(VER ${my}) && ! $force ]]; then
+ local -a obs
+ local -a my
+ local obsolete
+ obs=("${3//-/ }")
+ my=("${1//-/ }")
+ obsolete=0
+ if [[ ${#obs[@]} -gt 0 && ${#my[@]} -gt 0 ]]; then
+ if [[ $(VER "${obs[0]}") == $(VER "${my[0]}") && ! $force ]]; then
# They get obsoleted possibly in this kernel release
if [[ ! ${obs[1]} ]]; then
# They were obsoleted in this upstream kernel
obsolete=1
- elif [[ $(VER ${my[1]}) > $(VER ${obs[1]}) ]]; then
+ elif [[ $(VER "${my[1]}") > $(VER "${obs[1]}") ]]; then
# They were obsoleted in an earlier ABI bump of the kernel
obsolete=1
- elif [[ $(VER ${my[1]}) = $(VER ${obs[1]}) ]]; then
+ elif [[ $(VER "${my[1]}") = $(VER "${obs[1]}") ]]; then
# They were obsoleted in this ABI bump of the kernel
obsolete=1
fi
- elif [[ $(VER ${my}) > $(VER ${obs}) && ! $force ]]; then
+ elif [[ $(VER "${my[0]}") > $(VER "${obs[0]}") && ! $force ]]; then
# They were obsoleted in an earlier kernel release
obsolete=1
fi
@@ -795,8 +1013,8 @@ check_version_sanity()
fi
fi
set_module_suffix "$1"
- read -a kernels_module < <(find_module "$lib_tree" "${4}")
- [[ -z $kernels_module ]] && return 0
+ read -ra kernels_module <<< "$(find_module "$lib_tree" "${4}")"
+ [[ ${#kernels_module[@]} -eq 0 ]] && return 0
if [[ "$force_version_override" == "true" ]]; then
# Skip the following version checking code.
@@ -804,12 +1022,14 @@ check_version_sanity()
fi
if [[ ${kernels_module[1]} ]]; then
- warn "Warning! Cannot do version sanity checking because multiple ${4}$module_suffix modules were found in kernel $1."
+ warn "Cannot do version sanity checking because multiple ${4}$module_suffix modules were found in kernel $1."
return 0
fi
- local dkms_module=$(compressed_or_uncompressed "$dkms_tree/$module/$module_version/$1/$2/module/" "${4}")
+ local dkms_module
+ dkms_module=$(compressed_or_uncompressed "$dkms_tree/$module/$module_version/$1/$2/module" "${4}")
- local cmp_res="$(compare_module_version "${kernels_module}" "${dkms_module}")"
+ local cmp_res
+ cmp_res="$(compare_module_version "${kernels_module}" "${dkms_module}")"
if [[ "${cmp_res}" = ">" ]]; then
if [[ ! "$force" ]]; then
error "Module version $(get_module_verinfo "${dkms_module}" | head -n 1) for $4${module_suffix}" \
@@ -820,9 +1040,15 @@ check_version_sanity()
elif [[ "${cmp_res}" = "==" ]]; then
if [[ ! "$force" ]]; then
# if the module has neither version nor srcversion/checksum, check the binary files instead
- local verinfo="$(get_module_verinfo "${dkms_module}")"
+ local verinfo
+ verinfo="$(get_module_verinfo "${dkms_module}")"
if [[ "$(echo "$verinfo" | tr -d '[:space:]')" ]] || diff "${kernels_module}" "${dkms_module}" &>/dev/null; then
- echo "Module ${kernels_module} already installed at version $(echo "$verinfo" | head -n 1), override by specifying --force" >&2
+ verinfo=$(echo "$verinfo" | head -n 1)
+ if [[ $verinfo ]]; then
+ echo "Module ${kernels_module} already installed at version ${verinfo}, override by specifying --force" >&2
+ else
+ echo "Module ${kernels_module} already installed (unversioned module), override by specifying --force" >&2
+ fi
return 1
fi
fi
@@ -844,10 +1070,18 @@ read_conf_or_die() {
"File: ${3:-$conf} does not represent a valid dkms.conf file."
}
+read_conf_strict_or_die() {
+ read_conf_strict "$@" && return
+ die 8 "Bad conf file."\
+ "File: ${3:-$conf} does not represent a valid dkms.conf file."
+}
+
run_build_script() {
# $1 = script type
# $2 = script to run
- local script_type run
+ # $3 = (optional) logfile for script output
+ local script_type
+ local run
[[ $2 ]] || return 0
case "$1" in
pre_build|post_build)
@@ -859,12 +1093,21 @@ run_build_script() {
esac
run="$dkms_tree/$module/$module_version/$script_type/$2"
if [[ -x ${run%% *} ]]; then
- echo ""
+ if [[ $3 ]]; then
+ local res
+ res=0
+ invoke_command "cd $dkms_tree/$module/$module_version/$script_type/ && $run" "Running the $1 script" "$3" background || res=$?
+ if [[ $res != 0 ]]; then
+ echo "Consult $3 for more information."
+ exit "$res"
+ fi
+ else
echo "Running the $1 script:"
(
- cd "$dkms_tree/$module/$module_version/$script_type/"
+ cd "$dkms_tree/$module/$module_version/$script_type/" || exit 15
exec $run
)
+ fi
else
echo ""
warn "The $1 script is not executable."
@@ -890,19 +1133,22 @@ add_module()
# Do stuff for --rpm_safe_upgrade
if [[ $rpm_safe_upgrade ]]; then
- local pppid=$(awk '/PPid:/ {print $2}' /proc/$PPID/status)
- local lock_name=$(mktemp_or_die $tmp_location/dkms_rpm_safe_upgrade_lock.$pppid.XXXXXX)
- echo "$module-$module_version" >> $lock_name
- ps -o lstart --no-headers -p $pppid 2>/dev/null >> $lock_name
+ local pppid
+ local lock_name
+ pppid=$(awk '/PPid:/ {print $2}' /proc/$PPID/status)
+ lock_name=$(mktemp_or_die "$tmp_location/dkms_rpm_safe_upgrade_lock.$pppid.XXXXXX")
+ echo "$module-$module_version" >> "$lock_name"
+ ps -o lstart --no-headers -p "$pppid" 2>/dev/null >> "$lock_name"
fi
# Check that this module-version hasn't already been added
if is_module_added "$module" "$module_version"; then
- die 3 "DKMS tree already contains: $module-$module_version" \
+ die 3 "DKMS tree already contains: $module/$module_version" \
"You cannot add the same module/version combo more than once."
fi
- [[ $conf ]] || conf="$source_tree/$module-$module_version/dkms.conf"
+ local source_conf
+ source_conf=${conf:-"$source_tree/$module-$module_version/dkms.conf"}
# Check that /usr/src/$module-$module_version exists
if ! [[ -d $source_tree/$module-$module_version ]]; then
@@ -911,7 +1157,7 @@ add_module()
fi
# Check the conf file for sanity
- read_conf_or_die "$kernelver" "$arch" "$conf"
+ read_conf_strict_or_die "$kernelver" "$arch" "$source_conf"
# Create the necessary dkms tree structure
echo "Creating symlink $dkms_tree/$module/$module_version/source -> $source_tree/$module-$module_version"
@@ -928,20 +1174,17 @@ add_module()
prepare_kernel()
{
# $1 = kernel version to prepare
- # $2 = arch to prepare
-
- set_kernel_source_dir_and_kconfig "$1"
# Check that kernel-source exists
_check_kernel_dir "$1" || {
- die 1 "Your kernel headers for kernel $1 cannot be found at $install_tree/$1/build or $install_tree/$1/source." \
+ die 21 "Your kernel headers for kernel $1 cannot be found at $install_tree/$1/build or $install_tree/$1/source." \
"Please install the linux-headers-$1 package or use the --kernelsourcedir option to tell DKMS where it's located."
}
}
prepare_mok()
{
- if [[ -z "${mok_signing_key}" ]]; then
+ if [[ ! $mok_signing_key ]]; then
# No custom key specified, use the default key created by update-secureboot-policy for Ubuntu
# Debian's update-secureboot-policy has no --new-key option
case "$running_distribution" in
@@ -952,55 +1195,81 @@ prepare_mok()
if [[ ! -f ${mok_signing_key} || ! -f ${mok_certificate} ]]; then
if [[ ! -x "$(command -v update-secureboot-policy)" ]]; then
echo "Binary update-secureboot-policy not found, modules won't be signed"
- return
+ return 1
fi
# update-secureboot-policy won't create new key if $mok_certificate exists
if [[ -f ${mok_certificate} ]]; then
- rm -f "${mok_certificate}"
+ rm -f "${mok_certificate:?}"
fi
echo "Certificate or key are missing, generating them using update-secureboot-policy..."
SHIM_NOTRIGGER=y update-secureboot-policy --new-key &>/dev/null
update-secureboot-policy --enroll-key
fi
+ ;;
+ gentoo* )
+ # If the usual Gentoo/Portage environment variables are set, use those.
+ mok_signing_key=${MODULES_SIGN_KEY}
+ mok_certificate=${MODULES_SIGN_CERT}
+
+ # If still empty, attempt to read the signing configuration set for portage.
+ if [[ ! $mok_signing_key && -f /etc/portage/make.conf ]]; then
+ mok_signing_key=$(grep "^MODULES_SIGN_KEY=" /etc/portage/make.conf | cut -f2 -d= | sed 's/"//g')
+ fi
+ if [[ ! $mok_certificate && -f /etc/portage/make.conf ]]; then
+ mok_certificate=$(grep "^MODULES_SIGN_CERT=" /etc/portage/make.conf | cut -f2 -d= | sed 's/"//g')
+ fi
+ if [[ ! $mok_signing_key && -f ${kernel_config} ]]; then
+ mok_signing_key=$(grep "^CONFIG_MODULE_SIG_KEY=" "${kernel_config}" | cut -f2 -d= | sed 's/"//g')
+ # Kernel module signing facility requires PEM files containing both
+ # the key and the certificate, so in this case both will be the same.
+ mok_certificate=${mok_signing_key}
+ fi
;;
esac
fi
- if [[ ! ${mok_signing_key} ]]; then
+ if [[ ! $mok_signing_key ]]; then
mok_signing_key="/var/lib/dkms/mok.key"
fi
echo "Signing key: $mok_signing_key"
- if [[ ! ${mok_certificate} ]]; then
+ if [[ ! $mok_certificate ]]; then
mok_certificate="/var/lib/dkms/mok.pub"
fi
echo "Public certificate (MOK): $mok_certificate"
# scripts/sign-file.c in kernel source also supports using "pkcs11:..." as private key
- if [[ $mok_signing_key != "pkcs11:"* ]] && ( [[ ! -f $mok_signing_key || ! -f $mok_certificate ]] ); then
+ if [[ $mok_signing_key != "pkcs11:"* ]] && [[ ! -f $mok_signing_key || ! -f $mok_certificate ]]; then
echo "Certificate or key are missing, generating self signed certificate for MOK..."
if ! command -v openssl >/dev/null; then
echo "openssl not found, can't generate key and certificate."
- return
+ return 1
fi
+ # Requires OpenSSL >= 1.1.1 for -addext
openssl req -new -x509 -nodes -days 36500 -subj "/CN=DKMS module signing key" \
-newkey rsa:2048 -keyout "$mok_signing_key" \
+ -addext "extendedKeyUsage=codeSigning" \
-outform DER -out "$mok_certificate" > /dev/null 2>&1
if [[ ! -f ${mok_signing_key} ]]; then
echo "Key file ${mok_signing_key} not found and can't be generated, modules won't be signed"
- return
+ return 1
fi
fi
if [[ ! -f ${mok_certificate} ]]; then
echo "Certificate file ${mok_certificate} not found and can't be generated, modules won't be signed"
- return
+ return 1
fi
+
+ return 0
}
prepare_signing()
{
+ # Lazy source in signing related configuration
+ read_framework_conf "$dkms_framework_signing_variables"
+
do_signing=0
if [[ ! -f ${kernel_config} ]]; then
@@ -1026,12 +1295,14 @@ prepare_signing()
sign_file="/usr/src/linux-headers-$kernelver/scripts/sign-file"
fi
;;
+ gentoo* )
+ sign_file="/usr/src/linux-$kernelver/scripts/sign-file"
+ ;;
esac
if [[ ! -f ${sign_file} ]]; then
sign_file="$install_tree/$kernelver/build/scripts/sign-file"
fi
fi
- echo ""
echo "Sign command: $sign_file"
if [[ ! -f ${sign_file} || ! -x ${sign_file} ]]; then
@@ -1039,20 +1310,33 @@ prepare_signing()
return
fi
- prepare_mok
-
- do_signing=1
+ if prepare_mok; then
+ do_signing=1
+ fi
}
-# Get ready to build a module that has been registered with DKMS.
-prepare_build()
+# Build a module that has been registered with DKMS.
+do_build()
{
+ [[ $kernelver && $arch ]] || die 16 "do_build: Empty \$kernelver or \$arch"
+
# If the module has not been added, try to add it.
- is_module_added "$module" "$module_version" || add_module
+ if ! is_module_added "$module" "$module_version" ; then
+ add_module
+ echo ""
+ fi
- local -r base_dir="$dkms_tree/$module/$module_version/$kernelver/$arch"
- local -r build_dir="$dkms_tree/$module/$module_version/build"
local -r source_dir="$dkms_tree/$module/$module_version/source"
+ local -r build_dir="$dkms_tree/$module/$module_version/build"
+ local -r kernelver_dir="$dkms_tree/$module/$module_version/$kernelver"
+ local -r base_dir="$kernelver_dir/$arch"
+ local -r build_log="$build_dir/make.log"
+ local bd
+ local bd_missing
+ local status
+ local mvka
+ local count
+ local index
# Check that the module has not already been built for this kernel
[[ -d $base_dir ]] && die 3 \
@@ -1061,160 +1345,239 @@ prepare_build()
# Read the conf file
set_module_suffix "$kernelver"
- read_conf_or_die "$kernelver" "$arch"
+ read_conf_strict_or_die "$kernelver" "$arch"
# Error out if build_exclude is set
[[ $build_exclude ]] && diewarn 77 \
"The $base_dir/dkms.conf"\
- "for module $module includes a BUILD_EXCLUSIVE directive"\
+ "for module $module/$module_version includes a BUILD_EXCLUSIVE directive"\
"which does not match this kernel/arch/config."\
"This indicates that it should not be built."
# Error out if source_tree is basically empty (binary-only dkms tarball w/ --force check)
- (($(ls $source_dir | wc -l | awk {'print $1'}) < 2)) && die 8 \
+ # shellcheck disable=SC1083,SC2012
+ # TODO: use find instead of ls
+ (($(ls "$source_dir" | wc -l | awk {'print $1'}) < 2)) && die 8 \
"The directory $source_dir does not appear to have module source located within it."\
"Build halted."
- # Set up temporary build directory for build
- rm -rf "$build_dir"
- cp -a "$source_dir/" "$build_dir"
-
- cd "$build_dir"
-
- # Apply any patches
- for p in "${patch_array[@]}"; do
- [[ ! -e $build_dir/patches/$p ]] && \
- report_build_problem 5 \
- " Patch $p as specified in dkms.conf cannot be" \
- "found in $build_dir/patches/."
- invoke_command "patch -p1 < ./patches/$p" "applying patch $p" || \
- report_build_problem 6 "Application of patch $p failed." \
- "Check $build_dir for more information."
- done
+ prepare_kernel_and_signing
if [[ -f $kernel_source_dir/.kernelvariables ]]; then
- export CC=$(echo -e "show-%:\n\t@echo \$(\$*)\ninclude $kernel_source_dir/.kernelvariables" | make -f - show-CC)
+ CC=$(echo -e "show-%:\n\t@echo \$(\$*)\ninclude $kernel_source_dir/.kernelvariables" | make -f - show-CC)
+ export CC
else
unset CC
fi
if [[ -e "${kernel_config}" ]]; then
- local cc=$(sed -n 's|^CONFIG_CC_VERSION_TEXT="\([^ ]*\) .*"|\1|p' "${kernel_config}")
+ local cc
+ # Depending on the kernel version the strings might be formatted differently (with or without quotes):
+ #
+ # $ grep CONFIG_CC_VERSION_TEXT= /lib/modules/5.15.0-141-generic/build/.config
+ # CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
+ # $ grep CONFIG_CC_VERSION_TEXT= /lib/modules/5.15.0-141-generic/build/include/config/auto.conf
+ # CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
+ # $ grep CONFIG_CC_VERSION_TEXT= /lib/modules/6.8.0-60-generic/build/.config
+ # CONFIG_CC_VERSION_TEXT="x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0"
+ # $ grep CONFIG_CC_VERSION_TEXT= /lib/modules/6.8.0-60-generic/build/include/config/auto.conf
+ # CONFIG_CC_VERSION_TEXT=x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
+ 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"
+ CC="$cc"
+ KERNEL_CC="$cc"
+ export CC
+ export KERNEL_CC
fi
if grep -q 'CONFIG_CC_IS_CLANG=y' "${kernel_config}"; then
- local cc=clang
+ local cc
+ cc=clang
if command -v "$cc" >/dev/null; then
- export CC="$cc"
- export KERNEL_CC="$cc"
+ CC="$cc"
+ KERNEL_CC="$cc"
+ export CC
+ export KERNEL_CC
fi
fi
if grep -q 'CONFIG_LD_IS_LLD=y' "${kernel_config}"; then
- local ld=ld.lld
+ local ld
+ ld=ld.lld
if command -v "$ld" >/dev/null; then
- export LD="$ld"
- export KERNEL_LD="$ld"
+ LD="$ld"
+ KERNEL_LD="$ld"
+ export LD
+ export KERNEL_LD
fi
fi
fi
- # Run the pre_build script
- run_build_script pre_build "$pre_build"
-}
-
-# Build our previously prepared source tree. prepare_build must be called
-# before calling this function.
-actual_build()
-{
- local -r base_dir="$dkms_tree/$module/$module_version/$kernelver/$arch"
- local -r build_dir="$dkms_tree/$module/$module_version/build"
- local -r build_log="$build_dir/make.log"
+ # Check for missing BUILD_DEPENDS
+ bd_missing=
+ # shellcheck disable=SC2153
+ for bd in "${BUILD_DEPENDS[@]}"; do
+ while read -r status mvka; do
+ [[ $status ]] || continue
+ [[ $status = installed ]] && continue 2
+ done <<< "$(module_status "$bd" "*" "$kernelver" "$arch")"
+ bd_missing="$bd_missing $bd"
+ done
+ if [[ $bd_missing ]]; then
+ if [[ $force ]]; then
+ warn "Trying to build module $module/$module_version for kernel $kernelver ($arch) despite of missing BUILD_DEPENDS:$bd_missing."
+ else
+ die 13 "Aborting build of module $module/$module_version for kernel $kernelver ($arch) due to missing BUILD_DEPENDS:$bd_missing."\
+ "You may override by specifying --force."
+ fi
+ fi
- echo ""
+ # Set up temporary build directory for build
+ rm -rf "${build_dir:?}"
+ CP -a "$source_dir/" "$build_dir"
- invoke_command "$clean" "Cleaning build area" '' background
- echo "DKMS make.log for $module-$module_version for kernel $kernelver ($arch)" >> "$build_log"
+ echo "DKMS (@RELEASE_STRING@) make.log for $module/$module_version for kernel $kernelver ($arch)" >> "$build_log"
date >> "$build_log"
- local the_make_command="${make_command/#make/make -j$parallel_jobs KERNELRELEASE=$kernelver}"
+
+ cd "$build_dir" || exit 15
+
+ # Apply any patches
+ for p in "${patch_array[@]}"; do
+ [[ patches/$p == *"/../"* ]] && \
+ report_build_problem 5 \
+ "Patch $p as specified in dkms.conf contains '..' path component."
+ [[ ! -e $build_dir/patches/$p ]] && \
+ report_build_problem 5 \
+ "Patch $p as specified in dkms.conf cannot be" \
+ "found in $build_dir/patches/."
+ invoke_command "patch -p1 < ./patches/$p" "Applying patch $p" "$build_log" background || \
+ report_build_problem 6 "Application of patch $p failed." \
+ "Consult $build_log for more information."
+ done
+
+ # Run the pre_build script
+ run_build_script pre_build "$pre_build" "$build_log"
+
+ local the_make_command
+ the_make_command="${make_command/#make/make -j$parallel_jobs KERNELRELEASE=$kernelver}"
invoke_command "$the_make_command" "Building module(s)" "$build_log" background || \
report_build_problem 10 "Bad return status for module build on kernel: $kernelver ($arch)" \
"Consult $build_log for more information."
# Make sure all the modules built successfully
- for ((count=0; count < ${#built_module_name[@]}; count++)); do
+ for ((count=0; count < num_modules; count++)); do
[[ -e ${built_module_location[$count]}${built_module_name[$count]}$module_uncompressed_suffix ]] && continue
report_build_problem 7 \
- " Build of ${built_module_name[$count]}$module_uncompressed_suffix failed for: $kernelver ($arch)" \
- "Make sure the name of the generated module is correct and at the root of the" \
- "build directory, or consult make.log in the build directory" \
- "$build_dir for more information."
+ "Build of ${built_module_location[$count]}${built_module_name[$count]}$module_uncompressed_suffix failed for: $kernelver ($arch)" \
+ "Make sure the name and location of the generated module are correct," \
+ "or consult $build_log for more information."
done
- cd - >/dev/null
# Build success, so create DKMS structure for a built module
- mkdir -p "$base_dir/log"
- [[ $kernel_config ]] && cp -f "$kernel_config" "$base_dir/log/"
- mv -f "$build_log" "$base_dir/log/make.log" 2>/dev/null
+ mkdir -p "$kernelver_dir"
+ local -r tmp_base_dir=$(mktemp_or_die -d "$kernelver_dir/.tmp_${arch}_XXXXXX")
+ mkdir -p "$tmp_base_dir/log"
# Save a copy of the new module
- mkdir "$base_dir/module" >/dev/null
- for ((count=0; count < ${#built_module_name[@]}; count++)); do
- local the_module="$build_dir/${built_module_location[$count]}${built_module_name[$count]}"
- local built_module="$the_module$module_uncompressed_suffix"
- local compressed_module="$the_module$module_suffix"
+ mkdir -p "$tmp_base_dir/module"
+ if [[ -f "$build_dir/Module.symvers" ]] ; then
+ CP -f "$build_dir/Module.symvers" "$tmp_base_dir/module/Module.symvers"
+ fi
+ for ((count=0; count < num_modules; count++)); do
+ local the_module
+ local built_module
+ local compressed_module
+ the_module="$build_dir/${built_module_location[$count]}${built_module_name[$count]}"
+ built_module="$the_module$module_uncompressed_suffix"
+ compressed_module="$the_module$module_suffix"
+
+ if [[ ! -f $built_module ]]; then
+ warn "$built_module has disappeared"
+ continue
+ fi
- [[ ${strip[$count]} != no ]] && strip -g "$built_module"
+ if [[ ${strip[$count]} != no ]] && [[ ${CC} == "clang" ]]; then
+ llvm-strip -g "$built_module"
+ elif [[ ${strip[$count]} != no ]]; then
+ strip -g "$built_module"
+ fi
if (( do_signing )); then
echo "Signing module $built_module"
- "$sign_file" "$sign_hash" "$mok_signing_key" "$mok_certificate" "$built_module" 2>/dev/null
+ if ! signing_command_output=$("$sign_file" "$sign_hash" "$mok_signing_key" "$mok_certificate" "$built_module" 2>&1); then
+ warn "Failed to sign module '$built_module'!" "$signing_command_output"
+ fi
fi
if [[ $module_compressed_suffix = .gz ]]; then
- gzip -9f "$built_module" || compressed_module=""
+ # shellcheck disable=SC2086
+ # splitting is intentional
+ gzip $compress_gzip_opts -f "$built_module" || compressed_module=""
elif [[ $module_compressed_suffix = .xz ]]; then
- xz --check=crc32 --lzma2=dict=1MiB -f "$built_module" || compressed_module=""
+ # shellcheck disable=SC2086
+ # splitting is intentional
+ xz $compress_xz_opts -f "$built_module" || compressed_module=""
elif [[ $module_compressed_suffix = .zst ]]; then
- zstd -q -f -T0 -19 "$built_module" || compressed_module=""
+ # shellcheck disable=SC2086
+ # splitting is intentional
+ zstd $compress_zstd_opts -f "$built_module" || compressed_module=""
fi
- if [[ -n $compressed_module ]]; then
- cp -f "$compressed_module" "$base_dir/module/${dest_module_name[$count]}$module_suffix" >/dev/null
+ if [[ $compressed_module ]]; then
+ CP -f "$compressed_module" "$tmp_base_dir/module/${dest_module_name[$count]}$module_suffix"
else
- cp -f "$built_module" "$base_dir/module/${dest_module_name[$count]}$module_uncompressed_suffix" >/dev/null
+ CP -f "$built_module" "$tmp_base_dir/module/${dest_module_name[$count]}$module_uncompressed_suffix"
fi
done
- # Run the post_build script
- run_build_script post_build "$post_build"
-}
+ # Validate build completeness
+ for ((index=0; index < num_modules; index++)); do
+ local m
+ local f
+ m=${dest_module_name[index]}
+ f=$(compressed_or_uncompressed "$tmp_base_dir/module" "$m")
+ [[ $f && -f $f ]] || die 7 "Missing module '$m' in $tmp_base_dir/module"
+ done
-# Clean up after a build.
-clean_build()
-{
- # Run the clean commands
- cd "$dkms_tree/$module/$module_version/build"
- invoke_command "$clean" "Cleaning build area" '' background
- cd - >/dev/null
+ # Rename the temporary directory
+ chmod 0755 "$tmp_base_dir"
+ mv -T "$tmp_base_dir" "$base_dir" || die 7 "do_build: final mv failed ($?)"
+
+ # Run the post_build script, requires accessible $mvka/module/
+ run_build_script post_build "$post_build" "$build_log"
+
+ cd - >/dev/null || exit 15
+
+ # Save the log file
+ mv -f "$build_log" "$base_dir/log/make.log" 2>/dev/null
# Clean the build directory
- rm -rf "$dkms_tree/$module/$module_version/build"
+ rm -rf "${build_dir:?}"
+
+ # After successful build, save dependency versions
+ if [[ $BUILD_DEPENDS_REBUILD ]] && [[ ! $force ]]; then
+ mkdir -p "$base_dir"
+ for bd in "${BUILD_DEPENDS[@]}"; do
+ local dep_version
+ dep_version=$(module_status "$bd" "*" "$kernelver" "$arch" | while read -r status mvka; do
+ [[ $status ]] || continue
+ IFS='/' read -r m v k a <<< "$mvka"
+ echo "$v"
+ done | sort -V | tail -n1)
+ [[ $dep_version ]] && echo "$dep_version" > "$base_dir/.dep_${bd}"
+ done
+ fi
}
-do_build()
+prepare_kernel_and_signing()
{
+ [[ $prepared_kernel = "$kernelver/$arch" ]] && return
+
set_kernel_source_dir_and_kconfig "$kernelver"
- prepare_kernel "$kernelver" "$arch"
- # Lazy source in signing related configuration
- read_framework_conf $dkms_framework_signing_variables
+ prepare_kernel "$kernelver"
prepare_signing
- prepare_build
- actual_build
- clean_build
+ prepared_kernel="$kernelver/$arch"
+ echo ""
}
# Force the installation of a module if this is listed
@@ -1224,17 +1587,17 @@ force_installation()
forced_modules_dir="/usr/share/dkms/modules_to_force_install"
to_force=""
if [[ -d $forced_modules_dir ]]; then
- for elem in $forced_modules_dir/*; do
+ for elem in "$forced_modules_dir/"*; do
if [[ -e $elem ]]; then
- to_force="$to_force $(cat $elem)"
+ to_force="$to_force $(cat "$elem")"
fi
done
for elem in $to_force; do
- if [[ ${1} = ${elem} ]]; then
+ if [[ ${1} = "${elem}" ]]; then
echo "force"
return 0
- elif [[ ${1}_version-override = ${elem} ]]; then
+ elif [[ ${1}_version-override = "${elem}" ]]; then
echo "version-override"
return 0
fi
@@ -1248,29 +1611,51 @@ force_installation()
# They should be split into their own functions.
do_install()
{
+ [[ $kernelver && $arch ]] || die 16 "do_install: Empty \$kernelver or \$arch"
+
# If the module has not been built, try to build it first.
is_module_built "$module" "$module_version" "$kernelver" "$arch" || do_build
- local base_dir="$dkms_tree/$module/$module_version/$kernelver/$arch"
+
+ local -r base_dir="$dkms_tree/$module/$module_version/$kernelver/$arch"
+ local -r lib_tree="$install_tree/$kernelver"
+ local -r original_module_backup_dir="$dkms_tree/$module/original_module/$kernelver/$arch"
+ local -r active_link="$dkms_tree/$module/kernel-$kernelver-$arch"
+ local count
+ local index
+ local symlink
+ [[ $symlink_modules ]] && symlink="-s"
# Save the status of $force
- tmp_force="$force"
+ local -r tmp_force="$force"
# If the module is set to be force-installed
- local ret=$(force_installation $module)
- if [[ "$ret" == "force" ]];then
+ local ret
+ ret=$(force_installation "$module")
+ if [[ "$ret" == "force" ]]; then
force="true"
echo "Forcing installation of $module"
- elif [[ "$ret" == "version-override" ]];then
+ elif [[ "$ret" == "version-override" ]]; then
force_version_override="true"
echo "Forcing version override of $module"
fi
+
# Make sure that kernel exists to install into
[[ -e $install_tree/$kernelver ]] || die 6 \
"The directory $install_tree/$kernelver doesn't exist." \
"You cannot install a module onto a non-existant kernel."
# Read the conf file
- read_conf_or_die "$kernelver" "$arch"
+ set_module_suffix "$kernelver"
+ read_conf_strict_or_die "$kernelver" "$arch"
+
+ # Validate build completeness
+ for ((index=0; index < num_modules; index++)); do
+ local m
+ local f
+ m=${dest_module_name[index]}
+ f=$(compressed_or_uncompressed "$base_dir/module" "$m")
+ [[ $f && -f $f ]] || die 6 "Missing module $m in $base_dir/module"
+ done
# Check that its not already installed (kernel symlink)
is_module_installed "$module" "$module_version" "$kernelver" "$arch" && die 5 \
@@ -1283,82 +1668,95 @@ do_install()
[[ $rpm_safe_upgrade ]] && force="true"
# Save the original_module if one exists, none have been saved before, and this is the first module for this kernel
- local lib_tree="$install_tree/$kernelver"
local any_module_installed
- local count
- echo ""
- for ((count=0; count < ${#built_module_name[@]}; count++)); do
+ if ! run_build_script pre_install "$pre_install" && ! [[ $force ]]; then
+ die 101 "pre_install failed, aborting install." \
+ "You may override by specifying --force."
+ fi
+
+ for ((count=0; count < num_modules; count++)); do
# Check this version against what is already in the kernel
check_version_sanity "$kernelver" "$arch" "$obsolete_by" "${dest_module_name[$count]}" || continue
- if ((count == 0)) && ! run_build_script pre_install "$pre_install" && ! [[ $force ]]; then
- die 101 "pre_install failed, aborting install." \
- "You may override by specifying --force."
- fi
- local m=${dest_module_name[$count]}
- local installed_modules=$(find_module "$lib_tree" "$m")
- local module_count=${#installed_modules[@]}
- local original_copy=$(compressed_or_uncompressed "$dkms_tree/$module/original_module/$kernelver/$arch" "$m")
- if [[ -L $dkms_tree/$module/kernel-$kernelver-$arch &&
- -n "$original_copy" ]]; then
+ local m
+ local installed_modules
+ local module_count
+ local original_copy
+ m=${dest_module_name[$count]}
+ installed_modules=$(find_module "$lib_tree" "$m")
+ module_count=${#installed_modules[@]}
+ original_copy=$(compressed_or_uncompressed "$original_module_backup_dir" "$m")
+ if [[ -L $active_link && $original_copy ]]; then
echo "An original module was already stored during a previous install"
- elif ! [[ -L $dkms_tree/$module/kernel-$kernelver-$arch ]]; then
- local archive_pref1=$(compressed_or_uncompressed "$lib_tree/extra" "$m")
- local archive_pref2=$(compressed_or_uncompressed "$lib_tree/updates" "$m")
- local archive_pref3=$(compressed_or_uncompressed "$lib_tree${dest_module_location[$count]}" "$m")
- local archive_pref4=""
+ elif [[ ! -L $active_link ]]; then
+ local original_module
+ local found_original
+ local archive_pref1
+ local archive_pref2
+ local archive_pref3
+ local archive_pref4
+ original_module=""
+ found_original=""
+ archive_pref1=$(compressed_or_uncompressed "$lib_tree/extra" "$m")
+ archive_pref2=$(compressed_or_uncompressed "$lib_tree/updates" "$m")
+ archive_pref3=$(compressed_or_uncompressed "$lib_tree${dest_module_location[$count]}" "$m")
+ archive_pref4=""
((module_count == 1)) && archive_pref4=${installed_modules[0]}
- local original_module=""
- local found_orginal=""
for original_module in $archive_pref1 $archive_pref2 $archive_pref3 $archive_pref4; do
[[ -f $original_module ]] || continue
echo "Found pre-existing $original_module, archiving for uninstallation"
- mkdir -p "$dkms_tree/$module/original_module/$kernelver/$arch"
- mv -f "$original_module" "$dkms_tree/$module/original_module/$kernelver/$arch/"
+ mkdir -p "$original_module_backup_dir"
+ mv -f "$original_module" "$original_module_backup_dir/"
+ echo "$original_module" > "$original_module_backup_dir/${original_module##*/}.origin"
found_original="yes"
break
done
if [[ ! $found_original ]] && ((module_count > 1)); then
echo "Multiple original modules exist, so none will be put back in place during a later uninstall"
- echo "All instances will be stored for reference purposes in $dkms_tree/$module/original_module/$kernelver/$arch/collisions/"
+ echo "All instances will be stored for reference purposes in $original_module_backup_dir/collisions/"
fi
fi
if ((module_count > 1)); then
echo "Multiple same named modules! $module_count named $m$module_suffix in $lib_tree/"
for module_dup in $(find_module "$lib_tree" "$m"); do
- dup_tree="${module_dup#$lib_tree}";
+ dup_tree="${module_dup#"${lib_tree}"}";
dup_name="${module_dup##*/}"
- dup_tree="${dup_tree/${dup_name}}"
- mkdir -p "$dkms_tree/$module/original_module/$kernelver/$arch/collisions/$dup_tree"
- mv -f $module_dup "$dkms_tree/$module/original_module/$kernelver/$arch/collisions/$dup_tree"
+ dup_tree="${dup_tree/"${dup_name}"}"
+ mkdir -p "$original_module_backup_dir/collisions/$dup_tree"
+ mv -f "$module_dup" "$original_module_backup_dir/collisions/$dup_tree/"
+ echo "$module_dup" > "$original_module_backup_dir/collisions/$dup_tree/$dup_name.origin"
done
fi
# Copy module to its location
- echo "Installing $install_tree/$kernelver${dest_module_location[$count]}/${dest_module_name[$count]}$module_suffix"
- mkdir -p $install_tree/$kernelver${dest_module_location[$count]}
- [[ $symlink_modules ]] && symlink="-s"
- local toinstall=$(compressed_or_uncompressed "$base_dir/module" "$m")
- cp -f $symlink "$toinstall" "$install_tree/$kernelver${dest_module_location[$count]}/${toinstall##*/}"
+ local toinstall
+ local dest_dir
+ local dest_name
+ toinstall=$(compressed_or_uncompressed "$base_dir/module" "$m")
+ dest_dir="$install_tree/$kernelver${dest_module_location[$count]}"
+ dest_name=${toinstall##*/}
+ echo "Installing $dest_dir/$dest_name"
+ mkdir -p "$dest_dir"
+ CP -f $symlink "$toinstall" "$dest_dir/$dest_name" || die 6 "Copying '$toinstall' failed"
any_module_installed=1
done
- if ((${#built_module_name[@]} > 0)) && [[ ! "${any_module_installed}" ]]; then
+ if ((num_modules > 0)) && [[ ! "${any_module_installed}" ]]; then
die 6 "Installation aborted."
fi
# Create the kernel- symlink to designate this version as active
- rm -f "$dkms_tree/$module/kernel-$kernelver-$arch" 2>/dev/null
- ln -s "$module_version/$kernelver/$arch" "$dkms_tree/$module/kernel-$kernelver-$arch" 2>/dev/null
+ rm -f "$active_link"
+ ln -s "$module_version/$kernelver/$arch" "$active_link"
# Add to kabi-tracking
- if [[ -z $NO_WEAK_MODULES ]]; then
- if [[ ${weak_modules} ]]; then
- echo "Adding any weak-modules"
- list_each_installed_module "$module" "$kernelver" "$arch" | ${weak_modules} ${weak_modules_no_initrd} --add-modules
+ if [[ ! $NO_WEAK_MODULES ]]; then
+ if [[ ${weak_modules_add} ]]; then
+ echo "Adding linked weak modules..."
+ list_each_installed_module "$module" "$kernelver" "$arch" | ${weak_modules_add}
fi
fi
@@ -1372,7 +1770,7 @@ do_install()
exit 6
}
- if [[ $modprobe_on_install ]]; then
+ if [[ $modprobe_on_install ]] && [[ $kernelver = "$(uname -r)" ]]; then
# Make the newly installed modules available immediately
find /sys/devices -name modalias -print0 | xargs -0 cat | sort -u | xargs modprobe -a -b -q
if [[ -f /lib/systemd/system/systemd-modules-load.service ]]; then
@@ -1382,6 +1780,9 @@ do_install()
# Restore the status of $force
force="$tmp_force"
+
+ # First check and rebuild any modules with updated dependencies
+ check_and_rebuild_dependent_modules "${kernelver[0]}" "${arch[0]}"
}
# List each kernel object that has been installed for a particular module.
@@ -1393,8 +1794,8 @@ list_each_installed_module()
local count
local real_dest_module_location
local mod
- for ((count=0; count < ${#built_module_name[@]}; count++)); do
- real_dest_module_location="$(find_actual_dest_module_location $1 $count $2 $3)"
+ for ((count=0; count < num_modules; count++)); do
+ real_dest_module_location="$(find_actual_dest_module_location "$1" "$count" "$2" "$3")"
mod=$(compressed_or_uncompressed "$install_tree/$2${real_dest_module_location}" "${dest_module_name[$count]}")
echo "$mod"
done
@@ -1404,7 +1805,7 @@ list_each_installed_module()
# A module can only be in this broken state, if the user or a faulty program
# messed up. The module then is considered volatile, because there is no reliable
# way to tell if files in the source tree are still in a valid state.
-# Therefor any action (except 'add', if only the symlink is missing)
+# Therefore any action (except 'add', if only the symlink is missing)
# to operate on the module has to be refused.
# Manual intervention by the user is required to return to a sane state.
is_module_broken() {
@@ -1422,25 +1823,19 @@ is_module_added() {
is_module_built() {
[[ $1 && $2 && $3 && $4 ]] || return 1
- local d="$dkms_tree/$1/$2/$3/$4" m=''
+ local d
+ d="$dkms_tree/$1/$2/$3/$4"
[[ -d $d/module ]] || return 1
- local default_conf="$dkms_tree/$1/$2/source/dkms.conf"
- # If a custom dkms.conf was specified use it, otherwise use the default one.
- local real_conf="${conf:-${default_conf}}"
- read_conf_or_die "$3" "$4" "$real_conf"
- set_module_suffix "$3"
- for m in "${dest_module_name[@]}"; do
- local t=$(compressed_or_uncompressed "$d/module" "$m")
- test -n "$t" || return 1
- done
}
# This assumes we have already checked to see if the module has been built.
_is_module_installed() {
[[ $1 && $2 && $3 && $4 ]] || return 1
- local d="$dkms_tree/$1/$2/$3/$4"
- local k="$dkms_tree/$1/kernel-$3-$4"
- [[ -L $k && $(readlink -f $k) = $d ]]
+ local d
+ local k
+ d="$dkms_tree/$1/$2/$3/$4"
+ k="$dkms_tree/$1/kernel-$3-$4"
+ [[ -L $k && $(readlink -f "$k") = "$d" ]]
}
# This does not.
@@ -1471,6 +1866,7 @@ maybe_install_module() (
is_module_installed "$1" "$2" "$3" "$4" && {
if [[ "$force" = "true" ]]; then
do_uninstall "$3" "$4"
+ echo ""
else
echo "Module $1/$2 already installed on kernel $3 ($4), skip." \
"You may override by specifying --force."
@@ -1481,14 +1877,14 @@ maybe_install_module() (
)
build_module() {
- local i=0
+ local i
for ((i=0; i < ${#kernelver[@]}; i++)); do
maybe_build_module "$module" "$module_version" "${kernelver[$i]}" "${arch[$i]}"
done
}
install_module() {
- local i=0
+ local i
for ((i=0; i < ${#kernelver[@]}; i++)); do
maybe_install_module "$module" "$module_version" "${kernelver[$i]}" "${arch[$i]}"
done
@@ -1504,7 +1900,7 @@ possible_dest_module_locations()
local location
location[0]="${dest_module_location[$count]}"
- [[ ${DEST_MODULE_LOCATION[$count]} != ${dest_module_location[$count]} ]] && \
+ [[ ${DEST_MODULE_LOCATION[$count]} != "${dest_module_location[$count]}" ]] && \
location[1]="${DEST_MODULE_LOCATION[$count]}"
echo "${location[@]}"
@@ -1512,11 +1908,17 @@ possible_dest_module_locations()
find_actual_dest_module_location()
{
- local module="$1"
- local count="$2"
- local kernelver="$3"
- local arch="$4"
- local locations="$(possible_dest_module_locations $count)"
+ local module
+ local count
+ local kernelver
+ local arch
+ local locations
+ module=$1
+ count=$2
+ kernelver=$3
+ arch=$4
+ locations=$(possible_dest_module_locations "$count")
+
local l
local dkms_owned
local installed
@@ -1524,7 +1926,7 @@ find_actual_dest_module_location()
for l in $locations; do
installed=$(compressed_or_uncompressed "${install_tree}/${kernelver}${l}" "${dest_module_name[${count}]}")
- if [[ -n "${installed}" ]] && compare_module_version "${dkms_owned}" "${installed}" &>/dev/null; then
+ if [[ $installed ]] && compare_module_version "${dkms_owned}" "${installed}" &>/dev/null; then
echo "${l}"
return 0
fi
@@ -1538,48 +1940,89 @@ do_uninstall()
# $1 = kernel version
# $2 = arch
- echo ""
- echo "Module $module-$module_version for kernel $1 ($2):"
+ local -r original_module_backup_dir="$dkms_tree/$module/original_module/$1/$2"
+
+ echo "Module $module/$module_version for kernel $1 ($2):"
+ # Read the conf file
set_module_suffix "$1"
+ read_conf_or_die "$1" "$2"
# If kernel- symlink points to this module, check for original_module and put it back
- local was_active=""
- local kernel_symlink=$(readlink -f "$dkms_tree/$module/kernel-$1-$2")
+ local was_active
+ local kernel_symlink
local real_dest_module_location
+ was_active=""
+ kernel_symlink=$(readlink -f "$dkms_tree/$module/kernel-$1-$2")
if [[ $kernel_symlink = $dkms_tree/$module/$module_version/$1/$2 ]]; then
was_active="true"
echo "Before uninstall, this module version was ACTIVE on this kernel."
# remove kabi-tracking if last instance removed
- if [[ -z $NO_WEAK_MODULES ]]; then
- if [[ ${weak_modules} ]] && (module_status_built $module $module_version |grep -q "installed"); then
- echo "Removing any linked weak-modules"
- list_each_installed_module "$module" "$1" "$2" | ${weak_modules} ${weak_modules_no_initrd} --remove-modules
+ if [[ ! $NO_WEAK_MODULES ]]; then
+ if [[ ${weak_modules_remove} ]] && (module_status_built "$module" "$module_version" | grep -q "installed"); then
+ echo "Removing linked weak modules..."
+ list_each_installed_module "$module" "$1" "$2" | ${weak_modules_remove}
fi
fi
- for ((count=0; count < ${#built_module_name[@]}; count++)); do
- real_dest_module_location="$(find_actual_dest_module_location $module $count $1 $2)"
+ for ((count=0; count < num_modules; count++)); do
+ local m
+ m=${dest_module_name[$count]}
+
+ real_dest_module_location="$(find_actual_dest_module_location "$module" "$count" "$1" "$2")"
if [[ ${real_dest_module_location} ]]; then
- echo "Deleting $install_tree/$1${real_dest_module_location}/${dest_module_name[$count]}$module_suffix"
- rm -f "$install_tree/$1${real_dest_module_location}/${dest_module_name[$count]}$module_uncompressed_suffix"*
+ echo "Deleting $install_tree/$1${real_dest_module_location}/$m$module_suffix"
+ rm -f "${install_tree:?}/$1${real_dest_module_location}/$m$module_uncompressed_suffix"*
dir_to_remove="${real_dest_module_location#/}"
- while [[ ${dir_to_remove} != ${dir_to_remove#/} ]]; do
+ while [[ ${dir_to_remove} != "${dir_to_remove#/}" ]]; do
dir_to_remove="${dir_to_remove#/}"
done
- (if cd "$install_tree/$1"; then rpm -qf "${dir_to_remove}" >/dev/null 2>&1 || rmdir -p --ignore-fail-on-non-empty "${dir_to_remove}"; fi || true)
+
+ case "$running_distribution" in
+ debian* | ubuntu* | arch* | gentoo*)
+ (if cd "$install_tree/$1"; then rmdir -p --ignore-fail-on-non-empty "${dir_to_remove}"; fi || true)
+ ;;
+ *)
+ (if cd "$install_tree/$1"; then rpm -qf "${dir_to_remove}" >/dev/null 2>&1 || rmdir -p --ignore-fail-on-non-empty "${dir_to_remove}"; fi || true)
+ ;;
+ esac
else
- echo "Module was not found within $install_tree/$1/"
+ echo "Module $m$module_suffix was not found within $install_tree/$1/"
+ fi
+ if [[ -d $original_module_backup_dir ]]; then
+ local origin_file
+ while IFS= read -r origin_file
+ do
+ [[ $origin_file ]] || continue
+ local original_module
+ original_module=${origin_file%.origin}
+ [[ -f $original_module ]] || continue
+ local original_location
+ original_location=$(head -n 1 "$origin_file")
+ case $original_location in
+ "$install_tree/$1/"*)
+ echo "Restoring archived original module $original_location"
+ mkdir -p "${original_location%/*}"
+ mv -f "$original_module" "$original_location"
+ rm -f "$origin_file"
+ ;;
+ *) warn "Bad original location '$original_location' in $origin_file"
+ ;;
+ esac
+ done <<< "$(find "$original_module_backup_dir" -type f -name "$m.*.origin")"
+ find "${original_module_backup_dir%/*}" -type d -empty -delete
fi
- local origmod=$(compressed_or_uncompressed "$dkms_tree/$module/original_module/$1/$2" "${dest_module_name[$count]}")
- if [[ -n $origmod ]]; then
+ local origmod
+ origmod=$(compressed_or_uncompressed "$original_module_backup_dir" "$m")
+ if [[ $origmod ]]; then
+ # Module was archived by older dkms versions without creating .origin
echo "Restoring archived original module"
mkdir -p "$install_tree/$1${DEST_MODULE_LOCATION[$count]}/"
mv -f "$origmod" "$install_tree/$1${DEST_MODULE_LOCATION[$count]}/" 2>/dev/null
fi
done
- rm -f "$dkms_tree/$module/kernel-$1-$2"
+ rm -f "${dkms_tree:?}/$module/kernel-$1-$2"
else
echo "This module version was INACTIVE for this kernel."
fi
@@ -1588,21 +2031,19 @@ do_uninstall()
run_build_script post_remove "$post_remove"
# Run depmod because we changed $install_tree
- invoke_command "do_depmod $1" "Running depmod" '' background
+ if [[ ! $delayed_depmod ]]; then
+ invoke_command "do_depmod $1" "Running depmod" '' background
+ else
+ touch "$dkms_tree/depmod-pending-$1-$2"
+ fi
# Delete the original_module if nothing for this kernel is installed anymore
- if [[ $was_active && -d $dkms_tree/$module/original_module/$1/$2 && ! -d $dkms_tree/$module/original_module/$1/$2/collisions ]]; then
- echo ""
- echo "Removing original_module from DKMS tree for kernel $1 ($2)"
- rm -rf "$dkms_tree/$module/original_module/$1/$2" 2>/dev/null
- [[ $(find $dkms_tree/$module/original_module/$1/* -maxdepth 0 -type d 2>/dev/null) ]] || rm -rf "$dkms_tree/$module/original_module/$1"
- elif [[ $was_active && -d $dkms_tree/$module/original_module/$1/$2/collisions ]]; then
- echo ""
- echo "Keeping directory $dkms_tree/$module/original_module/$1/$2/collisions/"
- echo "for your reference purposes. Your kernel originally contained multiple"
- echo "same-named modules and this directory is now where these are located."
+ if [[ $was_active && -d $dkms_tree/$module/original_module/$1/$2 ]]; then
+ echo "Removing original module(s) from DKMS tree for kernel $1 ($2)"
+ rm -rf "${dkms_tree:?}/$module/original_module/$1/$2" 2>/dev/null
+ [[ $(find "$dkms_tree/$module/original_module/$1/"* -maxdepth 0 -type d 2>/dev/null) ]] || rm -rf "${dkms_tree:?}/$module/original_module/$1"
fi
- [[ $(find $dkms_tree/$module/original_module/* -maxdepth 0 -type d 2>/dev/null) ]] || rm -rf "$dkms_tree/$module/original_module"
+ [[ $(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() {
@@ -1614,13 +2055,13 @@ module_is_broken_and_die() {
module_is_added_or_die()
{
is_module_added "$module" "$module_version" || die 3 \
- "The module/version combo: $module-$module_version is not located in the DKMS tree."
+ "The module/version combo: $module/$module_version is not located in the DKMS tree."
}
maybe_unbuild_module()
{
is_module_built "$module" "$module_version" "$1" "$2" || {
- echo "Module $module $module_version is not built for kernel $1 ($2)."\
+ echo "Module $module/$module_version is not built for kernel $1 ($2)."\
"Skipping..."
return 0
}
@@ -1631,7 +2072,7 @@ maybe_unbuild_module()
maybe_uninstall_module()
{
is_module_installed "$module" "$module_version" "$1" "$2" || {
- echo "Module $module $module_version is not installed for kernel $1 ($2)."\
+ echo "Module $module/$module_version is not installed for kernel $1 ($2)."\
"Skipping..."
return 0
}
@@ -1642,6 +2083,7 @@ uninstall_module()
{
local i
for ((i=0; i < ${#kernelver[@]}; i++)); do
+ [[ $i = 0 ]] || echo ""
maybe_uninstall_module "${kernelver[$i]}" "${arch[$i]}"
done
}
@@ -1649,17 +2091,18 @@ uninstall_module()
do_unbuild()
{
# Delete or "unbuild" the $kernel_version/$arch_used part of the tree
- rm -rf "$dkms_tree/$module/$module_version/$1/$2"
- [[ $(find $dkms_tree/$module/$module_version/$1/* -maxdepth 0 -type d 2>/dev/null) ]] || \
- rm -rf "$dkms_tree/$module/$module_version/$1"
+ rm -rf "${dkms_tree:?}/$module/$module_version/$1/$2"
+ [[ $(find "${dkms_tree:?}/$module/$module_version/$1/"* -maxdepth 0 -type d 2>/dev/null) ]] || \
+ rm -rf "${dkms_tree:?}/$module/$module_version/$1"
}
-# Remove the build module, w/o removing/unregistering it.
+# Remove the built module, w/o removing/unregistering it.
# This uninstalls any installed modules along the way
unbuild_module()
{
local i
for ((i=0; i < ${#kernelver[@]}; i++)); do
+ [[ $i = 0 ]] || echo ""
maybe_uninstall_module "${kernelver[$i]}" "${arch[$i]}"
maybe_unbuild_module "${kernelver[$i]}" "${arch[$i]}"
done
@@ -1668,16 +2111,22 @@ unbuild_module()
# Unregister a DKMS module. This uninstalls any installed modules along the way.
remove_module()
{
+ # Clean up leftover temporary directories
+ rm -rf "${dkms_tree:?}/$module/$module_version"/*/.tmp_*
+ find "$dkms_tree/$module/$module_version/" -maxdepth 1 -type d -empty -delete
+
# Do --rpm_safe_upgrade check (exit out and don't do remove if inter-release RPM upgrade scenario occurs)
if [[ $rpm_safe_upgrade ]]; then
- local pppid=$(awk '/PPid:/ {print $2}' /proc/$PPID/status)
- local time_stamp=$(ps -o lstart --no-headers -p $pppid 2>/dev/null)
- for lock_file in $tmp_location/dkms_rpm_safe_upgrade_lock.$pppid.*; do
+ local pppid
+ local time_stamp
+ pppid=$(awk '/PPid:/ {print $2}' /proc/$PPID/status)
+ time_stamp=$(ps -o lstart --no-headers -p "$pppid" 2>/dev/null)
+ for lock_file in "$tmp_location/dkms_rpm_safe_upgrade_lock.$pppid".*; do
[[ -f $lock_file ]] || continue
- lock_head=$(head -n 1 $lock_file 2>/dev/null)
- lock_tail=$(tail -n 1 $lock_file 2>/dev/null)
- [[ $lock_head = $module-$module_version && $time_stamp && $lock_tail = $time_stamp ]] || continue
- rm -f $lock_file
+ lock_head=$(head -n 1 "$lock_file" 2>/dev/null)
+ lock_tail=$(tail -n 1 "$lock_file" 2>/dev/null)
+ [[ $lock_head = $module-$module_version && $time_stamp && $lock_tail = "$time_stamp" ]] || continue
+ rm -f "${lock_file:?}"
die 0 "Remove cancelled because --rpm_safe_upgrade scenario detected."
done
fi
@@ -1686,35 +2135,40 @@ remove_module()
for ((i=0; i < ${#kernelver[@]}; i++)); do
maybe_uninstall_module "${kernelver[$i]}" "${arch[$i]}"
maybe_unbuild_module "${kernelver[$i]}" "${arch[$i]}"
+ echo ""
done
# Delete the $module_version part of the tree if no other $module_version/$kernel_version dirs exist
- if ! find $dkms_tree/$module/$module_version/* -maxdepth 0 -type d 2>/dev/null | grep -Eqv "(build|tarball|driver_disk|rpm|deb|source)$"; then
- echo ""
- echo "Deleting module $module-$module_version completely from the DKMS tree."
- rm -rf "$dkms_tree/$module/$module_version"
+ if ! find "$dkms_tree/$module/$module_version/"* -maxdepth 0 -type d 2>/dev/null | grep -Eqv "(build|tarball|driver_disk|rpm|deb|source)$"; then
+ echo "Deleting module $module/$module_version completely from the DKMS tree."
+ rm -rf "${dkms_tree:?}/$module/$module_version"
fi
# Get rid of any remnant directories if necessary
+ # shellcheck disable=SC2012
+ # TODO: use find instead
if (($(ls "$dkms_tree/$module" | wc -w | awk '{print $1}') == 0)); then
- rm -rf "$dkms_tree/$module" 2>/dev/null
+ rm -rf "${dkms_tree:?}/$module" 2>/dev/null
fi
}
# Given a kernel object, figure out which DKMS module it is from.
find_module_from_ko()
{
- local ko="$1"
- local basename_ko="${ko##*/}"
+ local ko
+ local basename_ko
+ ko="$1"
+ basename_ko="${ko##*/}"
+
local module
local kernellink
for kernellink in "$dkms_tree"/*/kernel-*; do
[[ -L $kernellink ]] || continue
- module=${kernellink#$dkms_tree/}
+ module=${kernellink#"${dkms_tree}/"}
module=${module%/kernel-*}
diff "$kernellink/module/${basename_ko}" "${ko}" >/dev/null 2>&1 || continue
- rest=$(readlink $kernellink)
+ rest=$(readlink "$kernellink")
echo "$module/$rest"
return 0
done
@@ -1728,24 +2182,44 @@ find_module_from_ko()
module_status_weak() {
# $1 = module, $2 = module version, $3 = kernel version weak installed to,
# $4 = kernel arch, $5 = kernel version built for
- [[ -z $NO_WEAK_MODULES ]] || return 1
- [[ $weak_modules ]] || return 1
- local m v k a kern weak_ko mod installed_ko f ret=1 oifs=$IFS
+ [[ $NO_WEAK_MODULES ]] || return 1
+ [[ $weak_modules_add ]] && [[ $weak_modules_remove ]] || return 1
+ local m
+ local v
+ local k
+ local a
+ local kern
+ local weak_ko
+ local mod
+ local installed_ko
+ local f
+ local ret
+ local oifs
+ ret=1
+ oifs=$IFS
+
local -A already_found
for weak_ko in "$install_tree/"*/weak-updates/*; do
[[ -e $weak_ko ]] || continue
- [[ -L $weak_ko ]] && installed_ko="$(readlink -f "$weak_ko")" || continue
- IFS=/ read m v k a < <(IFS=$oifs find_module_from_ko "$weak_ko") || continue
- kern=${weak_ko#$install_tree/}
+ if [[ -L $weak_ko ]]; then
+ installed_ko="$(readlink -f "$weak_ko")"
+ else
+ continue
+ fi
+ IFS=/ read -r m v k a <<< "$(IFS=$oifs find_module_from_ko "$weak_ko")"
+ [[ $m ]] || continue
+ kern=${weak_ko#"${install_tree}/"}
kern=${kern%/weak-updates/*}
- [[ $m = ${1:-*} && $v = ${2:-*} && $k = ${5:-*} && $a = ${4:-*} && $kern = ${3:-*} ]] || continue
+ [[ $m = "${1:-*}" && $v = "${2:-*}" && $k = "${5:-*}" && $a = "${4:-*}" && $kern = "${3:-*}" ]] || continue
already_found[$m/$v/$kern/$a/$k]+=${weak_ko##*/}" "
done
# Check to see that all ko's are present for each module
- for mod in ${!already_found[@]}; do
- IFS=/ read m v k a kern <<< "$mod"
+ for mod in "${!already_found[@]}"; do
+ IFS=/ read -r m v k a kern <<< "$mod"
# ensure each module is weak linked
- for installed_ko in $(find $dkms_tree/$m/$v/$kern/$a/module -type f); do
+ # shellcheck disable=SC2044
+ # TODO: use find + -exec instead
+ for installed_ko in $(find "$dkms_tree/$m/$v/$kern/$a/module" -type f); do
[[ ${already_found[$mod]} != *"$installed_ko"* ]] && continue 2
done
ret=0
@@ -1757,41 +2231,59 @@ module_status_weak() {
# Print the requested status lines for weak-installed modules.
do_status_weak()
{
- local mvka m v k a kern status
- while read status mvka; do
- IFS=/ read m v k a kern <<< "$mvka"
+ local mvka
+ local m
+ local v
+ local k
+ local a
+ local kern
+ local status
+ while read -r status mvka; do
+ [[ $status ]] || continue
+ IFS=/ read -r m v k a kern <<< "$mvka"
echo "$m, $v, $k, $a: installed-weak from $kern"
- done < <(module_status_weak "$@")
+ done <<< "$(module_status_weak "$@")"
}
# Spit out all the extra status information that people running DKMS are
# interested in, but that the DKMS internals do not usually care about.
module_status_built_extra() (
set_module_suffix "$3"
- read_conf "$3" "$4" "$dkms_tree/$1/$2/source/dkms.conf" 2>/dev/null
- [[ -d $dkms_tree/$1/original_module/$3/$4 ]] && echo -n " (original_module exists)"
- for ((count=0; count < ${#dest_module_name[@]}; count++)); do
+ read_conf "$3" "$4" "$dkms_tree/$1/$2/source/dkms.conf"
+ [[ -d $dkms_tree/$1/original_module/$3/$4 ]] && echo -n " (Original modules exist)"
+ for ((count=0; count < num_modules; count++)); do
tree_mod=$(compressed_or_uncompressed "$dkms_tree/$1/$2/$3/$4/module" "${dest_module_name[$count]}")
- if ! [[ -n "$tree_mod" ]]; then
- echo -n " (WARNING! Missing some built modules!)"
+ if [[ ! $tree_mod ]]; then
+ echo -n " (Built modules are missing in the kernel modules folder)"
+ break
elif _is_module_installed "$@"; then
real_dest="$(find_actual_dest_module_location "$1" $count "$3" "$4")"
real_dest_mod=$(compressed_or_uncompressed "$install_tree/$3${real_dest}" "${dest_module_name[$count]}")
if ! diff -q "$tree_mod" "$real_dest_mod" >/dev/null 2>&1; then
- echo -n " (WARNING! Diff between built and installed module!)"
+ echo -n " (Differences between built and installed modules)"
+ break
fi
fi
done
)
# Return a list of all the modules that are either built or installed.
-# This and module_status do some juggling of $IFS to ensure that
+# This and list_module_version_combos do some juggling of $IFS to ensure that
# we do not get word splitting where it would be inconvenient.
module_status_built() {
- local ret=1 directory ka k a state oifs="$IFS" IFS=''
+ local ret
+ local directory
+ local ka
+ local k
+ local a
+ local state
+ local oifs
+ ret=1
+ oifs="$IFS"
+ IFS=''
for directory in "$dkms_tree/$1/$2/"${3:-+([0-9]).*}/${4:-*}; do
IFS="$oifs"
- ka="${directory#$dkms_tree/$1/$2/}"
+ ka="${directory#"${dkms_tree}/${1}/${2}/"}"
k="${ka%/*}"
a="${ka#*/}"
is_module_built "$1" "$2" "$k" "$a" || continue
@@ -1805,34 +2297,57 @@ module_status_built() {
return $ret
}
-# Return the status of all modules that have been added, built, or installed.
-module_status() {
- local oifs="$IFS" IFS='' mv m v directory ret=1
+# Return a list of all module/version combos known to DKMS.
+list_module_version_combos() {
+ local ret
+ local modv
+ local directory
+ local oifs
+ ret=1
+ oifs="$IFS"
+ IFS=''
for directory in "$dkms_tree/"${1:-*}/${2:-*}; do
IFS="$oifs"
- mv="${directory#$dkms_tree/}"
- m="${mv%/*}"
- v="${mv#*/}"
- is_module_broken "$m" "$v" && { echo "broken $m/$v"; continue; }
- is_module_added "$m" "$v" || continue
+ [[ -d $directory ]] || continue
+ modv="${directory#"${dkms_tree}/"}"
+ # skip /kernel-- -> // symlinks
+ [[ $modv != */kernel-*-* ]] || continue
+ echo "$modv"
ret=0
- module_status_built "$m" "$v" "$3" "$4" || echo "added $m/$v"
IFS=''
done
IFS="$oifs"
return $ret
}
+# Return the status of all modules that have been added, built, or installed.
+module_status() {
+ local ret
+ local m
+ local v
+ ret=1
+ while IFS='/' read -r m v; do
+ [[ $m ]] || continue
+ 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"
+ done <<< "$(list_module_version_combos "$1" "$2")"
+ return $ret
+}
+
# Print out the status in the format that people who call DKMS expect.
# Internal callers should use the module_status functions, as their output
# is easier to parse.
do_status() {
- local status mvka m v k a
- # separate deprecation warnings from status output
- local tmpfile=$(mktemp_or_die)
- (module_status "$@") >"$tmpfile"
- while read status mvka; do
- IFS=/ read m v k a <<< "$mvka"
+ local status
+ local mvka
+ local m
+ local v
+ local k
+ local a
+ while read -r status mvka; do
+ IFS=/ read -r m v k a <<< "$mvka"
case $status in
broken)
echo "$m/$v: $status"
@@ -1848,15 +2363,14 @@ do_status() {
echo
;;
esac
- done < "$tmpfile"
- rm "$tmpfile"
+ done <<< "$(module_status "$@")"
}
# Show all our status in the format that external callers expect, even
# though it is slightly harder to parse.
show_status()
{
- local j state_array
+ local j
if ((${#kernelver[@]} == 0)); then
do_status "$module" "$module_version" "$kernelver" "$arch"
do_status_weak "$module" "$module_version" "$kernelver" "$arch"
@@ -1873,20 +2387,20 @@ make_tarball()
# Read the conf file
read_conf_or_die "$kernelver" "$arch"
- local -r temp_dir_name=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX)
- make_tarball_rm_temp_dir_name="rm -rf $temp_dir_name"
- mkdir -p $temp_dir_name/dkms_main_tree
+ local -r temp_dir_name=$(mktemp_or_die -d "$tmp_location/dkms.XXXXXX")
+ make_tarball_rm_temp_dir_name="rm -rf ${temp_dir_name:?}"
+ mkdir -p "$temp_dir_name/dkms_main_tree"
if [[ $source_only ]]; then
kernel_version_list="source-only"
else
local i
for ((i=0; i<${#kernelver[@]}; i++)); do
- local -r intree_module_dir="$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}"
- local -r temp_module_dir="$temp_dir_name/dkms_main_tree/${kernelver[$i]}"
+ local intree_module_dir="$dkms_tree/$module/$module_version/${kernelver[$i]}/${arch[$i]}"
+ local temp_module_dir="$temp_dir_name/dkms_main_tree/${kernelver[$i]}"
if ! [[ -d "$intree_module_dir" ]]; then
- die 6 "No modules built for ${kernelver[$i]} (${arch[$i]})." \
+ die 6 "No modules built for ${kernelver[$i]} (${arch[$i]})." \
"Modules must already be in the built state before using mktarball."
fi
@@ -1899,7 +2413,7 @@ make_tarball()
kernel_version_list="${kernel_version_list}-kernel${kernelver[$i]}-${arch[$i]}"
fi
mkdir -p "$temp_module_dir"
- cp -rf "$intree_module_dir" "$temp_module_dir"
+ CP -rf "$intree_module_dir" "$temp_module_dir"
done
fi
@@ -1916,24 +2430,27 @@ make_tarball()
echo "$module" > "$binary_only_dir/PACKAGE_NAME"
echo "$module_version" > "$binary_only_dir/PACKAGE_VERSION"
[[ ! $conf ]] && conf="$source_dir/dkms.conf"
- cp -f $conf "$binary_only_dir/" 2>/dev/null
+ CP -f "$conf" "$binary_only_dir/" 2>/dev/null
else
echo ""
echo "Marking $source_dir for archiving..."
- mkdir -p $temp_dir_name/dkms_source_tree
- cp -rf $source_dir/* $temp_dir_name/dkms_source_tree
+ mkdir -p "$temp_dir_name/dkms_source_tree"
+ CP -fprT "$source_dir/" "$temp_dir_name/dkms_source_tree"
fi
- if (( $(echo $kernel_version_list | wc -m | awk {'print $1'}) > 200 )); then
+ # shellcheck disable=SC1083
+ if (( $(echo "$kernel_version_list" | wc -m | awk {'print $1'}) > 200 )); then
kernel_version_list="manykernels"
fi
- local tarball_name="$module-$module_version-$kernel_version_list.dkms.tar.gz"
- local tarball_dest="$dkms_tree/$module/$module_version/tarball/"
+ local tarball_name
+ local tarball_dest
+ tarball_name="$module-$module_version-$kernel_version_list.dkms.tar.gz"
+ tarball_dest="$dkms_tree/$module/$module_version/tarball/"
if [[ $archive_location ]]; then
tarball_name="${archive_location##*/}"
- if [[ ${archive_location%/*} != $archive_location ]]; then
+ if [[ ${archive_location%/*} != "$archive_location" ]]; then
tarball_dest="${archive_location%/*}"
fi
fi
@@ -1949,11 +2466,11 @@ make_tarball()
[[ -w $tarball_dest ]] || die 9 "Missing write permissions for $tarball_dest."
- if ! tar -C $temp_dir_name -caf $tarball_dest/$tarball_name . 2>/dev/null; then
+ if ! tar -C "$temp_dir_name" -caf "$tarball_dest/$tarball_name" . 2>/dev/null; then
die 6 "Failed to make tarball."
fi
- eval "$make_tarball_rm_temp_dir_name"
+ eval "$make_tarball_rm_temp_dir_name"
unset make_tarball_rm_temp_dir_name
}
@@ -1986,14 +2503,14 @@ load_tarball()
fi
# Untar it into $tmp_location
- local -r temp_dir_name=$(mktemp_or_die -d $tmp_location/dkms.XXXXXX)
- load_tarball_rm_temp_dir_name="rm -rf $temp_dir_name"
- tar -xaf $archive_location -C $temp_dir_name
+ local -r temp_dir_name=$(mktemp_or_die -d "$tmp_location/dkms.XXXXXX")
+ load_tarball_rm_temp_dir_name="rm -rf ${temp_dir_name:?}"
+ tar -xaf "$archive_location" -C "$temp_dir_name"
if [[ ! -d $temp_dir_name/dkms_main_tree ]]; then
# Tarball was not generated from mktarball.
# Just find the dkms.conf file and load the source.
- conf=$(find $temp_dir_name/ -name dkms.conf 2>/dev/null | head -n 1)
+ conf=$(find "$temp_dir_name/" -name dkms.conf 2>/dev/null | head -n 1)
if [[ ! $conf ]]; then
die 3 "Tarball does not appear to be a correctly formed DKMS archive. No dkms.conf found within it."
fi
@@ -2008,7 +2525,8 @@ load_tarball()
die 7 "No valid dkms.conf in dkms_source_tree or dkms_binaries_only." \
"$archive_location is not a valid DKMS tarball."
fi
- local conf="$temp_dir_name/$loc/dkms.conf"
+ local conf
+ conf="$temp_dir_name/$loc/dkms.conf"
[[ -f $conf ]] || continue
if ! get_pkginfo_from_conf "$conf"; then
echo >&2
@@ -2017,7 +2535,7 @@ load_tarball()
fi
if is_module_added "$PACKAGE_NAME" "$PACKAGE_VERSION" && \
[[ ! $force ]]; then
- die 8 "$PACKAGE_NAME-$PACKAGE_VERSION is already added!" \
+ die 8 "$PACKAGE_NAME/$PACKAGE_VERSION is already added!" \
"Aborting."
fi
# Success!
@@ -2026,7 +2544,7 @@ load_tarball()
module="$PACKAGE_NAME"; module_version="$PACKAGE_VERSION"
echo ""
- echo "Loading tarball for $module-$module_version"
+ echo "Loading tarball for $module/$module_version"
case $loc in
dkms_source_tree)
add_source_tree "$temp_dir_name/dkms_source_tree"
@@ -2039,7 +2557,7 @@ load_tarball()
echo "Creating $source_dir"
mkdir -p "$source_dir"
echo "Copying dkms.conf to $source_dir ..."
- cp -rf "$temp_dir_name/dkms_binaries_only/dkms.conf" "$source_dir"
+ CP -rf "$temp_dir_name/dkms_binaries_only/dkms.conf" "$source_dir"
fi
;;
esac
@@ -2053,15 +2571,15 @@ load_tarball()
[[ -d $directory ]] || continue
local -r kernel_arch_to_load=${directory/*dkms_main_tree\/}
- local -r dkms_dir_location="$dkms_tree/$module/$module_version/$kernel_arch_to_load"
+ local -r dkms_dir_location=$dkms_tree/$module/$module_version/$kernel_arch_to_load
if [[ -d $dkms_dir_location && ! $force ]]; then
warn "$dkms_dir_location already exists. Skipping..."
else
echo "Loading $dkms_dir_location..."
- rm -rf $dkms_dir_location
- mkdir -p $dkms_dir_location
- cp -rf $directory/* $dkms_dir_location/
+ rm -rf "${dkms_dir_location:?}"
+ mkdir -p "$dkms_dir_location"
+ CP -rf "$directory/"* "$dkms_dir_location/"
fi
done
@@ -2083,12 +2601,13 @@ run_match()
fi
# Error out if $template_kernel = $kernel_version
- if [[ $template_kernel = $kernelver ]]; then
+ if [[ $template_kernel = "$kernelver" ]]; then
die 2 "The templatekernel and the specified kernel version are the same."
fi
# Read in the status of template_kernel
- local template_kernel_status=$(do_status '' '' $template_kernel $arch | grep ": installed")
+ local template_kernel_status
+ template_kernel_status=$(do_status '' '' "$template_kernel" "$arch" | grep ": installed")
# If $module is set, grep the status only for that module
if [[ $module ]]; then
@@ -2110,11 +2629,13 @@ run_match()
return 0
fi
- prepare_kernel "$kernelver" "$arch"
+ prepare_kernel "$kernelver"
# Iterate over the kernel_status and match kernel to the template_kernel
- while read template_line; do
+ while read -r template_line; do
+ # shellcheck disable=SC1083
template_module=$(echo "$template_line" | awk {'print $1'} | sed 's/,$//')
+ # shellcheck disable=SC1083
template_version=$(echo "$template_line" | awk {'print $2'} | sed 's/,$//')
# Print out a match header
@@ -2130,30 +2651,31 @@ run_match()
fi
maybe_build_module "$template_module" "$template_version" "$kernelver" "$arch"
maybe_install_module "$template_module" "$template_version" "$kernelver" "$arch"
- done < <(echo "$template_kernel_status")
+ done <<< "$template_kernel_status"
}
report_build_problem()
{
# If apport is on the system, files a build problem
- if [[ -x /usr/share/apport/apport ]] && which python3 >/dev/null; then
- python3 /usr/share/apport/package-hooks/dkms_packages.py -m $module -v $module_version -k ${kernelver[0]}
+ if [[ -x /usr/share/apport/apport ]] && command -v python3 >/dev/null; then
+ python3 /usr/share/apport/package-hooks/dkms_packages.py -m "$module" -v "$module_version" -k "${kernelver[0]}"
fi
die "$@"
}
# Little helper function for reading args from the commandline.
-# it automatically handles -a b and -a=b variants, and returns 1 if
+# It automatically handles -a b and -a=b variants, and returns 1 if
# we need to shift $3.
read_arg() {
# $1 = arg name
# $2 = arg value
# $3 = arg parameter
- local rematch='^[^=]*=(.*)$'
+ local rematch
+ rematch='^[^=]*=(.*)$'
if [[ $2 =~ $rematch ]]; then
- read "$1" <<< "${BASH_REMATCH[1]}"
+ read -r "$1" <<< "${BASH_REMATCH[1]}"
else
- read "$1" <<< "$3"
+ read -r "$1" <<< "$3"
# There is no way to shift our callers args, so
# return 1 to indicate they should do it instead.
return 1
@@ -2203,7 +2725,8 @@ check_rw_dkms_tree() {
# We will check the dkms.conf file to make sure it is valid
# beforehand.
add_source_tree() {
- local from=$(readlink -f $1)
+ local from
+ from=$(readlink -f "$1")
if ! [[ $from && -f $from/dkms.conf ]]; then
die 9 "$1 must contain a dkms.conf file!"
fi
@@ -2216,8 +2739,8 @@ add_source_tree() {
module_version="$PACKAGE_VERSION"
if [[ $force && -d $source_tree/$module-$module_version ]]; then
echo >&2
- echo "Forcing install of $module-$module_version"
- rm -rf "$source_tree/$module-$module_version"
+ echo "Forcing install of $module/$module_version"
+ rm -rf "${source_tree:?}/$module-$module_version"
fi
# We are already installed, just return.
@@ -2225,15 +2748,15 @@ add_source_tree() {
"$source_tree/$module-$module_version")
return
;;
- "$dkms_tree/$module/$version/source")
+ "$dkms_tree/$module/$module_version/source")
return
;;
- "$dkms_tree/$module/$version/build")
+ "$dkms_tree/$module/$module_version/build")
return
;;
esac
mkdir -p "$source_tree/$module-$module_version"
- cp -fr "$from"/* "$source_tree/$module-$module_version"
+ CP -fprT "$from/" "$source_tree/$module-$module_version"
}
# This code used to be in dkms_autoinstaller.
@@ -2241,69 +2764,82 @@ add_source_tree() {
# functionality, and makes it much easier to reinstall DKMS kernel modules
# by hand if dkms_autoinstaller is not used.
autoinstall() {
- local status mv mvka m v k a
- local progress next_depends
- local -a to_install=()
- 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=()
+ if [[ -f /etc/dkms/no-autoinstall ]]; then
+ echo "Automatic installation of modules has been disabled."
+ return
+ fi
+
+ local status
+ local mv
+ local mvka
+ local m
+ local v
+ local k
+ local a
+ local progress
+ local next_depends
+ local -a to_install
+ 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
# Walk through our list of installed and built modules, and create
# a list of modules and their latest version.
- while read status mvka; do
- IFS='/' read m v k a <<< "$mvka"
+ while read -r status mvka; do
+ [[ $status ]] || continue
+ IFS='/' read -r m v k a <<< "$mvka"
# If the module status is broken there is nothing that can be done
if [[ $status = broken ]]; then
error "$m/$v is broken! Missing the source directory or the symbolic link pointing to it."\
"Manual intervention is required!"
continue
fi
- if [[ -z ${latest[$m]} ]]; then
+ if [[ ! ${latest[$m]} ]]; then
known_modules[${#known_modules[@]}]="$m"
latest[$m]="$v"
elif [[ ("$(VER "$v")" > "$(VER "${latest["$m"]}")") ]]; then
latest["$m"]="$v"
fi
- done < <(module_status)
+ done <<< "$(module_status)"
# Walk through our list of known modules, and create
# a list of modules that need to be reinstalled.
for m in "${known_modules[@]}"; do
v="${latest["$m"]}"
# If the module is already installed or weak-installed, skip it.
- if _is_module_installed "$m" "$v" "$kernelver" "$arch"; then
+ if _is_module_installed "$m" "$v" "${kernelver[0]}" "${arch[0]}"; then
installed_modules[${#installed_modules[@]}]="$m"
continue
fi
- if module_status_weak "$m" "$v" "$kernelver" "$arch" >/dev/null; then
+ if module_status_weak "$m" "$v" "${kernelver[0]}" "${arch[0]}" >/dev/null; then
installed_modules[${#installed_modules[@]}]="$m"
continue
fi
# If the module does not want to be autoinstalled, skip it.
- read_conf_or_die "$kernelver" "$arch" "$dkms_tree/$m/$v/source/dkms.conf"
+ module=$m module_version=$v read_conf_or_die "${kernelver[0]}" "${arch[0]}" "$dkms_tree/$m/$v/source/dkms.conf"
if [[ ! $AUTOINSTALL ]]; then
continue
fi
# Otherwise, autoinstall the latest version we have hanging around.
to_install[${#to_install[@]}]="$m/$v"
- build_depends["$m"]="${BUILD_DEPENDS[@]}"
+ build_depends["$m"]="${BUILD_DEPENDS[*]}"
done
- [[ $to_install ]] || return 0
+ [[ ${#to_install[@]} -eq 0 ]] && return 0
while true; do
progress=0
next_install=( )
# Step 1: Remove installed modules from all dependency lists.
- for m in ${!build_depends[@]}; do
+ for m in "${!build_depends[@]}"; do
next_depends=
for d in ${build_depends[$m]}; do
- for i in ${installed_modules[@]} ${skipped_modules[@]}; do
+ for i in "${installed_modules[@]}" "${skipped_modules[@]}"; do
[[ "$d" = "$i" ]] && continue 2
done
next_depends+="$d "
@@ -2312,22 +2848,25 @@ autoinstall() {
done
# Step 2: Install modules that have an empty dependency list.
- for mv in "${to_install[@]}"; do
- IFS=/ read m v <<< "$mv"
- if [[ -z ${build_depends[$m]} ]]; then
- (module="$m" module_version="$v" kernelver="$kernelver" arch="$arch" install_module)
+ for modv in "${to_install[@]}"; do
+ IFS=/ read -r m v <<< "$modv"
+ if [[ ! ${build_depends[$m]} ]]; then
+ is_module_built "$m" "$v" "${kernelver[0]}" "${arch[0]}" || prepare_kernel_and_signing
+ echo "Autoinstall of module $m/$v for kernel ${kernelver[0]} (${arch[0]})"
+ (module="$m" module_version="$v" kernelver="${kernelver[0]}" arch="${arch[0]}" install_module)
status=$?
if (( status == 0 )); then
installed_modules[${#installed_modules[@]}]="$m"
- progress=$(($progress +1))
+ progress=$((progress +1))
elif (( status == 77 )); then
skipped_modules[${#skipped_modules[@]}]="$m"
- progress=$(($progress +1))
+ progress=$((progress +1))
else
failed_modules[${#failed_modules[@]}]="$m($status)"
fi
+ echo ""
else
- next_install[${#next_install[@]}]="$mv"
+ next_install[${#next_install[@]}]="$modv"
fi
done
@@ -2344,19 +2883,19 @@ autoinstall() {
done
if (( ${#installed_modules[@]} > 0 )); then
- echo "Autoinstall on $kernelver succeeded for module(s) ${installed_modules[@]}."
+ echo "Autoinstall on ${kernelver[0]} succeeded for module(s) ${installed_modules[*]}."
fi
if (( ${#skipped_modules[@]} > 0 )); then
- echo "Autoinstall on $kernelver was skipped for module(s) ${skipped_modules[@]}."
+ echo "Autoinstall on ${kernelver[0]} was skipped for module(s) ${skipped_modules[*]}."
fi
if (( ${#failed_modules[@]} > 0 )); then
- echo "Autoinstall on $kernelver failed for module(s) ${failed_modules[@]}."
+ echo "Autoinstall on ${kernelver[0]} failed for module(s) ${failed_modules[*]}."
fi
for mv in "${to_install[@]}"; do
- IFS=/ read m v <<< "$mv"
+ IFS=/ read -r m v <<< "$mv"
echo "$m/$v autoinstall failed due to missing dependencies: ${build_depends[$m]}."
done
@@ -2366,6 +2905,228 @@ autoinstall() {
fi
}
+# This is roughly the inverse action to 'autoinstall'. It is supposed to be
+# called before upgrade of a kernel to first remove all modules that are
+# currently built or installed for that kernel to ensure they get rebuilt
+# by kernel_postinst later on.
+# Upon initial installation of a kernel this is a no-op.
+#
+# Ideally we should only mark them as needing a rebuild instead of removing
+# them right away, but such functionality is yet to be implemented.
+kernel_preinst()
+{
+ local m
+ local v
+ local failed
+
+ have_one_kernel kernel_prerm
+
+ # run depmod only once after uninstalling all dkms modules
+ delayed_depmod=1
+
+ while IFS='/' read -r m v; do
+ is_module_built "$m" "$v" "${kernelver[0]}" "${arch[0]}" || continue
+ read_conf_or_die "${kernelver[0]}" "${arch[0]}" "$dkms_tree/$m/$v/source/dkms.conf"
+ [[ $AUTOINSTALL ]] || continue
+ echo "dkms: removing module $m/$v for kernel ${kernelver[0]} (${arch[0]})" >&2
+ (module="$m" module_version="$v" unbuild_module) || failed="$failed $m/$v($?)"
+ done <<< "$(list_module_version_combos)"
+
+ if [[ -f $dkms_tree/depmod-pending-${kernelver[0]}-${arch[0]} ]]; then
+ rm -f "${dkms_tree:?}/depmod-pending-${kernelver[0]}-${arch[0]}"
+ invoke_command "do_depmod $1" "Running depmod" '' background
+ fi
+ delayed_depmod=
+
+ # clean leftover empty directories
+ [[ ! -d $install_tree/${kernelver[0]} ]] || find "$install_tree/${kernelver[0]}" -type d -empty -delete
+
+ [[ ! $failed ]] || die 14 "dkms kernel_preinst for kernel ${kernelver[0]} (${arch[0]}) failed for module(s)$failed."
+}
+
+# A wrapper for 'autoinstall', to be used in combination with 'kernel_prerm'.
+kernel_postinst()
+{
+ local m
+ local v
+ local failed
+
+ have_one_kernel kernel_postinst
+
+ autoinstall
+}
+
+# This is roughly the inverse action to 'autoinstall'. It is supposed to be
+# called upon removal of a kernel to also remove all modules (including
+# those with AUTOINSTALL="") that were built or installed for that kernel.
+#
+# Compromise on using 'unbuild' to remove the module when a kernel is being
+# removed. The 'remove' command is too destructive. The 'uninstall' command
+# leaves built files around that have no other trigger to 'unbuild' them.
+# (Triggering 'unbuild' on kernel header removal would not be a good idea
+# because that would also cause the module to be uninstalled for the kernel,
+# even though only the headers are being removed.)
+kernel_prerm()
+{
+ local m
+ local v
+ local failed
+
+ have_one_kernel kernel_prerm
+
+ # run depmod only once after uninstalling all dkms modules
+ delayed_depmod=1
+
+ while IFS='/' read -r m v; do
+ [[ $m ]] || continue
+ is_module_built "$m" "$v" "${kernelver[0]}" "${arch[0]}" || continue
+ echo "dkms: removing module $m/$v for kernel ${kernelver[0]} (${arch[0]})" >&2
+ (module="$m" module_version="$v" unbuild_module) || failed="$failed $m/$v($?)"
+ echo ""
+ done <<< "$(list_module_version_combos)"
+
+ if [[ -f $dkms_tree/depmod-pending-${kernelver[0]}-${arch[0]} ]]; then
+ rm -f "${dkms_tree:?}/depmod-pending-${kernelver[0]}-${arch[0]}"
+ invoke_command "do_depmod $1" "Running depmod" '' background
+ fi
+ delayed_depmod=
+
+ # clean leftover empty directories
+ [[ ! -d $install_tree/${kernelver[0]} ]] || find "$install_tree/${kernelver[0]}" -type d -empty -delete
+
+ [[ ! $failed ]] || die 14 "dkms kernel_prerm for kernel ${kernelver[0]} (${arch[0]}) failed for module(s)$failed."
+}
+
+# Check if a module's dependencies have been updated
+check_dependencies_updated() {
+
+ local module=$1
+ local module_version=$2
+
+ # $1 = module
+ # $2 = module version
+ # $3 = kernel version
+ # $4 = arch
+
+ local deps_updated=0
+
+ # Read the module's configuration
+ set_module_suffix "$3"
+ read_conf_strict_or_die "$3" "$4"
+
+ # Check each dependency
+ for bd in "${BUILD_DEPENDS[@]}"; do
+ # Get the latest version of the dependency
+ local dep_version
+ dep_version=$(module_status "$bd" "*" "$3" "$4" | while read -r status mvka; do
+ [[ $status ]] || continue
+ IFS='/' read -r m v k a <<< "$mvka"
+ echo "$v"
+ done | sort -V | tail -n1)
+
+ # If dependency is not installed, skip it
+ [[ $dep_version ]] || continue
+
+ # Check if dependency's version has changed since last build
+ local dep_version_file="$dkms_tree/$module/$module_version/$3/$4/.dep_${bd}"
+ if [[ -f "$dep_version_file" ]]; then
+ local old_version
+ old_version=$(cat "$dep_version_file")
+ if [[ "$old_version" != "$dep_version" ]]; then
+ deps_updated=1
+ break
+ fi
+ else
+ deps_updated=1
+ break
+ fi
+ done
+
+ return $deps_updated
+}
+
+# Check and rebuild all modules with updated dependencies
+check_and_rebuild_dependent_modules() {
+
+ # $1 = kernel version
+ # $2 = arch
+
+ local -a modules_to_rebuild
+ local -a rebuilt_modules
+ local progress=1
+
+ # First pass: collect all modules that need rebuilding
+ while read -r status mvka; do
+ [[ $status ]] || continue
+ IFS='/' read -r m v k a <<< "$mvka"
+ # Skip if not built for this kernel/arch
+ [[ "$k" = "$1" && "$a" = "$2" ]] || continue
+
+ # Read module's configuration by passing module and version of the dependent module)
+ module=$m module_version=$v read_conf_or_die "$1" "$2"
+
+ # Skip if no BUILD_DEPENDS, BUILD_DEPENDS_REBUILD is not set or --force is passed
+ [[ ${#BUILD_DEPENDS[@]} -eq 0 ]] || [[ -z $BUILD_DEPENDS_REBUILD ]] || [[ $force ]] && continue
+
+ # Check if dependencies have been updated
+ if ! check_dependencies_updated "$m" "$v" "$1" "$2"; then
+ modules_to_rebuild+=("$m/$v")
+ fi
+ done <<< "$(module_status)"
+
+ # Second pass: rebuild modules in dependency order
+ while (( progress > 0 )); do
+ progress=0
+ local -a next_rebuild
+
+ # Remove already rebuilt modules from dependency lists
+ for mv in "${modules_to_rebuild[@]}"; do
+ IFS=/ read -r m v <<< "$mv"
+ module=$m module_version=$v read_conf_or_die "$1" "$2"
+
+ # Check if all dependencies are satisfied
+ # shellcheck disable=SC2034
+ local can_rebuild=1
+ for bd in "${BUILD_DEPENDS[@]}"; do
+ local dep_found=0
+ for rm in "${rebuilt_modules[@]}"; do
+ IFS=/ read -r dm <<< "$rm"
+ [[ "$dm" = "$bd" ]] && dep_found=1 && break
+ done
+ if (( ! dep_found )); then
+ can_rebuild=0
+ break
+ fi
+ done
+
+ if (( ! can_rebuild )); then
+ module=$m module_version=$v
+ echo ""
+ echo "Rebuilding module $m/$v due to updated dependencies"
+ echo ""
+ do_uninstall "$1" "$2"
+ do_unbuild "$1" "$2"
+ if do_build; then
+ do_install
+ rebuilt_modules+=("$m/$v")
+ progress=1
+ fi
+ else
+ next_rebuild+=("$m/$v")
+ fi
+ done
+ modules_to_rebuild=("${next_rebuild[@]}")
+ done
+
+ # Report any modules that couldn't be rebuilt
+ if (( ${#modules_to_rebuild[@]} > 0 )); then
+ echo "Warning: The following modules could not be rebuilt due to dependency cycles:"
+ for mv in "${modules_to_rebuild[@]}"; do
+ echo " $mv"
+ done
+ fi
+}
+
#############################
#### ####
#### Program Starts Here ####
@@ -2380,6 +3141,8 @@ umask 022
unset CC CXX CFLAGS CXXFLAGS LDFLAGS
# Set important variables
+# shellcheck disable=SC2034
+# not used now, might use later
current_kernel=$(uname -r)
current_os=$(uname -s)
running_distribution=$(distro_version) || exit
@@ -2390,21 +3153,26 @@ tmp_location=${TMPDIR:-/tmp}
verbose=""
symlink_modules=""
+# Set compression defaults
+compress_gzip_opts=""
+compress_xz_opts="--check=crc32 --lzma2=dict=1MiB"
+compress_zstd_opts="-q --rm -T0"
+
# Check that we can write temporary files
tmpfile=$(mktemp_or_die)
echo "Hello, DKMS!" > "$tmpfile"
if [[ "$(cat "$tmpfile")" != "Hello, DKMS!" ]]; then
warn "dkms will not function properly without some free space in \$TMPDIR ($tmp_location)."
fi
-rm -f "$tmpfile"
+rm -f "${tmpfile:?}"
# These can come from the environment or the config file
+# shellcheck disable=SC1091
[[ ! ${ADDON_MODULES_DIR} && -e /etc/sysconfig/module-init-tools ]] && . /etc/sysconfig/module-init-tools
addon_modules_dir="${ADDON_MODULES_DIR}"
-weak_modules="${WEAK_MODULES_BIN}"
# Source in configuration not related to signing
-read_framework_conf $dkms_framework_nonsigning_variables
+read_framework_conf "$dkms_framework_nonsigning_variables"
# Clear out command line argument variables
@@ -2428,22 +3196,24 @@ module_uncompressed_suffix=""
module_compressed_suffix=""
rpm_safe_upgrade=""
declare -a directive_array=() kernelver=() arch=()
-weak_modules=''
+weak_modules_add=''
+weak_modules_remove=''
last_mvka=''
last_mvka_conf=''
try_source_tree=''
die_is_fatal="yes"
-[ -x /sbin/weak-modules ] && weak_modules='/sbin/weak-modules'
-[ -x /usr/lib/module-init-tools/weak-modules ] && weak_modules='/usr/lib/module-init-tools/weak-modules'
no_depmod=""
+delayed_depmod=""
+prepared_kernel="none"
-action_re='^(remove|(auto|un)?install|match|mktarball|(un)?build|add|status|ldtarball|generate_mok)$'
+action_re='^(remove|(auto|un)?install|match|mktarball|(un)?build|add|status|ldtarball|generate_mok|kernel_(preinst|postinst|prerm))$'
# Parse command line arguments
while (($# > 0)); do
case $1 in
--module*|-m)
read_arg _mv "$1" "$2" || shift
+ # shellcheck disable=SC2154
parse_moduleversion "$_mv"
;;
-v)
@@ -2451,6 +3221,7 @@ while (($# > 0)); do
;;
--kernelver*|-k)
read_arg _ka "$1" "$2" || shift
+ # shellcheck disable=SC2154
parse_kernelarch "$_ka"
;;
--templatekernel*)
@@ -2509,7 +3280,7 @@ while (($# > 0)); do
read_arg install_tree "$1" "$2" || shift
;;
--symlink-modules)
- symlink_module="true"
+ symlink_modules="true"
;;
--config*)
read_arg kernel_config "$1" "$2" || shift
@@ -2520,6 +3291,7 @@ while (($# > 0)); do
;;
--arch*|-a)
read_arg _aa "$1" "$2" || shift
+ # shellcheck disable=SC2154
arch[${#arch[@]}]="$_aa"
;;
--kernelsourcedir*)
@@ -2528,6 +3300,7 @@ while (($# > 0)); do
;;
--directive*)
read_arg _da "$1" "$2" || shift
+ # shellcheck disable=SC2154
directive_array[${#directive_array[@]}]="$_da"
;;
--no-depmod)
@@ -2537,14 +3310,19 @@ while (($# > 0)); do
modprobe_on_install="true"
;;
--debug)
- export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '
+ PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '
+ export PS4
set -x
;;
-j)
read_arg parallel_jobs "$1" "$2" || shift
;;
+ --help|-h)
+ show_usage
+ exit 0
+ ;;
-*)
- error " Unknown option: $1"
+ error "Unknown option: $1"
show_usage
exit 2
;;
@@ -2570,90 +3348,144 @@ done
# Sanity checking
-# The <(cmd) idiom does not work if /proc is not mounted
-read line < <(echo "Hello, DKMS!")
-if [[ $line != "Hello, DKMS!" ]]; then
- warn "dkms will not function properly if /proc is not mounted."
-fi
-
# Error out if binaries-only is set and source-only is set
if [[ $binaries_only && $source_only ]]; then
- die 8 " You have specified both --binaries-only and --source-only." \
+ die 8 "You have specified both --binaries-only and --source-only." \
"You cannot do this."
fi
# Error if # of arches doesn't match # of kernels
if (( ${#kernelver[@]} != ${#arch[@]} && \
${#arch[@]} > 1 )); then
- die 1 " If more than one arch is specified on the command line, then there" \
+ die 1 "If more than one arch is specified on the command line, then there" \
"must be an equal number of kernel versions also specified (1:1 relationship)."
fi
# Check that kernel version and all aren't both set simultaneously
-if [[ $kernelver && $all ]]; then
- die 2 " You cannot specify a kernel version and also specify" \
+if [[ ${#kernelver[@]} -gt 0 && $all ]]; then
+ die 2 "You cannot specify a kernel version and also specify" \
"--all on the command line."
fi
# Check that arch and all aren't both set simultaneously
-if [[ $arch && $all ]]; then
- die 3 " You cannot specify an arch and also specify" \
+if [[ ${#arch[@]} -gt 0 && $all ]]; then
+ die 3 "You cannot specify an arch and also specify" \
"--all on the command line."
fi
-# Since initramfs/initrd rebuild is not requested, skip it with Redhat's weak-modules
-if [[ $weak_modules ]]; then
- weak_modules_no_initrd="--no-initramfs"
-fi
-
# Default to -j
parallel_jobs=${parallel_jobs:-$(get_num_cpus)}
# Make sure we're not passing -j0 to make; treat -j0 as just "-j"
[[ "$parallel_jobs" = 0 ]] && parallel_jobs=""
+# Require explicit --kernelver argument
+[[ $action =~ kernel_(preinst|postinst|prerm) ]] && have_one_kernel "$action"
+
setup_kernels_arches "$action"
+
+# Since initramfs/initrd rebuild is not requested, skip it with Redhat's weak-modules
+if [[ ! $NO_WEAK_MODULES ]]; then
+ case "$running_distribution" in
+ rhel*)
+ weak_modules_add='/usr/sbin/weak-modules --no-initramfs --add-modules'
+ weak_modules_remove='/usr/sbin/weak-modules --no-initramfs --remove-modules'
+ ;;
+ sles* | suse* | opensuse*)
+ # shellcheck disable=SC2016
+ weak_modules_add='/usr/lib/module-init-tools/weak-modules2 --add-kernel-modules ${kernelver}'
+ # shellcheck disable=SC2016
+ weak_modules_remove='/usr/lib/module-init-tools/weak-modules2 --remove-kernel-modules ${kernelver}'
+ ;;
+ *)
+ ;;
+ esac
+fi
+
+# Execute post-transaction command if set and log its output
+execute_post_transaction() {
+ # Blank the log file before starting
+ : > "$dkms_tree/post_transaction.log"
+
+ # Lazy source in post_transaction related configuration
+ read_framework_conf "$dkms_framework_post_transaction"
+
+ invoke_command "$post_transaction" "Executing post-transaction command" "$dkms_tree/post_transaction.log" background
+}
+
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
- [[ $action = install ]] && check_root || check_rw_dkms_tree
- ${action}_module
- ;;
-autoinstall)
- check_root && autoinstall
- ;;
-match)
- check_root && have_one_kernel "match" && run_match
- ;;
-mktarball)
- check_module_args mktarball
- module_is_broken_and_die
- module_is_added_or_die
- make_tarball
- ;;
-status)
- show_status
- ;;
-ldtarball) # Make sure they're root if we're using --force
- if [[ $(id -u) != 0 ]] && [[ $force = true ]]; then
- die 1 "You must be root to use this command with the --force option."
- fi
- load_tarball && add_module
- ;;
-generate_mok)
- read_framework_conf $dkms_framework_signing_variables
- prepare_mok
- ;;
-*)
- error "Unknown action specified: \"$action\""
- show_usage
- ;;
+ remove | unbuild | uninstall)
+ check_module_args "$action"
+ module_is_broken_and_die
+ module_is_added_or_die
+ if [[ $action = uninstall ]]; then
+ check_root
+ else
+ check_rw_dkms_tree
+ fi
+ "${action}_module"
+ ret=$?
+ # Execute post_transaction command if set
+ if [[ $ret -eq 0 && -n "$post_transaction" ]]; then
+ execute_post_transaction
+ fi
+ exit $ret
+ ;;
+ add | build | install)
+ check_all_is_banned "$action" # TODO: fix/enable --all
+ [[ $action != add ]] && module_is_broken_and_die
+ if [[ $action = install ]]; then
+ check_root
+ else
+ check_rw_dkms_tree
+ fi
+ "${action}_module"
+ ret=$?
+ # Execute post_transaction command if set
+ if [[ $ret -eq 0 && -n "$post_transaction" && $action = install ]]; then
+ execute_post_transaction
+ fi
+ exit $ret
+ ;;
+ autoinstall)
+ have_one_kernel "$action"
+ check_root && autoinstall
+ ret=$?
+ # Execute post_transaction command if set
+ if [[ $ret -eq 0 && -n "$post_transaction" && ${#installed_modules[@]} -gt 0 ]]; then
+ execute_post_transaction
+ fi
+ exit $ret
+ ;;
+ match)
+ check_root && have_one_kernel "match" && run_match
+ ;;
+ mktarball)
+ check_module_args mktarball
+ module_is_broken_and_die
+ module_is_added_or_die
+ make_tarball
+ ;;
+ status)
+ show_status
+ ;;
+ ldtarball) # Make sure they're root if we're using --force
+ if [[ $(id -u) != 0 ]] && [[ $force = true ]]; then
+ die 1 "You must be root to use this command with the --force option."
+ fi
+ load_tarball && add_module
+ ;;
+ generate_mok)
+ read_framework_conf "$dkms_framework_signing_variables"
+ prepare_mok
+ ;;
+ kernel_preinst | kernel_postinst | kernel_prerm)
+ check_root && have_one_kernel "$action" && "$action"
+ ;;
+ *)
+ error "Unknown action specified: \"$action\""
+ show_usage
+ ;;
esac
+
+# vim: et:ts=4:sw=4
diff --git a/dkms.zsh-completion.in b/dkms.zsh-completion.in
index bca4f8c..923c05b 100644
--- a/dkms.zsh-completion.in
+++ b/dkms.zsh-completion.in
@@ -38,6 +38,8 @@ if [[ -n $cmd ]]; then
curcontext="${curcontext%:*}-$cmd:"
else
# Exclude sub-commands based on any options specified so far.
+ # shellcheck disable=SC1073,SC1058,SC1072,SC1009
+ # for loop too long TODO: fix
for cmds opts in \
'(remove|build|install|uninstall|match|status|mktarball)' 'k' \
'(add|remove)' '-_safe_upgrade' \
diff --git a/dkms_autoinstaller.in b/dkms_autoinstaller.in
old mode 100755
new mode 100644
index 31c382e..2fbc4f5
--- a/dkms_autoinstaller.in
+++ b/dkms_autoinstaller.in
@@ -17,40 +17,11 @@
### END INIT INFO
-if [ -f /lib/lsb/init-functions ]; then
- . /lib/lsb/init-functions
-elif [ -f /etc/rc.d/init.d/functions ]; then
- . /etc/rc.d/init.d/functions
-fi
-
exec="@SBINDIR@/dkms"
-prog=${exec##*/}
+MODDIR="@MODDIR@"
test -f $exec || exit 0
-[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
-
-uname_s=$(uname -s)
-
-_get_kernel_dir() {
- KVER=$1
- case ${uname_s} in
- Linux) DIR="@MODDIR@/$KVER/build" ;;
- GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
- esac
- echo $DIR
-}
-
-_check_kernel_dir() {
- DIR=$(_get_kernel_dir $1)
- case ${uname_s} in
- Linux) test -e $DIR/include ;;
- GNU/kFreeBSD) test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;;
- *) return 1 ;;
- esac
- return $?
-}
-
case "$1" in
start)
if [ -n "$2" ]; then
@@ -58,13 +29,12 @@ case "$1" in
else
kernel=$(uname -r)
fi
- if [ -f /etc/dkms/no-autoinstall ]; then
- log_action_msg "Automatic installation of modules has been disabled."
- elif ! _check_kernel_dir $kernel; then
- log_action_msg "Automatic installation of modules for kernel $kernel was skipped since the kernel headers for this kernel do not seem to be installed."
+ if [ ! -d "$MODDIR/$kernel/build/include" ]; then
+ echo "Automatic installation of modules for kernel $kernel was skipped since the kernel headers for this kernel do not seem to be installed."
else
- dkms autoinstall --kernelver $kernel
+ dkms autoinstall --kernelver "$kernel"
res=$?
+ test $res = 0
fi
;;
stop|restart|force-reload|status|reload)
diff --git a/dkms_common.postinst b/dkms_common.postinst
deleted file mode 100644
index 52fb3a4..0000000
--- a/dkms_common.postinst
+++ /dev/null
@@ -1,256 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2002-2005 Flavio Stanchina
-# Copyright (C) 2005-2006 Aric Cyr
-# Copyright (C) 2007 Mario Limonciello
-# Copyright (C) 2009 Alberto Milone
-
-set -e
-
-[ -f /usr/share/debconf/confmodule ] && . /usr/share/debconf/confmodule
-
-uname_s=$(uname -s)
-
-_get_kernel_dir() {
- KVER=$1
- case ${uname_s} in
- Linux) DIR="/lib/modules/$KVER/build" ;;
- GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
- esac
- echo $DIR
-}
-
-_check_kernel_dir() {
- DIR=$(_get_kernel_dir $1)
- case ${uname_s} in
- Linux) test -e $DIR/include ;;
- GNU/kFreeBSD) test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;;
- *) return 1 ;;
- esac
- return $?
-}
-
-# Check the existence of a kernel named as $1
-_is_kernel_name_correct() {
- if [ -e "/lib/modules/$1" ]; then
- echo yes
- else
- echo no
- fi
-}
-
-
-# Get the most recent kernel on Debian based systems. This keeps
-# into account both the version and the ABI. If the current kernel
-# is the most recent kernel then the function will print a null string.
-_get_newest_kernel_debian() {
- NEWEST_KERNEL=
- NEWEST_VERSION=
- NEWEST_ABI=
-
- for kernel in /boot/config-*; do
- [ -f "$kernel" ] || continue
- KERNEL=${kernel#*-}
- KERNEL_VERSION=${KERNEL%%-*}
- ABI=${KERNEL#*-}
- ABI=${ABI%%-*}
-
- if [ -z "$NEWEST_KERNEL" ]; then
- # The 1st time get a version which is bigger than $1
- COMPARE_TO=$1
- else
- # Get the biggest version
- COMPARE_TO="$NEWEST_VERSION-$NEWEST_ABI"
- fi
-
- # if $kernel is greater than $COMPARE_TO
- if [ $(dpkg --compare-versions "$KERNEL_VERSION-$ABI" ge "$COMPARE_TO" && echo "yes" || \
- echo "no") = "yes" ]; then
- NEWEST_KERNEL=$KERNEL
- NEWEST_VERSION=$KERNEL_VERSION
- NEWEST_ABI=$ABI
- fi
- done
-
- echo "$NEWEST_KERNEL"
-}
-
-# Get the most recent kernel in Rhel based systems.
-_get_newest_kernel_rhel() {
- rpm -q --qf="%{VERSION}-%{RELEASE}.%{ARCH}\n" --whatprovides kernel | tail -n 1
-}
-
-# Get the newest kernel on Debian and Rhel based systems.
-get_newest_kernel() {
- NEWEST_KERNEL=
- # Try Debian first as rpm can be installed in Debian based distros
- if [ -e /usr/bin/dpkg ]; then
- # If DEB based
- CURRENT_VERSION=${CURRENT_KERNEL%%-*}
- CURRENT_ABI=${CURRENT_KERNEL#*-}
- CURRENT_FLAVOUR=${CURRENT_ABI#*-}
- CURRENT_ABI=${CURRENT_ABI%%-*}
- NEWEST_KERNEL=$(_get_newest_kernel_debian "$CURRENT_VERSION-$CURRENT_ABI")
-
- elif which rpm >>/dev/null 2>&1; then
- # If RPM based
- NEWEST_KERNEL=$(_get_newest_kernel_rhel)
- fi
-
- # Make sure that kernel name that we extracted corresponds to an installed
- # kernel
- if [ -n "$NEWEST_KERNEL" ] && [ $(_is_kernel_name_correct $NEWEST_KERNEL) = "no" ]; then
- NEWEST_KERNEL=
- fi
-
- echo $NEWEST_KERNEL
-}
-
-NAME=$1
-VERSION=$2
-TARBALL_ROOT=$3
-ARCH=$4
-UPGRADE=$5
-
-if [ -z "$NAME" ] || [ -z "$VERSION" ]; then
- echo "Need NAME, and VERSION defined"
- echo "ARCH is optional"
- exit 1
-fi
-
-if [ -f /etc/dkms/no-autoinstall ]; then
- echo "autoinstall for dkms modules has been disabled."
- exit 0
-fi
-
-# read framework configuration options
-if [ -r /etc/dkms/framework.conf ]; then
- . /etc/dkms/framework.conf
-fi
-
-KERNELS=$(ls -v /lib/modules/ 2>/dev/null || true)
-CURRENT_KERNEL=$(uname -r)
-
-#We never want to keep an older version side by side to prevent conflicts
-if [ -e "/var/lib/dkms/$NAME/$VERSION" ]; then
- echo "Removing old $NAME-$VERSION DKMS files..."
- dkms remove -m $NAME -v $VERSION --all
-fi
-
-#Load new files, by source package and by tarball
-if [ -f "$TARBALL_ROOT/$NAME-$VERSION.dkms.tar.gz" ]; then
- if ! dkms ldtarball --archive "$TARBALL_ROOT/$NAME-$VERSION.dkms.tar.gz"; then
- echo ""
- echo ""
- echo "Unable to load DKMS tarball $TARBALL_ROOT/$NAME-$VERSION.dkms.tar.gz."
- echo "Common causes include: "
- echo " - You must be using DKMS 2.1.0.0 or later to support binaries only"
- echo " distribution specific archives."
- echo " - Corrupt distribution specific archive"
- echo ""
- echo ""
- exit 2
- fi
-elif [ -d "/usr/src/$NAME-$VERSION" ]; then
- echo "Loading new $NAME-$VERSION DKMS files..."
- dkms add -m $NAME -v $VERSION > /dev/null
-fi
-
-# On 1st installation, let us look for a directory
-# in /lib/modules which matches $(uname -r). If none
-# is found it is possible that buildd is being used
-# and that uname -r is giving us the name of the
-# kernel used by the buildd machine.
-#
-# If this is the case we try to build the kernel
-# module for each kernel which has a directory in
-# /lib/modules. Furthermore we will have to tell
-# DKMS which architecture it should build the module
-# for (e.g. if the buildd machine is using a
-# 2.6.24-23-xen 64bit kernel).
-#
-# NOTE: if the headers are not installed then the
-# module won't be built, as usual
-
-# Here we look for the most recent kernel so that we can
-# build the module for it (in addition to doing it for the
-# current kernel.
-NEWEST_KERNEL=$(get_newest_kernel)
-
-if [ -z "$autoinstall_all_kernels" ]; then
- # If the current kernel is installed on the system or chroot
- if [ $(_is_kernel_name_correct $CURRENT_KERNEL) = "yes" ]; then
- if [ -n "$NEWEST_KERNEL" ] && [ ${CURRENT_KERNEL} != ${NEWEST_KERNEL} ]; then
- KERNELS="$CURRENT_KERNEL $NEWEST_KERNEL"
- else
- KERNELS=$CURRENT_KERNEL
- fi
- # The current kernel is not useful as it's not installed
- else
- echo "It is likely that $CURRENT_KERNEL belongs to a chroot's host"
-
- # Let's use only the newest kernel if this is not a first installation
- # otherwise build for all kernels
- if [ -n "$NEWEST_KERNEL" -a -n "$UPGRADE" ]; then
- KERNELS="$NEWEST_KERNEL"
- fi
- fi
-fi
-
-# Take care of displaying newline separated list
-echo "Building for $KERNELS" | tr '\n' ',' \
- | sed -e 's/,/, /g; s/, $/\n/; s/, \([^,]\+\)$/ and \1/'
-
-if [ -n "$ARCH" ]; then
- echo "Building for architecture $ARCH"
- ARCH="-a $ARCH"
-fi
-
-for KERNEL in $KERNELS; do
- dkms_status=$(dkms status -m $NAME -v $VERSION -k $KERNEL $ARCH)
- if [ $(echo $KERNEL | grep -c "BOOT") -gt 0 ]; then
- echo ""
- echo "Module build and install for $KERNEL was skipped as "
- echo "it is a BOOT variant"
- continue
- fi
-
-
- #if the module isn't yet built, try to build it
- if [ $(echo $dkms_status | grep -c ": built") -eq 0 ]; then
- if [ ! -L /var/lib/dkms/$NAME/$VERSION/source ]; then
- echo "This package appears to be a binaries-only package"
- echo " you will not be able to build against kernel $KERNEL"
- echo " since the package source was not provided"
- continue
- fi
- if _check_kernel_dir $KERNEL; then
- echo "Building initial module for $KERNEL"
- set +e
- dkms build -m $NAME -v $VERSION -k $KERNEL $ARCH > /dev/null
- case $? in
- 77)
- set -e
- echo "Skipped."
- continue
- ;;
- 0)
- set -e
- echo "Done."
- ;;
- *)
- exit $?
- ;;
- esac
- dkms_status=$(dkms status -m $NAME -v $VERSION -k $KERNEL $ARCH)
- else
- echo "Module build for kernel $KERNEL was skipped since the"
- echo "kernel headers for this kernel do not seem to be installed."
- fi
- fi
-
- #if the module is built (either pre-built or just now), install it
- if [ $(echo $dkms_status | grep -c ": built") -eq 1 ] &&
- [ $(echo $dkms_status | grep -c ": installed") -eq 0 ]; then
- dkms install -m $NAME -v $VERSION -k $KERNEL $ARCH
- fi
-done
diff --git a/dkms_common.postinst.in b/dkms_common.postinst.in
index fe5d037..9e76604 100644
--- a/dkms_common.postinst.in
+++ b/dkms_common.postinst.in
@@ -6,30 +6,23 @@
set -e
-uname_s=$(uname -s)
+MODDIR="@MODDIR@"
_get_kernel_dir() {
KVER=$1
- case ${uname_s} in
- Linux) DIR="@MODDIR@/$KVER/build" ;;
- GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
- esac
- echo $DIR
+ DIR="$MODDIR/$KVER/build"
+ echo "$DIR"
}
_check_kernel_dir() {
- DIR=$(_get_kernel_dir $1)
- case ${uname_s} in
- Linux) test -e $DIR/include ;;
- GNU/kFreeBSD) test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;;
- *) return 1 ;;
- esac
+ DIR=$(_get_kernel_dir "$1")
+ test -e "$DIR/include"
return $?
}
# Check the existence of a kernel named as $1
_is_kernel_name_correct() {
- if [ -e "@MODDIR@/$1" ]; then
+ if [ -e "$MODDIR/$1" ]; then
echo yes
else
echo no
@@ -61,8 +54,8 @@ _get_newest_kernel_debian() {
fi
# if $kernel is greater than $COMPARE_TO
- if [ $(dpkg --compare-versions "$KERNEL_VERSION-$ABI" ge "$COMPARE_TO" && echo "yes" || \
- echo "no") = "yes" ]; then
+ if [ "$(dpkg --compare-versions "$KERNEL_VERSION-$ABI" ge "$COMPARE_TO" && echo "yes" || \
+ echo "no")" = "yes" ]; then
NEWEST_KERNEL=$KERNEL
NEWEST_VERSION=$KERNEL_VERSION
NEWEST_ABI=$ABI
@@ -85,22 +78,24 @@ get_newest_kernel() {
# If DEB based
CURRENT_VERSION=${CURRENT_KERNEL%%-*}
CURRENT_ABI=${CURRENT_KERNEL#*-}
+ # shellcheck disable=SC2034
+ # not used now, might use it later
CURRENT_FLAVOUR=${CURRENT_ABI#*-}
CURRENT_ABI=${CURRENT_ABI%%-*}
NEWEST_KERNEL=$(_get_newest_kernel_debian "$CURRENT_VERSION-$CURRENT_ABI")
- elif which rpm >>/dev/null 2>&1; then
+ elif command -v rpm >/dev/null 2>&1; then
# If RPM based
NEWEST_KERNEL=$(_get_newest_kernel_rhel)
fi
# Make sure that kernel name that we extracted corresponds to an installed
# kernel
- if [ -n "$NEWEST_KERNEL" ] && [ $(_is_kernel_name_correct $NEWEST_KERNEL) = "no" ]; then
+ if [ -n "$NEWEST_KERNEL" ] && [ "$(_is_kernel_name_correct "$NEWEST_KERNEL")" = "no" ]; then
NEWEST_KERNEL=
fi
- echo $NEWEST_KERNEL
+ echo "$NEWEST_KERNEL"
}
NAME=$1
@@ -121,17 +116,22 @@ if [ -f /etc/dkms/no-autoinstall ]; then
fi
# read framework configuration options
-if [ -r /etc/dkms/framework.conf ]; then
- . /etc/dkms/framework.conf
-fi
+for fwcf in /etc/dkms/framework.conf /etc/dkms/framework.conf.d/*.conf ; do
+ if [ -f "$fwcf" ] && [ -r "$fwcf" ]; then
+ # shellcheck disable=SC1090
+ . "$fwcf"
+ fi
+done
-KERNELS=$(ls -dv @MODDIR@/*/build 2>/dev/null | cut -d/ -f4 || true)
+# shellcheck disable=SC2012
+# suggests to use find here instead, but that is not equivalent
+KERNELS=$(ls -dv "$MODDIR"/*/build 2>/dev/null | sed 's|'"$MODDIR"'/\(.*\)/build|\1|' || true)
CURRENT_KERNEL=$(uname -r)
#We never want to keep an older version side by side to prevent conflicts
if [ -e "/var/lib/dkms/$NAME/$VERSION" ]; then
- echo "Removing old $NAME-$VERSION DKMS files..."
- dkms remove -m $NAME -v $VERSION --all
+ echo "Removing old $NAME/$VERSION DKMS files..."
+ dkms remove -m "$NAME" -v "$VERSION" --all
fi
#Load new files, by source package and by tarball
@@ -149,8 +149,15 @@ if [ -f "$TARBALL_ROOT/$NAME-$VERSION.dkms.tar.gz" ]; then
exit 2
fi
elif [ -d "/usr/src/$NAME-$VERSION" ]; then
- echo "Loading new $NAME-$VERSION DKMS files..."
- dkms add -m $NAME -v $VERSION > /dev/null
+ echo "Loading new $NAME/$VERSION DKMS files..."
+ dkms add -m "$NAME" -v "$VERSION" > /dev/null
+fi
+
+dkms_conf="/var/lib/dkms/$NAME/$VERSION/source/dkms.conf"
+autoinstall=$(bash -c 'AUTOINSTALL=; . "'"$dkms_conf"'" >/dev/null 2>&1; echo $AUTOINSTALL')
+if [ -z "$autoinstall" ]; then
+ echo "Not building the $NAME module which does not have AUTOINSTALL enabled."
+ exit 0
fi
dkms_conf="/var/lib/dkms/$NAME/$VERSION/source/dkms.conf"
@@ -161,14 +168,14 @@ if [ -z "$autoinstall" ]; then
fi
# On 1st installation, let us look for a directory
-# in @MODDIR@ which matches $(uname -r). If none
+# in $MODDIR which matches $(uname -r). If none
# is found it is possible that buildd is being used
# and that uname -r is giving us the name of the
# kernel used by the buildd machine.
#
# If this is the case we try to build the kernel
# module for each kernel which has a directory in
-# @MODDIR@. Furthermore we will have to tell
+# $MODDIR. Furthermore we will have to tell
# DKMS which architecture it should build the module
# for (e.g. if the buildd machine is using a
# 2.6.24-23-xen 64bit kernel).
@@ -178,13 +185,13 @@ fi
# Here we look for the most recent kernel so that we can
# build the module for it (in addition to doing it for the
-# current kernel.
+# current kernel).
NEWEST_KERNEL=$(get_newest_kernel)
if [ -z "$autoinstall_all_kernels" ]; then
# If the current kernel is installed on the system or chroot
- if [ $(_is_kernel_name_correct $CURRENT_KERNEL) = "yes" ]; then
- if [ -n "$NEWEST_KERNEL" ] && [ ${CURRENT_KERNEL} != ${NEWEST_KERNEL} ]; then
+ if [ "$(_is_kernel_name_correct "$CURRENT_KERNEL")" = "yes" ]; then
+ if [ -n "$NEWEST_KERNEL" ] && [ "${CURRENT_KERNEL}" != "${NEWEST_KERNEL}" ]; then
KERNELS="$CURRENT_KERNEL $NEWEST_KERNEL"
else
KERNELS=$CURRENT_KERNEL
@@ -195,7 +202,7 @@ if [ -z "$autoinstall_all_kernels" ]; then
# Let's use only the newest kernel if this is not a first installation
# otherwise build for all kernels
- if [ -n "$NEWEST_KERNEL" -a -n "$UPGRADE" ]; then
+ if [ -n "$NEWEST_KERNEL" ] && [ -n "$UPGRADE" ]; then
KERNELS="$NEWEST_KERNEL"
fi
fi
@@ -207,46 +214,41 @@ echo "Building for $KERNELS" | tr '\n' ',' \
if [ -n "$ARCH" ]; then
echo "Building for architecture $ARCH"
- ARCH="-a $ARCH"
fi
for KERNEL in $KERNELS; do
- dkms_status=$(dkms status -m $NAME -v $VERSION -k $KERNEL $ARCH)
- if [ $(echo $KERNEL | grep -c "BOOT") -gt 0 ]; then
- echo ""
+ echo ""
+ dkms_status=$(dkms status -m "$NAME" -v "$VERSION" -k "$KERNEL" ${ARCH:+-a "$ARCH"})
+ if [ "$(echo "$KERNEL" | grep -c "BOOT")" -gt 0 ]; then
echo "Module build and install for $KERNEL was skipped as "
echo "it is a BOOT variant"
continue
fi
-
#if the module isn't yet built, try to build it
- if [ $(echo $dkms_status | grep -c ": built") -eq 0 ]; then
- if [ ! -L /var/lib/dkms/$NAME/$VERSION/source ]; then
+ if [ "$(echo "$dkms_status" | grep -c ": built")" -eq 0 ]; then
+ if [ ! -L "/var/lib/dkms/$NAME/$VERSION/source" ]; then
echo "This package appears to be a binaries-only package"
echo " you will not be able to build against kernel $KERNEL"
echo " since the package source was not provided"
continue
fi
- if _check_kernel_dir $KERNEL; then
- echo "Building initial module for $KERNEL"
- set +e
- dkms build -m $NAME -v $VERSION -k $KERNEL $ARCH > /dev/null
- case $? in
+ if _check_kernel_dir "$KERNEL"; then
+ echo "Building initial module $NAME/$VERSION for $KERNEL"
+ res=0
+ dkms build -m "$NAME" -v "$VERSION" -k "$KERNEL" ${ARCH:+-a "$ARCH"} || res=$?
+ case "$res" in
77)
- set -e
- echo "Skipped."
+ # skipped due to BUILD_EXCLUSIVE
continue
;;
0)
- set -e
- echo "Done."
;;
*)
- exit $?
+ exit $res
;;
esac
- dkms_status=$(dkms status -m $NAME -v $VERSION -k $KERNEL $ARCH)
+ dkms_status=$(dkms status -m "$NAME" -v "$VERSION" -k "$KERNEL" ${ARCH:+-a "$ARCH"})
else
echo "Module build for kernel $KERNEL was skipped since the"
echo "kernel headers for this kernel do not seem to be installed."
@@ -254,8 +256,10 @@ for KERNEL in $KERNELS; do
fi
#if the module is built (either pre-built or just now), install it
- if [ $(echo $dkms_status | grep -c ": built") -eq 1 ] &&
- [ $(echo $dkms_status | grep -c ": installed") -eq 0 ]; then
- dkms install -m $NAME -v $VERSION -k $KERNEL $ARCH
+ if [ "$(echo "$dkms_status" | grep -c ": built")" -eq 1 ] &&
+ [ "$(echo "$dkms_status" | grep -c ": installed")" -eq 0 ]; then
+ dkms install -m "$NAME" -v "$VERSION" -k "$KERNEL" ${ARCH:+-a "$ARCH"}
fi
done
+
+# vim: et:ts=4:sw=4
diff --git a/dkms_framework.conf b/dkms_framework.conf
deleted file mode 100644
index db487c0..0000000
--- a/dkms_framework.conf
+++ /dev/null
@@ -1,41 +0,0 @@
-# This configuration file modifies the behavior of DKMS (Dynamic Kernel Module
-# Support) and is sourced in by DKMS every time it is run.
-
-# Source Tree Location (default: /usr/src):
-# source_tree="/usr/src"
-
-# DKMS Tree Location (default: /var/lib/dkms):
-# dkms_tree="/var/lib/dkms"
-
-# Install Tree Location (default: /lib/modules):
-# install_tree="/lib/modules"
-
-# Temporary folder Location (default: /tmp):
-# tmp_location="/tmp"
-
-# Verbosity setting, will be active if set to a non-null value:
-# verbose=""
-
-# This creates symlinks from the install_tree into the dkms_tree instead of
-# copying the modules. This preserves some space on the costs of being less
-# safe. Symlinking will be active if set to a non-null value:
-# symlink_modules=""
-
-# Automatic installation and upgrade for all installed kernels if set to a
-# non-null value:
-# autoinstall_all_kernels=""
-
-# Location of the sign-file kernel binary. $kernelver can be used in path to
-# represent the target kernel version. (default: depends on distribution):
-# sign_file="/path/to/sign-file"
-
-# Location of the key and certificate files used for Secure boot. $kernelver
-# can be used in path to represent the target kernel version.
-# mok_signing_key can also be a "pkcs11:..." string for PKCS#11 engine, as
-# long as the sign_file program supports it.
-# (default: /var/lib/dkms):
-# mok_signing_key=/var/lib/dkms/mok.key
-# mok_certificate=/var/lib/dkms/mok.pub
-
-# Automatically modprobe the built modules upon successful installation:
-# modprobe_on_install="true"
diff --git a/dkms_framework.conf.in b/dkms_framework.conf.in
index 36543cf..73dd42d 100644
--- a/dkms_framework.conf.in
+++ b/dkms_framework.conf.in
@@ -1,5 +1,7 @@
# This configuration file modifies the behavior of DKMS (Dynamic Kernel Module
# Support) and is sourced in by DKMS every time it is run.
+# Additionally to /etc/dkms/framework.conf, any file matching the glob
+# /etc/dkms/framework.conf.d/*.conf will be loaded as well.
# Source Tree Location (default: /usr/src):
# source_tree="/usr/src"
@@ -32,8 +34,8 @@
# Location of the key and certificate files used for Secure boot. $kernelver
# can be used in path to represent the target kernel version.
#
-# NOTE: If any of the files specified by `mok_signing_key` and
-# `mok_certificate` are non-existant, dkms will re-create both files.
+# NOTE: If any of the files specified by `mok_signing_key` and `mok_certificate`
+# are non-existent, dkms will re-create both files.
#
# mok_signing_key can also be a "pkcs11:..." string for PKCS#11 engine, as
# long as the sign_file program supports it.
@@ -46,3 +48,17 @@
# Limit the number of jobs run in parallel (default is the number of CPUs)
# parallel_jobs=2
+
+# Compression settings DKMS uses when compressing modules. The defaults are
+# used, for reasonable compression times. One might instead wish to use maximum
+# compression, at the expense of speed when compressing.
+# compress_gzip_opts="-6"
+# compress_xz_opts="--check=crc32 --lzma2=dict=1MiB -6"
+# compress_zstd_opts="-q --rm -T0 -3"
+
+# Command to run at the end of every DKMS transaction, for example after a new
+# kernel has been installed on the system and all modules have been successfully
+# built and installed.
+# The command listed is executed if set to any non null value. $kernelver can be
+# used in path to represent the target kernel version.
+# post_transaction=""
diff --git a/kernel_postinst.d_dkms.in b/kernel_postinst.d_dkms.in
deleted file mode 100755
index f4ccc95..0000000
--- a/kernel_postinst.d_dkms.in
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-
-# We're passed the version of the kernel being installed
-inst_kern=$1
-
-uname_s=$(uname -s)
-
-_get_kernel_dir() {
- KVER=$1
- case ${uname_s} in
- Linux) DIR="@MODDIR@/$KVER/build" ;;
- GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
- esac
- echo "$DIR"
-}
-
-_check_kernel_dir() {
- DIR=$(_get_kernel_dir "$1")
- case ${uname_s} in
- Linux) test -e "$DIR/include" ;;
- GNU/kFreeBSD) test -e "$DIR/kern" && test -e "$DIR/conf/kmod.mk" ;;
- *) false ;;
- esac
-}
-
-case "${uname_s}" in
- Linux)
- header_pkg="linux-headers-$inst_kern"
- kernel="Linux"
- ;;
- GNU/kFreeBSD)
- header_pkg="kfreebsd-headers-$inst_kern"
- kernel="kFreeBSD"
- ;;
-esac
-
-if [ -x @LIBDIR@/dkms_autoinstaller ]; then
- exec @LIBDIR@/dkms_autoinstaller start "$inst_kern"
-fi
-
-if ! _check_kernel_dir "$inst_kern" ; then
- echo "dkms: WARNING: $kernel headers are missing, which may explain the above failures." >&2
- echo " please install the $header_pkg package to fix this." >&2
-fi
diff --git a/kernel_prerm.d_dkms b/kernel_prerm.d_dkms
deleted file mode 100755
index aeb8e3a..0000000
--- a/kernel_prerm.d_dkms
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-# We're passed the version of the kernel being removed
-inst_kern=$1
-
-if command -v dkms > /dev/null; then
- dkms status -k "$inst_kern" 2>/dev/null | while IFS=",:/ " read -r name vers _ arch status; do
- [ "$status" = "installed" ] || continue
- echo "dkms: removing: $name $vers ($inst_kern) ($arch)" >&2
- dkms remove -m "$name" -v "$vers" -k "$inst_kern" -a "$arch"
- done
-fi
-
-rmdir --ignore-fail-on-non-empty \
- "/lib/modules/$inst_kern/updates/dkms" \
- "/lib/modules/$inst_kern/updates" 2>/dev/null
-
-exit 0
diff --git a/kernel_prerm.d_dkms.in b/kernel_prerm.d_dkms.in
deleted file mode 100755
index cbf0c94..0000000
--- a/kernel_prerm.d_dkms.in
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-# This script is triggered when the kernel (linux-image) package is being
-# removed. We're passed the version of the kernel being removed.
-inst_kern=$1
-
-if command -v dkms > /dev/null; then
- dkms status -k "$inst_kern" 2>/dev/null | while IFS=",:/ " read -r name vers _ arch status; do
- [ "$status" = "installed" ] || continue
- echo "dkms: removing: $name $vers ($inst_kern) ($arch)" >&2
- # Compromise on using 'unbuild' to remove the module when a
- # kernel is being removed. The 'remove' command is too
- # destructive. The 'uninstall' command leaves built files
- # around that have no other trigger to 'unbuild' them.
- # (Triggering 'unbuild' on kernel header removal would not be
- # a good idea because that would also cause the module to be
- # uninstalled for the kernel, even though only the headers are
- # being removed.)
- dkms unbuild -m "$name" -v "$vers" -k "$inst_kern" -a "$arch"
- done
-fi
-
-rmdir --ignore-fail-on-non-empty \
- "@MODDIR@/$inst_kern/updates/dkms" \
- "@MODDIR@/$inst_kern/updates" 2>/dev/null
-
-exit 0
diff --git a/redhat_kernel_install.d.in b/redhat_kernel_install.d.in
new file mode 100644
index 0000000..1cd861e
--- /dev/null
+++ b/redhat_kernel_install.d.in
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+COMMAND=$1
+KERNEL_VERSION=$2
+
+case "$COMMAND" in
+ add)
+ dkms kernel_postinst --kernelver "$KERNEL_VERSION"
+ ;;
+ remove)
+ dkms kernel_prerm --kernelver "$KERNEL_VERSION"
+ ;;
+esac
+
+exit 0
diff --git a/run_test.sh b/run_test.sh
index 5177a50..2790a7e 100755
--- a/run_test.sh
+++ b/run_test.sh
@@ -6,7 +6,8 @@ set -eu
cd "$(dirname -- "$0")"
# To use a specific kernel version, use the environment variable KERNEL_VER
-KERNEL_VER="${KERNEL_VER:-$(uname -r)}"
+UNAME_R="$(uname -r)"
+KERNEL_VER="${KERNEL_VER:-${UNAME_R}}"
KERNEL_ARCH="$(uname -m)"
echo "Using kernel ${KERNEL_VER}/${KERNEL_ARCH}"
@@ -17,42 +18,50 @@ export DEBIAN_FRONTEND=noninteractive
# Avoid output variations due to parallelism
export parallel_jobs=1
+tmpdir=
+tmpdir_cleanup()
+{
+ rm -rf "${tmpdir:?}"
+}
+trap tmpdir_cleanup EXIT
+tmpdir=$(mktemp -d)
+[[ -d ${tmpdir} ]] || exit 1
+
# Temporary files, directories, and modules created during tests
TEST_MODULES=(
"dkms_test"
+ "dkms_dependencies_test"
+ "dkms_dependencies_rebuild_test"
+ "dkms_circular_dependencies_test"
+ "dkms_replace_test"
"dkms_noautoinstall_test"
"dkms_failing_test"
- "dkms_dependencies_test"
+ "dkms_failing_dependencies_test"
"dkms_multiver_test"
"dkms_nover_test"
"dkms_emptyver_test"
"dkms_nover_update_test"
"dkms_conf_test"
+ "dkms_duplicate_test"
+ "dkms_duplicate_built_test"
+ "dkms_duplicate_dest_test"
+ "dkms_patches_test"
+ "dkms_scripts_test"
+ "dkms_noisy_test"
+ "dkms_crlf_test"
+ "dkms_deprecated_test"
"dkms_build_exclusive_test"
"dkms_build_exclusive_dependencies_test"
)
TEST_TMPDIRS=(
- "/usr/src/dkms_test-1.0"
- "/usr/src/dkms_noautoinstall_test-1.0"
- "/usr/src/dkms_failing_test-1.0"
- "/usr/src/dkms_dependencies_test-1.0"
- "/usr/src/dkms_multiver_test-1.0"
- "/usr/src/dkms_multiver_test-2.0"
- "/usr/src/dkms_nover_test-1.0"
- "/usr/src/dkms_emptyver_test-1.0"
- "/usr/src/dkms_nover_update_test-1.0"
- "/usr/src/dkms_nover_update_test-2.0"
- "/usr/src/dkms_nover_update_test-3.0"
- "/usr/src/dkms_conf_test-1.0"
- "/usr/src/dkms_build_exclusive_test-1.0"
- "/usr/src/dkms_build_exclusive_dependencies_test-1.0"
- "/tmp/dkms_test_dir_${KERNEL_VER}/"
+ "${tmpdir}/dkms_test_dir_${KERNEL_VER}/"
)
TEST_TMPFILES=(
- "/tmp/dkms_test_private_key"
- "/tmp/dkms_test_certificate"
- "/tmp/dkms_test_kconfig"
+ "${tmpdir}/dkms_test_private_key"
+ "${tmpdir}/dkms_test_certificate"
+ "${tmpdir}/dkms_test_kconfig"
"/etc/dkms/framework.conf.d/dkms_test_framework.conf"
+ "/etc/dkms/no-autoinstall"
"test_cmd_output.log"
"test_cmd_stdout.log"
"test_cmd_stderr.log"
@@ -62,12 +71,12 @@ TEST_TMPFILES=(
# Reportedly in some cases the entries in the modinfo output are ordered
# differently. Fetch whatever we need and sort them.
modinfo_quad() {
- modinfo $1 | grep -E "^description:|^filename:|^license:|^version:" | sort
+ modinfo "$1" | grep -E "^description:|^filename:|^license:|^version:" | sort
}
SIGNING_MESSAGE=""
declare -i NO_SIGNING_TOOL
-if [ "$#" = 1 ] && [ "$1" = "--no-signing-tool" ]; then
+if [[ $# = 1 ]] && [[ $1 = "--no-signing-tool" ]]; then
echo 'Ignore signing tool errors'
NO_SIGNING_TOOL=1
else
@@ -82,14 +91,24 @@ dkms_status_grep_dkms_module() {
clean_dkms_env() {
local found_module
-
- for module in ${TEST_MODULES[@]}; do
- found_module="$(dkms_status_grep_dkms_module ${module})"
- if [[ -n "$found_module" ]] ; then
- dkms remove ${module}/1.0 >/dev/null
+ local module
+ local version
+ local dir
+ local file
+
+ for module in "${TEST_MODULES[@]}"; do
+ found_module=$(dkms_status_grep_dkms_module "${module}")
+ if [[ $found_module ]] ; then
+ for version in 1.0 2.0 3.0; do
+ [[ ! -d "/var/lib/dkms/${module}/${version}" ]] || dkms remove "${module}/${version}" >/dev/null || true
+ done
fi
rm -rf "/var/lib/dkms/${module}/"
rm -f "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/${module}.ko${mod_compression_ext}"
+ rm -f "/lib/modules/${KERNEL_VER}/kernel/extra/${module}.ko${mod_compression_ext}"
+ for version in 1.0 2.0 3.0; do
+ rm -rf "/usr/src/${module}-${version}"
+ done
done
for dir in "${TEST_TMPDIRS[@]}"; do
rm -rf "$dir"
@@ -102,9 +121,9 @@ clean_dkms_env() {
check_no_dkms_test() {
local found_module
- for module in ${TEST_MODULES[@]}; do
- found_module="$(dkms_status_grep_dkms_module ${module})"
- if [[ -n "$found_module" ]] ; then
+ for module in "${TEST_MODULES[@]}"; do
+ found_module=$(dkms_status_grep_dkms_module "${module}")
+ if [[ $found_module ]] ; then
echo >&2 "Error: module ${module} is still in DKMS tree"
exit 1
fi
@@ -132,12 +151,13 @@ check_no_dkms_test() {
}
cert_serial() {
- local ver="$(openssl version)"
+ local ver
+ ver=$(openssl version)
# Some systems in CI test are still using ancient versions of openssl program.
if [[ "$ver" = "OpenSSL 1.0."* ]] || [[ "$ver" = "OpenSSL 0."* ]]; then
- openssl x509 -text -inform DER -in "$1" -noout | grep -A 1 'X509v3 Subject Key Identifier' | tail -n 1 | tr 'a-z' 'A-Z' | tr -d ' :'
+ openssl x509 -text -inform DER -in "$1" -noout | grep -A 1 'X509v3 Subject Key Identifier' | tail -n 1 | tr '[:lower:]' '[:upper:]' | tr -d ' :'
else
- openssl x509 -serial -inform DER -in "$1" -noout | tr 'a-z' 'A-Z' | sed 's/^SERIAL=//'
+ openssl x509 -serial -inform DER -in "$1" -noout | tr '[:lower:]' '[:upper:]' | sed 's/^SERIAL=//'
fi
}
@@ -146,7 +166,8 @@ set_signing_message() {
# $2: module version
# $3: module file name if not the same as $1
if (( NO_SIGNING_TOOL == 0 )); then
- SIGNING_MESSAGE="Signing module /var/lib/dkms/$1/$2/build/${3:-$1}.ko"$'\n'
+ SIGNING_MESSAGE="
+Signing module /var/lib/dkms/$1/$2/build/${3:-$1}.ko"
fi
}
@@ -165,36 +186,30 @@ run_status_with_expected_output() {
generalize_expected_output() {
local output_log=$1
- # On CentOS, weak-modules is executed. Drop it from the output, to be more generic
- sed -i '/^Adding any weak-modules$/d' ${output_log}
- sed -i '/^Removing any linked weak-modules$/d' ${output_log}
+ # Normalize temporary directories
+ sed -i "s|/\(\.tmp_${KERNEL_ARCH}\)_....../|/\1_XXXXXX/|g" "${output_log}"
+ # On Red Hat and SUSE based distributions, weak-modules is executed. Drop it from the output, to be more generic
+ sed -i '/^Adding linked weak modules.*$/d' "${output_log}"
+ sed -i '/^Removing linked weak modules.*$/d' "${output_log}"
# Signing related output. Drop it from the output, to be more generic
if (( NO_SIGNING_TOOL == 0 )); then
- sed -i '/^EFI variables are not supported on this system/d' ${output_log}
- sed -i '/^\/sys\/firmware\/efi\/efivars not found, aborting./d' ${output_log}
- sed -i '/^Sign command:/d' ${output_log}
- sed -i '/^Signing key:/d' ${output_log}
- sed -i '/^Public certificate (MOK):/d' ${output_log}
- sed -i '/^Certificate or key are missing, generating them using update-secureboot-policy...$/d' ${output_log}
- sed -i '/^Certificate or key are missing, generating self signed certificate for MOK...$/d' ${output_log}
+ sed -i '/^EFI variables are not supported on this system/d' "${output_log}"
+ sed -i '/^\/sys\/firmware\/efi\/efivars not found, aborting./d' "${output_log}"
+ sed -i '/^Certificate or key are missing, generating them using update-secureboot-policy...$/d' "${output_log}"
+ sed -i '/^Certificate or key are missing, generating self signed certificate for MOK...$/d' "${output_log}"
else
- sed -i "/^The kernel is built without module signing facility, modules won't be signed$/d" ${output_log}
- sed -i "/^Binary .* not found, modules won't be signed$/d" ${output_log}
+ sed -i "/^Binary .* not found, modules won't be signed$/d" "${output_log}"
# Uncomment the following line to run this script with --no-signing-tool on platforms where the sign-file tool exists
- # sed -i '/^Signing module \/var\/lib\/dkms\/dkms_test\/1.0\/build\/dkms_test.ko$/d' ${output_log}
+ # sed -i '/^Signing module \/var\/lib\/dkms\/dkms_test\/1.0\/build\/dkms_test.ko$/d' "${output_log}"
fi
# OpenSSL non-critical errors while signing. Remove them to be more generic
- sed -i '/^At main.c:/d' ${output_log}
- sed -i '/^- SSL error:/d' ${output_log}
+ sed -i '/^At main.c:/d' "${output_log}"
+ sed -i '/^- SSL error:/d' "${output_log}"
# Apport related error that can occur in the CI. Drop from the output to be more generic
- sed -i "/^python3: can't open file '\/usr\/share\/apport\/package-hooks\/dkms_packages.py'\: \[Errno 2\] No such file or directory$/d" ${output_log}
- sed -i "/^ERROR (dkms apport): /d" ${output_log}
- # Drop empty lines
- sed -i "/^$/d" ${output_log}
- # Gentoo complains there is not a .comment section in the built modules
- sed -i "/^readelf\: Warning: Section '.comment' was not dumped because it does not exist$/d" ${output_log}
+ sed -i "/^python3: can't open file '\/usr\/share\/apport\/package-hooks\/dkms_packages.py'\: \[Errno 2\] No such file or directory$/d" "${output_log}"
+ sed -i "/^ERROR (dkms apport): /d" "${output_log}"
# Swap any CC/LD/... flags (if set) with a placeholder message
- sed -i "s|\(make -j1 KERNELRELEASE=${KERNEL_VER} all\).*|\1 |" ${output_log}
+ sed -i "s|\(make -j1 KERNELRELEASE=${KERNEL_VER} all\).*|\1 |" "${output_log}"
}
run_with_expected_output() {
@@ -202,40 +217,125 @@ run_with_expected_output() {
}
run_with_expected_error() {
- local expected_error_code="$1"
- local dkms_command="$3"
+ local expected_error_code=$1
+ local dkms_command=$3
local output_log=test_cmd_output.log
local expected_output_log=test_cmd_expected_output.log
local error_code=0
shift
- cat > ${expected_output_log}
- stdbuf -o L -e L "$@" > ${output_log} 2>&1 || error_code=$?
+ cat > "${expected_output_log}"
+ stdbuf -o L -e L "$@" > "${output_log}" 2>&1 || error_code=$?
if [[ "${error_code}" != "${expected_error_code}" ]] ; then
echo "Error: command '$*' returned status ${error_code} instead of expected ${expected_error_code}"
- cat ${output_log}
- rm ${expected_output_log} ${output_log}
+ cat "${output_log}"
+ rm "${expected_output_log}" "${output_log}"
return 1
fi
- generalize_expected_output ${output_log} ${dkms_command}
- if ! diff -U3 ${expected_output_log} ${output_log} ; then
+ generalize_expected_output "${output_log}" "${dkms_command}"
+ if ! diff -U3 "${expected_output_log}" "${output_log}" ; then
echo >&2 "Error: unexpected output from: $*"
- rm ${expected_output_log} ${output_log}
+ rm "${expected_output_log}" "${output_log}"
+ return 1
+ fi
+ rm "${expected_output_log}" "${output_log}"
+}
+
+generalize_make_log() {
+ local output_log=$1
+
+ sed -r -i '
+# timestamp on line 2
+2s/.*//
+/# elapsed time:/s/[0-9]+:[0-9]+:[0-9]+//
+
+# minimize and unify compilation output between distributions
+# we are not really interested in the compilation details
+/warning: the compiler differs from the one used to build the kernel/d
+/ The kernel was built by:/d
+/ You are using:/d
+/make(\[[0-9]+\])?: (Entering|Leaving) directory/d
+s/ \[M\] / /
+/^ /s/\/var\/lib\/dkms\/.*\///
+/^ AR built-in\.a$/d
+/^ Building modules, stage 2\.$/d
+/^ MODPOST Module\.symvers$/d
+/^ MODPOST [0-9]+ modules$/d
+/^ CC \.module-common\.o$/d
+/^ BTF dkms_(.*_)?test.ko$/d
+/Skipping BTF generation for (\/var\/lib\/dkms\/.*\/)?dkms_(.*_)?test.ko due to unavailability of vmlinux$/d
+/^ CLEAN \.tmp_versions$/d
+' "${output_log}"
+}
+
+check_make_log_content() {
+ local make_log=$1
+ local output_log=test_cmd_output.log
+ local expected_output_log=test_cmd_expected_output.log
+
+ cat > "${expected_output_log}"
+ cat "$make_log" > "${output_log}"
+ generalize_make_log "${output_log}"
+ if ! diff -U3 "${expected_output_log}" "${output_log}" ; then
+ echo >&2 "Error: unexpected make.log difference"
+ rm "${expected_output_log}" "${output_log}"
return 1
fi
- rm ${expected_output_log} ${output_log}
+ rm "${expected_output_log}" "${output_log}"
+}
+
+check_module_source_tree_created() {
+ if ! [[ -d "$1" ]] ; then
+ echo >&2 "Error: directory '$1' was not created"
+ exit 1
+ fi
+ if ! [[ -f "$1/dkms.conf" ]] ; then
+ echo >&2 "Error: '$1/dkms.conf' was not found"
+ exit 1
+ fi
+}
+
+remove_module_source_tree() {
+ for p in "$@" ; do
+ case "$p" in
+ /usr/src/*)
+ ;;
+ *)
+ echo "Unsuported module source tree location '$p'"
+ exit 1
+ ;;
+ esac
+ done
+ echo "Removing source tree $*"
+ rm -r "$@"
+}
+
+install_framework_conf()
+{
+ [[ $1 && $2 ]] || return
+ sed "s|@tmpdir@|${tmpdir:?}|g" "$1" > "$2"
}
# sig_hashalgo itself may show bogus value if kmod version < 26
kmod_broken_hashalgo() {
- local -ri kmod_ver=$(kmod --version | grep version | cut -f 3 -d ' ')
+ local -ri kmod_ver=$(kmod --version | sed -n 's/kmod version \([0-9]\+\).*/\1/p')
(( kmod_ver < 26 ))
}
+# Function to check if a file does not exist
+file_not_exists() {
+ local file="$1"
+ if [ ! -e "$file" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
mod_compression_ext=
kernel_config="/lib/modules/${KERNEL_VER}/build/.config"
-if [ -f "${kernel_config}" ]; then
+if [[ -f $kernel_config ]]; then
if grep -q "^CONFIG_MODULE_COMPRESS_NONE=y" "${kernel_config}" ; then
mod_compression_ext=
elif grep -q "^CONFIG_MODULE_COMPRESS_GZIP=y" "${kernel_config}" ; then
@@ -249,6 +349,9 @@ fi
# Compute the expected destination module location
os_id="$(sed -n 's/^ID\s*=\s*\(.*\)$/\1/p' /etc/os-release | tr -d '"')"
+distro_sign_file_candidates=
+distro_modsigkey=/var/lib/dkms/mok.key
+distro_modsigcert=/var/lib/dkms/mok.pub
case "${os_id}" in
centos | fedora | rhel | ovm | almalinux)
expected_dest_loc=extra
@@ -261,8 +364,13 @@ case "${os_id}" in
arch)
expected_dest_loc=updates/dkms
;;
- debian* | ubuntu | linuxmint)
+ debian* | linuxmint)
expected_dest_loc=updates/dkms
+ distro_sign_file_candidates="/usr/lib/linux-kbuild-${KERNEL_VER%.*}/scripts/sign-file"
+ ;;
+ ubuntu)
+ expected_dest_loc=updates/dkms
+ distro_sign_file_candidates="/usr/bin/kmodsign /usr/src/linux-headers-${KERNEL_VER}/scripts/sign-file"
;;
alpine)
expected_dest_loc=kernel/extra
@@ -270,6 +378,11 @@ case "${os_id}" in
gentoo)
expected_dest_loc=kernel/extra
mod_compression_ext=
+ distro_sign_file_candidates="/usr/src/linux-${KERNEL_VER}/scripts/sign-file"
+ distro_modsigkey=/root/kernel_key.pem
+ distro_modsigcert=/root/kernel_cert.pem
+ echo "MODULES_SIGN_KEY=${distro_modsigkey}" >> /etc/portage/make.conf
+ echo "MODULES_SIGN_CERT=${distro_modsigcert}" >> /etc/portage/make.conf
;;
*)
echo >&2 "Error: unknown Linux distribution ID ${os_id}"
@@ -279,26 +392,62 @@ esac
echo "Checking module compression ..."
echo "config: $(grep "^CONFIG_MODULE_COMPRESS" "${kernel_config}" || true)"
-echo "files: $(find "/lib/modules/${KERNEL_VER}" -name \*.ko\* 2>/dev/null | head -n1)"
+echo "files: $(find "/lib/modules/${KERNEL_VER}" -name \*.ko\* 2>/dev/null | head -n1)"
echo "Expected extension: ${mod_compression_ext:-(none)}"
+for sign_file in $distro_sign_file_candidates \
+ "/lib/modules/${KERNEL_VER}/build/scripts/sign-file"
+do
+ [[ ! -x $sign_file ]] || break
+done
+
+SIGNING_PROLOGUE_command="Sign command: ${sign_file}"
+SIGNING_PROLOGUE_key="Signing key: ${distro_modsigkey}"
+SIGNING_PROLOGUE_cert="Public certificate (MOK): ${distro_modsigcert}"
+if [[ $sign_file = "/usr/bin/kmodsign" ]]; then
+ SIGNING_PROLOGUE_key="Signing key: /var/lib/shim-signed/mok/MOK.priv"
+ SIGNING_PROLOGUE_cert="Public certificate (MOK): /var/lib/shim-signed/mok/MOK.der"
+fi
+
+if (( NO_SIGNING_TOOL == 0 )); then
+ SIGNING_PROLOGUE="${SIGNING_PROLOGUE_command}
+${SIGNING_PROLOGUE_key}
+${SIGNING_PROLOGUE_cert}
+"
+else
+ SIGNING_PROLOGUE="The kernel is built without module signing facility, modules won't be signed
+"
+fi
+
+DKMS_VERSION="$(dkms --version)"
+
echo 'Preparing a clean test environment'
clean_dkms_env
+echo 'Test that there are no dkms modules installed'
+run_with_expected_output dkms status -k "${KERNEL_VER}" << EOF
+EOF
+
echo 'Test framework file hijacking'
mkdir -p /etc/dkms/framework.conf.d/
-cp test/framework/hijacking.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
+install_framework_conf test/framework/hijacking.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
run_with_expected_output dkms status -m dkms_test << EOF
EOF
rm /etc/dkms/framework.conf.d/dkms_test_framework.conf
+only="${1:-}"
+[[ $only ]] && echo "Running only '$only' tests"
+
+if [[ ! $only || $only = basic ]]; then
+
############################################################################
-### Testing dkms on a regular module ###
+echo '*** Testing dkms on a regular module'
############################################################################
echo 'Adding the test module by version (expected error)'
run_with_expected_error 2 dkms add -m dkms_test -v 1.0 << EOF
+
Error! Could not find module source directory.
Directory: /usr/src/dkms_test-1.0 does not exist.
EOF
@@ -307,37 +456,91 @@ echo 'Adding the test module by directory'
run_with_expected_output dkms add test/dkms_test-1.0 << EOF
Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0: added
EOF
-if ! [[ -d /usr/src/dkms_test-1.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_test-1.0 was not created'
- exit 1
-fi
-echo 'Adding the test module again (expected error)'
+echo 'Adding the test module by directory again (expected error)'
run_with_expected_error 3 dkms add test/dkms_test-1.0 << EOF
-Error! DKMS tree already contains: dkms_test-1.0
+
+Error! DKMS tree already contains: dkms_test/1.0
You cannot add the same module/version combo more than once.
EOF
-echo 'Adding the test module by version (expected error)'
+echo 'Removing the test module'
+run_with_expected_output dkms remove --all -m dkms_test -v 1.0 << EOF
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_test-1.0
+
+echo 'Adding the test module by config file'
+run_with_expected_output dkms add test/dkms_test-1.0/dkms.conf << EOF
+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo 'Adding the test module by config file again (expected error)'
+run_with_expected_error 3 dkms add test/dkms_test-1.0/dkms.conf << EOF
+
+Error! DKMS tree already contains: dkms_test/1.0
+You cannot add the same module/version combo more than once.
+EOF
+
+echo 'Removing the test module'
+run_with_expected_output dkms remove --all -m dkms_test -v 1.0 << EOF
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+
+echo 'Adding the test module by version'
+run_with_expected_output dkms add -m dkms_test -v 1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo 'Adding the test module by version again (expected error)'
run_with_expected_error 3 dkms add -m dkms_test -v 1.0 << EOF
-Error! DKMS tree already contains: dkms_test-1.0
+
+Error! DKMS tree already contains: dkms_test/1.0
You cannot add the same module/version combo more than once.
EOF
echo 'Building the test module'
set_signing_message "dkms_test" "1.0"
run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
EOF
run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
EOF
+echo 'Checking make.log content'
+check_make_log_content "/var/lib/dkms/dkms_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/log/make.log" << EOF
+DKMS (${DKMS_VERSION}) make.log for dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+
+
+Building module(s)
+# command: make -j1 KERNELRELEASE=${KERNEL_VER} -C /lib/modules/${KERNEL_VER}/build M=/var/lib/dkms/dkms_test/1.0/build
+ CC dkms_test.o
+ CC dkms_test.mod.o
+ LD dkms_test.ko
+
+# exit code: 0
+# elapsed time:
+----------------------------------------------------------------
+EOF
+
echo 'Building the test module again'
run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
Module dkms_test/1.0 already built for kernel ${KERNEL_VER} (${KERNEL_ARCH}), skip. You may override by specifying --force.
@@ -346,93 +549,31 @@ run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
EOF
-if (( NO_SIGNING_TOOL == 0 )); then
- echo 'Building the test module with bad sign_file path in framework file'
- cp test/framework/bad_sign_file_path.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
- run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
-Binary /no/such/file not found, modules won't be signed
-Cleaning build area... done.
-Building module(s)... done.
-Cleaning build area... done.
-EOF
-
- echo ' Building the test module with bad mok_signing_key path in framework file'
- cp test/framework/bad_key_file_path.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
- run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
-Key file /no/such/path.key not found and can't be generated, modules won't be signed
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
-EOF
-
- echo ' Building the test module with bad mok_certificate path in framework file'
- cp test/framework/bad_cert_file_path.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
- run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
-Certificate file /no/such/path.crt not found and can't be generated, modules won't be signed
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
-EOF
- rm /tmp/dkms_test_private_key
+echo 'Building the test module for a kernel without headers installed (expected error)'
+run_with_expected_error 21 dkms build -k "${KERNEL_VER}-noheaders" -m dkms_test -v 1.0 << EOF
- echo ' Building the test module with path contains variables in framework file'
- mkdir "/tmp/dkms_test_dir_${KERNEL_VER}/"
- cp test/framework/variables_in_path.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
- run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+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.
EOF
- rm -r "/tmp/dkms_test_dir_${KERNEL_VER}/"
-
- BUILT_MODULE_PATH="/var/lib/dkms/dkms_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/module/dkms_test.ko${mod_compression_ext}"
- CURRENT_HASH="$(modinfo -F sig_hashalgo "${BUILT_MODULE_PATH}")"
-
- echo ' Building the test module using a different hash algorithm'
- if kmod_broken_hashalgo; then
- echo ' Current kmod has broken hash algorithm code. Skipping...'
- elif [[ "${CURRENT_HASH}" == "unknown" ]]; then
- echo ' Current kmod reports unknown hash algorithm. Skipping...'
- else
- cp test/framework/temp_key_cert.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
- if [[ "${CURRENT_HASH}" == "sha512" ]]; then
- ALTER_HASH="sha256"
- else
- ALTER_HASH="sha512"
- fi
- echo "CONFIG_MODULE_SIG_HASH=\"${ALTER_HASH}\"" > /tmp/dkms_test_kconfig
- run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --config /tmp/dkms_test_kconfig --force << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+echo 'Building the test module for more than one kernel version (same version twice for this test)'
+run_with_expected_output dkms build -k "${KERNEL_VER}" -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 already built for kernel ${KERNEL_VER} (${KERNEL_ARCH}), skip. You may override by specifying --force.
+Module dkms_test/1.0 already built for kernel ${KERNEL_VER} (${KERNEL_ARCH}), skip. You may override by specifying --force.
EOF
- run_with_expected_output sh -c "modinfo -F sig_hashalgo '${BUILT_MODULE_PATH}'" << EOF
-${ALTER_HASH}
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
EOF
- rm /tmp/dkms_test_kconfig
- fi
-
- rm /etc/dkms/framework.conf.d/dkms_test_framework.conf
-fi
-
-cp test/framework/temp_key_cert.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
echo 'Building the test module again by force'
run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
EOF
run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
EOF
-if (( NO_SIGNING_TOOL == 0 )); then
- echo ' Extracting serial number from the certificate'
- MODULE_SERIAL="$(cert_serial /tmp/dkms_test_certificate)"
-fi
-
echo 'Installing the test module'
run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
@@ -441,6 +582,10 @@ EOF
run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
EOF
+if ! [[ -f "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}" ]] ; then
+ echo >&2 "Error: module not found in /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}"
+ exit 1
+fi
echo 'Installing the test module again'
run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
@@ -449,17 +594,14 @@ EOF
run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
EOF
-if ! [[ -f "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}" ]] ; then
- echo >&2 "Error: module not found in /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}"
- exit 1
-fi
echo 'Installing the test module again by force'
run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
-Module dkms_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
Running depmod... done.
+
Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
Running depmod... done.
EOF
@@ -475,28 +617,40 @@ license: GPL
version: 1.0
EOF
-if (( NO_SIGNING_TOOL == 0 )); then
- echo ' Checking module signature'
- SIG_KEY="$(modinfo -F sig_key "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}" | tr -d ':')"
- SIG_HASH="$(modinfo -F sig_hashalgo "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}")"
+echo 'Enable post-transaction command and install the module'
+mkdir -p /etc/dkms/framework.conf.d/
+install_framework_conf test/framework/post_transaction.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
- if kmod_broken_hashalgo; then
- echo ' Current kmod has broken hash algorithm code. Skipping...'
- elif [[ "${SIG_HASH}" == "unknown" ]]; then
- echo ' Current kmod reports unknown hash algorithm. Skipping...'
- elif [[ ! "${SIG_KEY}" ]]; then
- echo >&2 "Error: module was not signed"
- exit 1
- else
- run_with_expected_output sh -c "echo '${SIG_KEY}'" << EOF
-${MODULE_SERIAL}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+Executing post-transaction command... done.
EOF
- fi
-fi
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Checking post_transacion.log content'
+check_make_log_content "/var/lib/dkms/post_transaction.log" << EOF
+
+
+# command: echo This is a test message as post transaction. Kernel version is ${KERNEL_VER}
+This is a test message as post transaction. Kernel version is ${KERNEL_VER}
+
+# exit code: 0
+# elapsed time:
+----------------------------------------------------------------
+EOF
+
+rm /etc/dkms/framework.conf.d/dkms_test_framework.conf
echo 'Uninstalling the test module'
run_with_expected_output dkms uninstall -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
-Module dkms_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
Running depmod... done.
@@ -511,7 +665,7 @@ fi
echo 'Uninstalling the test module again'
run_with_expected_output dkms uninstall -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
-Module dkms_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
EOF
run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
@@ -519,7 +673,7 @@ EOF
echo 'Unbuilding the test module'
run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
-Module dkms_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
EOF
run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0: added
@@ -527,8 +681,8 @@ EOF
echo 'Unbuilding the test module again'
run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
-Module dkms_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
EOF
run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0: added
@@ -536,9 +690,10 @@ EOF
echo 'Removing the test module'
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
-Module dkms_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_test-1.0 completely from the DKMS tree.
+Module dkms_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
EOF
run_status_with_expected_output 'dkms_test' << EOF
EOF
@@ -547,27 +702,12 @@ if ! [[ -d /usr/src/dkms_test-1.0 ]] ; then
exit 1
fi
-echo 'Adding the test module by version'
-run_with_expected_output dkms add -m dkms_test -v 1.0 << EOF
-Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
-EOF
-run_status_with_expected_output 'dkms_test' << EOF
-dkms_test/1.0: added
-EOF
-
-echo 'Removing the test module'
-run_with_expected_output dkms remove --all -m dkms_test -v 1.0 << EOF
-Deleting module dkms_test-1.0 completely from the DKMS tree.
-EOF
-run_status_with_expected_output 'dkms_test' << EOF
-EOF
-
echo 'Installing the test module by version (combining add, build, install)'
run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
Running depmod... done.
EOF
@@ -587,33 +727,14 @@ license: GPL
version: 1.0
EOF
-if (( NO_SIGNING_TOOL == 0 )); then
- echo ' Checking module signature'
- SIG_KEY="$(modinfo -F sig_key "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}" | tr -d ':')"
- SIG_HASH="$(modinfo -F sig_hashalgo "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}")"
-
- if kmod_broken_hashalgo; then
- echo ' Current kmod has broken hash algorithm code. Skipping...'
- elif [[ "${SIG_HASH}" == "unknown" ]]; then
- echo ' Current kmod reports unknown hash algorithm. Skipping...'
- elif [[ ! "${SIG_KEY}" ]]; then
- # kmod may not be linked with openssl and thus can't extract the key from module
- echo >&2 "Error: modules was not signed, or key is unknown"
- exit 1
- else
- run_with_expected_output sh -c "echo '${SIG_KEY}'" << EOF
-${MODULE_SERIAL}
-EOF
- fi
-fi
-
echo 'Removing the test module with --all'
run_with_expected_output dkms remove --all -m dkms_test -v 1.0 << EOF
-Module dkms_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
Running depmod... done.
-Deleting module dkms_test-1.0 completely from the DKMS tree.
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
EOF
run_status_with_expected_output 'dkms_test' << EOF
EOF
@@ -622,155 +743,2164 @@ if [[ -e "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_comp
exit 1
fi
-echo 'Removing /usr/src/dkms_test-1.0'
-rm -r /usr/src/dkms_test-1.0
+remove_module_source_tree /usr/src/dkms_test-1.0
-echo 'Building the test module by config file (combining add, build)'
-run_with_expected_output dkms build -k "${KERNEL_VER}" test/dkms_test-1.0/dkms.conf << EOF
+echo 'Checking that the environment is clean again'
+check_no_dkms_test
+
+fi # basic tests
+
+if [[ ! $only || $only = signing ]]; then
+
+if (( NO_SIGNING_TOOL == 0 )); then
+ ############################################################################
+ echo '*** Testing module signing'
+ ############################################################################
+
+ echo 'Adding the test module'
+ run_with_expected_output dkms add test/dkms_test-1.0 << EOF
Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
EOF
-run_status_with_expected_output 'dkms_test' << EOF
-dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+ check_module_source_tree_created /usr/src/dkms_test-1.0
+ run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
EOF
-echo "Running dkms autoinstall"
-run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
-Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
-Running depmod... done.
-Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test.
-EOF
-run_status_with_expected_output 'dkms_test' << EOF
-dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
-EOF
+ echo 'Building the test module with bad sign_file path in framework file'
+ install_framework_conf test/framework/bad_sign_file_path.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
+ run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
+Sign command: /no/such/file
+Binary /no/such/file not found, modules won't be signed
-echo "Running dkms autoinstall for a kernel without headers installed (expected error)"
-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.
-Autoinstall on ${KERNEL_VER}-noheaders failed for module(s) dkms_test(1).
-Error! One or more modules failed to install during autoinstall.
-Refer to previous errors for more information.
+Building module(s)... done.
EOF
-echo 'Removing the test module with --all'
-run_with_expected_output dkms remove --all -m dkms_test -v 1.0 << EOF
-Module dkms_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
-Before uninstall, this module version was ACTIVE on this kernel.
-Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
-Running depmod... done.
-Deleting module dkms_test-1.0 completely from the DKMS tree.
-EOF
-run_status_with_expected_output 'dkms_test' << EOF
+ echo 'Building the test module with bad mok_signing_key path in framework file'
+ install_framework_conf test/framework/bad_key_file_path.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
+ run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
+${SIGNING_PROLOGUE_command}
+Signing key: /no/such/path.key
+Public certificate (MOK): /var/lib/dkms/mok.pub
+Key file /no/such/path.key not found and can't be generated, modules won't be signed
+
+Building module(s)... done.
EOF
-echo 'Removing temporary files'
-if (( NO_SIGNING_TOOL == 0 )); then
- rm /tmp/dkms_test_private_key /tmp/dkms_test_certificate
+ echo 'Building the test module with bad mok_certificate path in framework file'
+ install_framework_conf test/framework/bad_cert_file_path.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
+ run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
+${SIGNING_PROLOGUE_command}
+Signing key: ${tmpdir}/dkms_test_private_key
+Public certificate (MOK): /no/such/path.crt
+Certificate file /no/such/path.crt not found and can't be generated, modules won't be signed
+
+Building module(s)... done.
+EOF
+
+ echo 'Building the test module with a failing sign_file command'
+ install_framework_conf test/framework/fail_sign_file_path.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
+ run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
+Sign command: /bin/false
+Signing key: ${tmpdir}/dkms_test_private_key
+Public certificate (MOK): ${tmpdir}/dkms_test_certificate
+
+Building module(s)... done.${SIGNING_MESSAGE}
+Warning: Failed to sign module '/var/lib/dkms/dkms_test/1.0/build/dkms_test.ko'!
+
+EOF
+ rm "${tmpdir}/dkms_test_private_key"
+
+ echo 'Building the test module with path contains variables in framework file'
+ mkdir "${tmpdir}/dkms_test_dir_${KERNEL_VER}/"
+ install_framework_conf test/framework/variables_in_path.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
+ run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
+Sign command: /lib/modules/${KERNEL_VER}/build/scripts/sign-file
+Signing key: ${tmpdir}/dkms_test_dir_${KERNEL_VER}/key
+Public certificate (MOK): ${tmpdir}/dkms_test_dir_${KERNEL_VER}/cert
+
+Building module(s)... done.${SIGNING_MESSAGE}
+EOF
+ rm -r "${tmpdir}/dkms_test_dir_${KERNEL_VER}/"
+
+ BUILT_MODULE_PATH="/var/lib/dkms/dkms_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/module/dkms_test.ko${mod_compression_ext}"
+ CURRENT_HASH="$(modinfo -F sig_hashalgo "${BUILT_MODULE_PATH}")"
+
+ install_framework_conf test/framework/temp_key_cert.conf /etc/dkms/framework.conf.d/dkms_test_framework.conf
+ SIGNING_PROLOGUE_tmp_key_cert="${SIGNING_PROLOGUE_command}
+Signing key: ${tmpdir}/dkms_test_private_key
+Public certificate (MOK): ${tmpdir}/dkms_test_certificate
+"
+
+ echo 'Building the test module using a different hash algorithm'
+ if kmod_broken_hashalgo; then
+ echo ' Current kmod has broken hash algorithm code. Skipping...'
+ elif [[ "${CURRENT_HASH}" == "unknown" ]]; then
+ echo ' Current kmod reports unknown hash algorithm. Skipping...'
+ else
+ if [[ "${CURRENT_HASH}" == "sha512" ]]; then
+ ALTER_HASH="sha256"
+ else
+ ALTER_HASH="sha512"
+ fi
+ echo "CONFIG_MODULE_SIG_HASH=\"${ALTER_HASH}\"" > "${tmpdir}/dkms_test_kconfig"
+ run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --config "${tmpdir}/dkms_test_kconfig" --force << EOF
+${SIGNING_PROLOGUE_tmp_key_cert}
+Building module(s)... done.${SIGNING_MESSAGE}
+EOF
+ run_with_expected_output sh -c "modinfo -F sig_hashalgo '${BUILT_MODULE_PATH}'" << EOF
+${ALTER_HASH}
+EOF
+ rm "${tmpdir}/dkms_test_kconfig"
+ fi
+
+ echo 'Building the test module again by force'
+ run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 --force << EOF
+${SIGNING_PROLOGUE_tmp_key_cert}
+Building module(s)... done.${SIGNING_MESSAGE}
+EOF
+ run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+EOF
+
+ echo ' Extracting serial number (aka sig_key in modinfo) from the certificate'
+ CERT_SERIAL="$(cert_serial "${tmpdir}/dkms_test_certificate")"
+
+ echo 'Installing the test module'
+ run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+ run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Checking modinfo'
+run_with_expected_output sh -c "$(declare -f modinfo_quad); modinfo_quad /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}" << EOF
+description: A Simple dkms test module
+filename: /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+license: GPL
+version: 1.0
+EOF
+
+ echo ' Checking module signature'
+ SIG_KEY="$(modinfo -F sig_key "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}" | tr -d ':')"
+ SIG_HASH="$(modinfo -F sig_hashalgo "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}")"
+
+ if kmod_broken_hashalgo; then
+ echo ' Current kmod has broken hash algorithm code. Skipping...'
+ elif [[ "${SIG_HASH}" == "unknown" ]]; then
+ echo ' Current kmod reports unknown hash algorithm. Skipping...'
+ elif [[ ! "${SIG_KEY}" ]]; then
+ # kmod may not be linked with openssl and thus can't extract the key from module
+ echo >&2 "Error: module was not signed, or key is unknown"
+ exit 1
+ else
+ run_with_expected_output sh -c "echo '${SIG_KEY}'" << EOF
+${CERT_SERIAL}
+EOF
+ fi
+
+ echo 'Removing the test module'
+ run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+ run_status_with_expected_output 'dkms_test' << EOF
+EOF
+
+ remove_module_source_tree /usr/src/dkms_test-1.0
+
+ echo 'Installing the test module (combining add, build, install)'
+ run_with_expected_output dkms install -k "${KERNEL_VER}" test/dkms_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
+
+${SIGNING_PROLOGUE_tmp_key_cert}
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+ check_module_source_tree_created /usr/src/dkms_test-1.0
+ run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+ echo 'Checking modinfo'
+ run_with_expected_output sh -c "$(declare -f modinfo_quad); modinfo_quad /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}" << EOF
+description: A Simple dkms test module
+filename: /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+license: GPL
+version: 1.0
+EOF
+
+ echo ' Checking module signature'
+ SIG_KEY="$(modinfo -F sig_key "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}" | tr -d ':')"
+ SIG_HASH="$(modinfo -F sig_hashalgo "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}")"
+
+ if kmod_broken_hashalgo; then
+ echo ' Current kmod has broken hash algorithm code. Skipping...'
+ elif [[ "${SIG_HASH}" == "unknown" ]]; then
+ echo ' Current kmod reports unknown hash algorithm. Skipping...'
+ elif [[ ! "${SIG_KEY}" ]]; then
+ # kmod may not be linked with openssl and thus can't extract the key from module
+ echo >&2 "Error: module was not signed, or key is unknown"
+ exit 1
+ else
+ run_with_expected_output sh -c "echo '${SIG_KEY}'" << EOF
+${CERT_SERIAL}
+EOF
+ fi
+
+ echo 'Removing the test module'
+ run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+ run_status_with_expected_output 'dkms_test' << EOF
+EOF
+
+ echo 'Removing temporary files'
+ rm "${tmpdir}/dkms_test_private_key" "${tmpdir}/dkms_test_certificate"
+ rm /etc/dkms/framework.conf.d/dkms_test_framework.conf
+
+ remove_module_source_tree /usr/src/dkms_test-1.0
+
+ echo 'Checking that the environment is clean again'
+ check_no_dkms_test
fi
-rm /etc/dkms/framework.conf.d/dkms_test_framework.conf
-echo 'Removing /usr/src/dkms_test-1.0'
-rm -r /usr/src/dkms_test-1.0
+fi # signing tests
+
+if [[ ! $only || $only = autoinstall ]]; then
+
+############################################################################
+echo '*** Testing dkms autoinstall/kernel_{postinst/prerm}, dkms_autoinstaller'
+############################################################################
+
+echo 'Testing without modules and without headers'
+
+echo ' Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}-noheaders" << EOF
+EOF
+
+if [[ -x /usr/lib/dkms/dkms_autoinstaller ]]; then
+echo ' Running dkms_autoinstaller'
+run_with_expected_output /usr/lib/dkms/dkms_autoinstaller start "${KERNEL_VER}-noheaders" << EOF
+Automatic installation of modules for kernel ${KERNEL_VER}-noheaders was skipped since the kernel headers for this kernel do not seem to be installed.
+EOF
+fi
+
+echo ' Running dkms kernel_postinst'
+run_with_expected_output dkms kernel_postinst -k "${KERNEL_VER}-noheaders" << EOF
+EOF
+
+echo ' Running dkms kernel_prerm'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}-noheaders" << EOF
+EOF
+
+echo 'Testing without modules but with /etc/dkms/no-autoinstall'
+touch /etc/dkms/no-autoinstall
+
+echo ' Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+Automatic installation of modules has been disabled.
+EOF
+
+if [[ -x /usr/lib/dkms/dkms_autoinstaller ]]; then
+echo ' Running dkms_autoinstaller'
+run_with_expected_output /usr/lib/dkms/dkms_autoinstaller start "${KERNEL_VER}" << EOF
+Automatic installation of modules has been disabled.
+EOF
+fi
+
+echo ' Running dkms kernel_postinst'
+run_with_expected_output dkms kernel_postinst -k "${KERNEL_VER}" << EOF
+Automatic installation of modules has been disabled.
+EOF
+
+echo ' Running dkms kernel_prerm'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+EOF
+
+rm -f /etc/dkms/no-autoinstall
+
+echo 'Testing without modules'
+
+echo ' Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+EOF
+
+if [[ -x /usr/lib/dkms/dkms_autoinstaller ]]; then
+echo ' Running dkms_autoinstaller'
+run_with_expected_output /usr/lib/dkms/dkms_autoinstaller start "${KERNEL_VER}" << EOF
+EOF
+fi
+
+echo ' Running dkms kernel_postinst'
+run_with_expected_output dkms kernel_postinst -k "${KERNEL_VER}" << EOF
+EOF
+
+echo ' Running dkms kernel_prerm'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+EOF
+
+echo 'Building the test module by config file (combining add, build)'
+run_with_expected_output dkms build -k "${KERNEL_VER}" test/dkms_test-1.0/dkms.conf << EOF
+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
+
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+EOF
+
+echo 'Running dkms autoinstall (module built but not installed)'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Unbuilding the test module'
+run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo 'Testing without headers'
+
+echo ' Running dkms autoinstall (expected error)'
+run_with_expected_error 21 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.
+EOF
+
+if [[ -x /usr/lib/dkms/dkms_autoinstaller ]]; then
+echo ' Running dkms_autoinstaller'
+run_with_expected_output /usr/lib/dkms/dkms_autoinstaller start "${KERNEL_VER}-noheaders" << EOF
+Automatic installation of modules for kernel ${KERNEL_VER}-noheaders was skipped since the kernel headers for this kernel do not seem to be installed.
+EOF
+fi
+
+echo ' Running dkms kernel_postinst (expected error)'
+run_with_expected_error 21 dkms kernel_postinst -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.
+EOF
+
+echo ' Running dkms kernel_prerm'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}-noheaders" << EOF
+EOF
+
+echo 'Testing with /etc/dkms/no-autoinstall'
+touch /etc/dkms/no-autoinstall
+
+echo ' Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+Automatic installation of modules has been disabled.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+if [[ -x /usr/lib/dkms/dkms_autoinstaller ]]; then
+echo ' Running dkms_autoinstaller'
+run_with_expected_output /usr/lib/dkms/dkms_autoinstaller start "${KERNEL_VER}" << EOF
+Automatic installation of modules has been disabled.
+EOF
+fi
+
+echo ' Running dkms kernel_postinst'
+run_with_expected_output dkms kernel_postinst -k "${KERNEL_VER}" << EOF
+Automatic installation of modules has been disabled.
+EOF
+
+echo ' Installing the test module'
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+
+echo ' Running dkms kernel_prerm'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+dkms: removing module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+
+Running depmod... done.
+EOF
+
+rm -f /etc/dkms/no-autoinstall
+
+echo 'Running dkms autoinstall --all (expected error)'
+run_with_expected_error 5 dkms autoinstall --all << EOF
+
+Error! The action autoinstall does not support the --all parameter.
+EOF
+
+echo 'Running dkms autoinstall for more than one kernel version (same version twice for this test) (expected error)'
+run_with_expected_error 4 dkms autoinstall -k "${KERNEL_VER}" -k "${KERNEL_VER}" << EOF
+
+Error! The action autoinstall does not support multiple kernel version parameters on the command line.
+EOF
+
+echo 'Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Running dkms autoinstall again'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+if [[ -x /usr/lib/dkms/dkms_autoinstaller ]]; then
+echo 'Unbuilding the test module'
+run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo 'Running dkms_autoinstaller'
+run_with_expected_output /usr/lib/dkms/dkms_autoinstaller start "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Running dkms_autoinstaller again'
+run_with_expected_output /usr/lib/dkms/dkms_autoinstaller start "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+fi
+
+echo 'Running dkms kernel_prerm w/o kernel argument (expected error)'
+run_with_expected_error 4 dkms kernel_prerm << EOF
+
+Error! The action kernel_prerm requires exactly one kernel version parameter on the command line.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Running dkms kernel_prerm'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+dkms: removing module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo 'Running dkms kernel_prerm again'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo 'Building the test module'
+run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+EOF
+
+echo 'Running dkms kernel_prerm (module built but not installed)'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+dkms: removing module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo 'Running dkms kernel_postinst w/o kernel argument (expected error)'
+run_with_expected_error 4 dkms kernel_postinst << EOF
+
+Error! The action kernel_postinst requires exactly one kernel version parameter on the command line.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo 'Running dkms kernel_postinst'
+run_with_expected_output dkms kernel_postinst -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Running dkms kernel_postinst again'
+run_with_expected_output dkms kernel_postinst -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Removing the test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_test-1.0
+
+echo 'Adding failing test module'
+run_with_expected_output dkms add test/dkms_failing_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_failing_test/1.0/source -> /usr/src/dkms_failing_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_failing_test-1.0
+
+echo ' Running autoinstall with failing test module (expected error)'
+run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_failing_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)...(bad exit status: 2)
+Failed command:
+make -j1 KERNELRELEASE=${KERNEL_VER} all
+
+Error! Bad return status for module build on kernel: ${KERNEL_VER} (${KERNEL_ARCH})
+Consult /var/lib/dkms/dkms_failing_test/1.0/build/make.log for more information.
+
+Autoinstall on ${KERNEL_VER} failed for module(s) dkms_failing_test(10).
+
+Error! One or more modules failed to install during autoinstall.
+Refer to previous errors for more information.
+EOF
+
+if [[ -x /usr/lib/dkms/dkms_autoinstaller ]]; then
+echo ' Running dkms_autoinstaller with failing test module (expected error)'
+run_with_expected_error 1 /usr/lib/dkms/dkms_autoinstaller start "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_failing_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)...(bad exit status: 2)
+Failed command:
+make -j1 KERNELRELEASE=${KERNEL_VER} all
+
+Error! Bad return status for module build on kernel: ${KERNEL_VER} (${KERNEL_ARCH})
+Consult /var/lib/dkms/dkms_failing_test/1.0/build/make.log for more information.
+
+Autoinstall on ${KERNEL_VER} failed for module(s) dkms_failing_test(10).
+
+Error! One or more modules failed to install during autoinstall.
+Refer to previous errors for more information.
+EOF
+fi
+
+echo ' Running dkms kernel_postinst with failing test module (expected error)'
+run_with_expected_error 11 dkms kernel_postinst -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_failing_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)...(bad exit status: 2)
+Failed command:
+make -j1 KERNELRELEASE=${KERNEL_VER} all
+
+Error! Bad return status for module build on kernel: ${KERNEL_VER} (${KERNEL_ARCH})
+Consult /var/lib/dkms/dkms_failing_test/1.0/build/make.log for more information.
+
+Autoinstall on ${KERNEL_VER} failed for module(s) dkms_failing_test(10).
+
+Error! One or more modules failed to install during autoinstall.
+Refer to previous errors for more information.
+EOF
+
+echo ' Removing failing test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_failing_test -v 1.0 << EOF
+Module dkms_failing_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_failing_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_failing_test/1.0 completely from the DKMS tree.
+EOF
+
+remove_module_source_tree /usr/src/dkms_failing_test-1.0
+
+echo 'Checking that the environment is clean again'
+check_no_dkms_test
+
+fi # autoinstall tests
+
+if [[ ! $only || $only = noautoinstall ]]; then
+
+############################################################################
+echo '*** Testing dkms on a module with AUTOINSTALL=""'
+############################################################################
+
+echo 'Adding the noautoinstall test module'
+run_with_expected_output dkms add test/dkms_noautoinstall_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_noautoinstall_test/1.0/source -> /usr/src/dkms_noautoinstall_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_noautoinstall_test-1.0
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+dkms_noautoinstall_test/1.0: added
+EOF
+
+echo 'Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+dkms_noautoinstall_test/1.0: added
+EOF
+
+if [[ -x /usr/lib/dkms/dkms_autoinstaller ]]; then
+echo 'Running dkms_autoinstaller'
+run_with_expected_output /usr/lib/dkms/dkms_autoinstaller start "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+dkms_noautoinstall_test/1.0: added
+EOF
+fi
+
+echo 'Running dkms kernel_postinst'
+run_with_expected_output dkms kernel_postinst -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+dkms_noautoinstall_test/1.0: added
+EOF
+
+echo 'Building the noautoinstall test module'
+set_signing_message "dkms_noautoinstall_test" "1.0"
+run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+EOF
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+dkms_noautoinstall_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+EOF
+
+echo 'Installing the noautoinstall test module'
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noautoinstall_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+dkms_noautoinstall_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Running dkms kernel_prerm'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+dkms: removing module dkms_noautoinstall_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_noautoinstall_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noautoinstall_test.ko${mod_compression_ext}
+
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+dkms_noautoinstall_test/1.0: added
+EOF
+
+echo 'Installing the noautoinstall test module'
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noautoinstall_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+dkms_noautoinstall_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Uninstalling the noautoinstall test module'
+run_with_expected_output dkms uninstall -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
+Module dkms_noautoinstall_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noautoinstall_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+dkms_noautoinstall_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+EOF
+
+echo 'Unbuilding the noautoinstall test module'
+run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
+Module dkms_noautoinstall_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+EOF
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+dkms_noautoinstall_test/1.0: added
+EOF
+
+echo 'Removing the noautoinstall test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
+Module dkms_noautoinstall_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_noautoinstall_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_noautoinstall_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_noautoinstall_test-1.0
+
+echo 'Checking that the environment is clean again'
+check_no_dkms_test
+
+fi # noautoinstall tests
+
+if [[ ! $only || $only = dependencies ]]; then
+
+############################################################################
+echo '*** Testing dkms modules with dependencies'
+############################################################################
+
+set_signing_message "dkms_dependencies_test" "1.0"
+SIGNING_MESSAGE_dependencies="$SIGNING_MESSAGE"
+set_signing_message "dkms_test" "1.0"
+
+echo 'Adding the prerequisite test module'
+run_with_expected_output dkms add test/dkms_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+EOF
+
+echo 'Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+EOF
+
+echo 'Adding test module with dependencies'
+run_with_expected_output dkms add test/dkms_dependencies_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_dependencies_test/1.0/source -> /usr/src/dkms_dependencies_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_dependencies_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0: added
+EOF
+
+echo 'Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE_dependencies}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test dkms_dependencies_test.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Running dkms kernel_prerm'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+dkms: removing module dkms_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_test.ko${mod_compression_ext}
+
+dkms: removing module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0: added
+EOF
+
+echo 'Running dkms kernel_prerm again'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0: added
+EOF
+
+echo 'Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall of module dkms_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE_dependencies}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test dkms_dependencies_test.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Running dkms autoinstall again'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Removing the test module with dependencies'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_dependencies_test -v 1.0 << EOF
+Module dkms_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_dependencies_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+EOF
+
+echo 'Removing the prerequisite test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_test-1.0 /usr/src/dkms_dependencies_test-1.0
+
+echo 'Adding test module with unsatisfied dependencies'
+run_with_expected_output dkms add test/dkms_dependencies_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_dependencies_test/1.0/source -> /usr/src/dkms_dependencies_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_dependencies_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0: added
+EOF
+
+echo 'Building the test module with unsatisfied dependencies (expected error)'
+run_with_expected_error 13 dkms build -k "${KERNEL_VER}" -m dkms_dependencies_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+
+Error! Aborting build of module dkms_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}) due to missing BUILD_DEPENDS: dkms_test.
+You may override by specifying --force.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0: added
+EOF
+
+echo 'Building the test module with unsatisfied dependencies by force'
+run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_dependencies_test -v 1.0 --force << EOF
+${SIGNING_PROLOGUE}
+Warning: Trying to build module dkms_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}) despite of missing BUILD_DEPENDS: dkms_test.
+Building module(s)... done.${SIGNING_MESSAGE_dependencies}
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+EOF
+
+echo 'Installing the test module with unsatisfied dependencies'
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_dependencies_test -v 1.0 << EOF
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo "Running dkms autoinstall"
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Unbuilding the test module with unsatisfied dependencies'
+run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_dependencies_test -v 1.0 << EOF
+Module dkms_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0: added
+EOF
+
+echo "Running dkms autoinstall (expected error)"
+run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}" << EOF
+dkms_dependencies_test/1.0 autoinstall failed due to missing dependencies: dkms_test.
+
+Error! One or more modules failed to install during autoinstall.
+Refer to previous errors for more information.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0: added
+EOF
+
+echo 'Removing the test module with unsatisfied dependencies'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_dependencies_test -v 1.0 << EOF
+Module dkms_dependencies_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_dependencies_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_dependencies_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_dependencies_test-1.0
+
+echo 'Adding test module with circular dependencies'
+set_signing_message "dkms_circular_dependencies_test" "1.0"
+run_with_expected_output dkms add test/dkms_circular_dependencies_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_circular_dependencies_test/1.0/source -> /usr/src/dkms_circular_dependencies_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_circular_dependencies_test-1.0
+run_status_with_expected_output 'dkms_circular_dependencies_test' << EOF
+dkms_circular_dependencies_test/1.0: added
+EOF
+
+echo "Running dkms autoinstall (expected error)"
+run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}" << EOF
+dkms_circular_dependencies_test/1.0 autoinstall failed due to missing dependencies: dkms_circular_dependencies_test.
+
+Error! One or more modules failed to install during autoinstall.
+Refer to previous errors for more information.
+EOF
+run_status_with_expected_output 'dkms_circular_dependencies_test' << EOF
+dkms_circular_dependencies_test/1.0: added
+EOF
+
+echo 'Building the test module with circular dependencies (expected error)'
+run_with_expected_error 13 dkms build -k "${KERNEL_VER}" -m dkms_circular_dependencies_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+
+Error! Aborting build of module dkms_circular_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}) due to missing BUILD_DEPENDS: dkms_circular_dependencies_test.
+You may override by specifying --force.
+EOF
+run_status_with_expected_output 'dkms_circular_dependencies_test' << EOF
+dkms_circular_dependencies_test/1.0: added
+EOF
+
+echo 'Building the test module with circular dependencies by force'
+run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_circular_dependencies_test -v 1.0 --force << EOF
+${SIGNING_PROLOGUE}
+Warning: Trying to build module dkms_circular_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}) despite of missing BUILD_DEPENDS: dkms_circular_dependencies_test.
+Building module(s)... done.${SIGNING_MESSAGE}
+EOF
+run_status_with_expected_output 'dkms_circular_dependencies_test' << EOF
+dkms_circular_dependencies_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+EOF
+
+echo 'Installing the test module with circular dependencies'
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_circular_dependencies_test -v 1.0 << EOF
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_circular_dependencies_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_circular_dependencies_test' << EOF
+dkms_circular_dependencies_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Removing the test module with circular dependencies'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_circular_dependencies_test -v 1.0 << EOF
+Module dkms_circular_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_circular_dependencies_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_circular_dependencies_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_circular_dependencies_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_circular_dependencies_test-1.0
+
+echo 'Checking that the environment is clean again'
+check_no_dkms_test
+
+fi # dependencies tests
+
+if [[ ! $only || $only = rebuild_dependencies ]]; then
+
+############################################################################
+echo '*** Testing dkms modules with dependencies and rebuild requirements'
+############################################################################
+
+set_signing_message "dkms_dependencies_rebuild_test" "1.0"
+SIGNING_MESSAGE_rebuild_dependencies="$SIGNING_MESSAGE"
+set_signing_message "dkms_test" "2.0"
+SIGNING_MESSAGE_updated_dependency="$SIGNING_MESSAGE"
+set_signing_message "dkms_test" "1.0"
+
+echo 'Adding the prerequisite test module'
+run_with_expected_output dkms add test/dkms_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+EOF
+
+echo 'Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+EOF
+
+echo 'Adding test module with dependencies'
+run_with_expected_output dkms add test/dkms_dependencies_rebuild_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_dependencies_rebuild_test/1.0/source -> /usr/src/dkms_dependencies_rebuild_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_dependencies_rebuild_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0: added
+EOF
+
+echo 'Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_dependencies_rebuild_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE_rebuild_dependencies}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_rebuild_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test dkms_dependencies_rebuild_test.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo ' Checking the dependency version'
+run_with_expected_output cat /var/lib/dkms/dkms_dependencies_rebuild_test/kernel-"${KERNEL_VER}"-"${KERNEL_ARCH}"/.dep_dkms_test << EOF
+1.0
+EOF
+
+echo 'Running dkms kernel_prerm'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+dkms: removing module dkms_dependencies_rebuild_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_dependencies_rebuild_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_rebuild_test.ko${mod_compression_ext}
+
+dkms: removing module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0: added
+EOF
+
+echo 'Running dkms kernel_prerm again'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0: added
+EOF
+
+echo 'Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall of module dkms_dependencies_rebuild_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE_rebuild_dependencies}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_rebuild_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test dkms_dependencies_rebuild_test.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Running dkms autoinstall again'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Removing the prerequisite test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+remove_module_source_tree /usr/src/dkms_test-1.0
+
+echo 'Adding the updated prerequisite test module'
+run_with_expected_output dkms add test/dkms_test-2.0 << EOF
+Creating symlink /var/lib/dkms/dkms_test/2.0/source -> /usr/src/dkms_test-2.0
+EOF
+check_module_source_tree_created /usr/src/dkms_test-2.0
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/2.0: added
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Building and installing the updated prerequisite test module and trigger rebuild of the dependent module'
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 2.0 << EOF
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE_updated_dependency}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Rebuilding module dkms_dependencies_rebuild_test/1.0 due to updated dependencies
+
+Module dkms_dependencies_rebuild_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_rebuild_test.ko${mod_compression_ext}
+Running depmod... done.
+Building module(s)... done.${SIGNING_MESSAGE_rebuild_dependencies}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_rebuild_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/2.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo ' Checking the updated dependency version after the rebuild'
+run_with_expected_output cat /var/lib/dkms/dkms_dependencies_rebuild_test/kernel-"${KERNEL_VER}"-"${KERNEL_ARCH}"/.dep_dkms_test << EOF
+2.0
+EOF
+
+echo 'Removing the updated prerequisite test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 2.0 << EOF
+Module dkms_test/2.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_test/2.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+remove_module_source_tree /usr/src/dkms_test-2.0
+
+echo 'Adding the downgraded prerequisite test module'
+run_with_expected_output dkms add test/dkms_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Building and installing the downgraded prerequisite test module and trigger rebuild of the dependent module'
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Rebuilding module dkms_dependencies_rebuild_test/1.0 due to updated dependencies
+
+Module dkms_dependencies_rebuild_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_rebuild_test.ko${mod_compression_ext}
+Running depmod... done.
+Building module(s)... done.${SIGNING_MESSAGE_rebuild_dependencies}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_rebuild_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo ' Checking the updated dependency version after the rebuild'
+run_with_expected_output cat /var/lib/dkms/dkms_dependencies_rebuild_test/kernel-"${KERNEL_VER}"-"${KERNEL_ARCH}"/.dep_dkms_test << EOF
+1.0
+EOF
+
+echo 'Removing the test module with dependencies'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_dependencies_rebuild_test -v 1.0 << EOF
+Module dkms_dependencies_rebuild_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_rebuild_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_dependencies_rebuild_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+EOF
+
+echo 'Removing the downgraded prerequisite test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_test-1.0 /usr/src/dkms_dependencies_rebuild_test-1.0
+
+echo 'Adding test module with unsatisfied dependencies'
+run_with_expected_output dkms add test/dkms_dependencies_rebuild_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_dependencies_rebuild_test/1.0/source -> /usr/src/dkms_dependencies_rebuild_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_dependencies_rebuild_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0: added
+EOF
+
+echo 'Building the test module with unsatisfied dependencies (expected error)'
+run_with_expected_error 13 dkms build -k "${KERNEL_VER}" -m dkms_dependencies_rebuild_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+
+Error! Aborting build of module dkms_dependencies_rebuild_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}) due to missing BUILD_DEPENDS: dkms_test.
+You may override by specifying --force.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0: added
+EOF
+
+echo 'Building the test module with unsatisfied dependencies by force (expected success, ignoring build dependencies)'
+run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_dependencies_rebuild_test -v 1.0 --force << EOF
+${SIGNING_PROLOGUE}
+Warning: Trying to build module dkms_dependencies_rebuild_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}) despite of missing BUILD_DEPENDS: dkms_test.
+Building module(s)... done.${SIGNING_MESSAGE_rebuild_dependencies}
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+EOF
+
+echo ' Checking there is no dependency version generated when ignoring build dependencies'
+file_not_exists /var/lib/dkms/dkms_dependencies_rebuild_test/kernel-"${KERNEL_VER}"-"${KERNEL_ARCH}"/.dep_dkms_test
+
+echo 'Installing the test module with unsatisfied dependencies'
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_dependencies_rebuild_test -v 1.0 << EOF
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_rebuild_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo "Running dkms autoinstall"
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Unbuilding the test module with unsatisfied dependencies'
+run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_dependencies_rebuild_test -v 1.0 << EOF
+Module dkms_dependencies_rebuild_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_rebuild_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0: added
+EOF
+
+echo "Running dkms autoinstall (expected error)"
+run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}" << EOF
+dkms_dependencies_rebuild_test/1.0 autoinstall failed due to missing dependencies: dkms_test.
+
+Error! One or more modules failed to install during autoinstall.
+Refer to previous errors for more information.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+dkms_dependencies_rebuild_test/1.0: added
+EOF
+
+echo 'Removing the test module with unsatisfied dependencies'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_dependencies_rebuild_test -v 1.0 << EOF
+Module dkms_dependencies_rebuild_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_dependencies_rebuild_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_dependencies_rebuild_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_dependencies_rebuild_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_dependencies_rebuild_test-1.0
+
+echo 'Checking that the environment is clean again'
+check_no_dkms_test
+
+fi # rebuild_dependencies tests
+
+if [[ ! $only || $only = replace ]]; then
+
+############################################################################
+echo '*** Testing replacement of a pre-existing module'
+############################################################################
+
+# This feature is intended to replace modules that are shipped with the
+# kernel image by a newer version, not for supporting different dkms
+# modules with conflicting module names.
+# Only for this test the to-be-replaced module is also a dkms module.
+
+echo 'Adding, building and installing the to-be-replaced test module'
+run_with_expected_output dkms add test/dkms_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+set_signing_message "dkms_test" "1.0"
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Adding, building and installing the replacement test module'
+run_with_expected_output dkms add test/dkms_replace_test-2.0 << EOF
+Creating symlink /var/lib/dkms/dkms_replace_test/2.0/source -> /usr/src/dkms_replace_test-2.0
+EOF
+check_module_source_tree_created /usr/src/dkms_replace_test-2.0
+run_status_with_expected_output 'dkms_replace_test' << EOF
+dkms_replace_test/2.0: added
+EOF
+
+set_signing_message "dkms_replace_test" "2.0" "dkms_test"
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_replace_test -v 2.0 << EOF
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+Found pre-existing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}, archiving for uninstallation
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_replace_test' << EOF
+dkms_replace_test/2.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed (Original modules exist)
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed (Differences between built and installed modules)
+EOF
+
+echo 'Unbuilding the replacement test module'
+run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_replace_test -v 2.0 << EOF
+Module dkms_replace_test/2.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Restoring archived original module /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_replace_test' << EOF
+dkms_replace_test/2.0: added
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Running dkms autoinstall'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_replace_test/2.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE}
+Found pre-existing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}, archiving for uninstallation
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test dkms_replace_test.
+EOF
+run_status_with_expected_output 'dkms_replace_test' << EOF
+dkms_replace_test/2.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed (Original modules exist)
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed (Differences between built and installed modules)
+EOF
+
+echo 'Running dkms autoinstall again'
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_replace_test' << EOF
+dkms_replace_test/2.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed (Original modules exist)
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed (Differences between built and installed modules)
+EOF
+
+echo 'Removing the replacement test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_replace_test -v 2.0 << EOF
+Module dkms_replace_test/2.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Restoring archived original module /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_replace_test/2.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_replace_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Removing the to-be-replaced test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_replace_test' << EOF
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_test-1.0 /usr/src/dkms_replace_test-2.0
+
+echo 'Checking that the environment is clean again'
+check_no_dkms_test
+
+fi # replace tests
+
+if [[ ! $only || $only = multiple ]]; then
+
+############################################################################
+echo '*** Testing more dkms features'
+############################################################################
+
+echo 'Adding test module with patches'
+run_with_expected_output dkms add test/dkms_patches_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_patches_test/1.0/source -> /usr/src/dkms_patches_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_patches_test-1.0
+run_status_with_expected_output 'dkms_patches_test' << EOF
+dkms_patches_test/1.0: added
+EOF
+
+echo 'Building and installing the test module with patches'
+set_signing_message "dkms_patches_test" "1.0"
+SIGNING_MESSAGE_patches="$SIGNING_MESSAGE"
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_patches_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Applying patch patch1.patch... done.
+Applying patch subdir/patch2.patch... done.
+Building module(s)... done.${SIGNING_MESSAGE_patches}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_patches_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_patches_test' << EOF
+dkms_patches_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Unbuilding the test module with patches'
+run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_patches_test -v 1.0 << EOF
+Module dkms_patches_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_patches_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_patches_test' << EOF
+dkms_patches_test/1.0: added
+EOF
+
+echo 'Adding test module with pre/post scripts'
+run_with_expected_output dkms add test/dkms_scripts_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_scripts_test/1.0/source -> /usr/src/dkms_scripts_test-1.0
+Running the post_add script:
+EOF
+check_module_source_tree_created /usr/src/dkms_scripts_test-1.0
+run_status_with_expected_output 'dkms_scripts_test' << EOF
+dkms_scripts_test/1.0: added
+EOF
+
+echo 'Building and installing the test module with pre/post scripts'
+set_signing_message "dkms_scripts_test" "1.0"
+SIGNING_MESSAGE_scripts="$SIGNING_MESSAGE"
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_scripts_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Running the pre_build script... done.
+Building module(s)... done.${SIGNING_MESSAGE_scripts}
+Running the post_build script... done.
+Running the pre_install script:
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_scripts_test.ko${mod_compression_ext}
+Running the post_install script:
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_scripts_test' << EOF
+dkms_scripts_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Unbuilding the test module with pre/post scripts'
+run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_scripts_test -v 1.0 << EOF
+Module dkms_scripts_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_scripts_test.ko${mod_compression_ext}
+Running the post_remove script:
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_scripts_test' << EOF
+dkms_scripts_test/1.0: added
+EOF
+
+echo 'Adding noisy test module'
+run_with_expected_output dkms add test/dkms_noisy_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_noisy_test/1.0/source -> /usr/src/dkms_noisy_test-1.0
+Running the post_add script:
+/var/lib/dkms/dkms_noisy_test/1.0/source/script.sh post_add
+post_add: line 1
+post_add: line 2/stderr
+post_add: line 3
+post_add: line 4/stderr
+post_add: line 5
+EOF
+check_module_source_tree_created /usr/src/dkms_noisy_test-1.0
+run_status_with_expected_output 'dkms_noisy_test' << EOF
+dkms_noisy_test/1.0: added
+EOF
+
+echo 'Building and installing the noisy test module'
+set_signing_message "dkms_noisy_test" "1.0"
+SIGNING_MESSAGE_noisy="$SIGNING_MESSAGE"
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_noisy_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Applying patch patch2.patch... done.
+Applying patch patch1.patch... done.
+Running the pre_build script... done.
+Building module(s)... done.${SIGNING_MESSAGE_noisy}
+Running the post_build script... done.
+Running the pre_install script:
+/var/lib/dkms/dkms_noisy_test/1.0/source/script.sh pre_install
+pre_install: line 1
+pre_install: line 2/stderr
+pre_install: line 3
+pre_install: line 4/stderr
+pre_install: line 5
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noisy_test.ko${mod_compression_ext}
+Running the post_install script:
+/var/lib/dkms/dkms_noisy_test/1.0/source/script.sh post_install
+post_install: line 1
+post_install: line 2/stderr
+post_install: line 3
+post_install: line 4/stderr
+post_install: line 5
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_noisy_test' << EOF
+dkms_noisy_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Checking make.log content'
+check_make_log_content "/var/lib/dkms/dkms_noisy_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/log/make.log" << EOF
+DKMS (${DKMS_VERSION}) make.log for dkms_noisy_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+
+
+Applying patch patch2.patch
+# command: patch -p1 < ./patches/patch2.patch
+patching file Makefile
+patching file dkms_noisy_test.c
+
+# exit code: 0
+# elapsed time:
+----------------------------------------------------------------
+
+Applying patch patch1.patch
+# command: patch -p1 < ./patches/patch1.patch
+patching file Makefile
+Hunk #1 succeeded at 3 (offset 2 lines).
+patching file dkms_noisy_test.c
+Hunk #1 succeeded at 18 (offset 2 lines).
+
+# exit code: 0
+# elapsed time:
+----------------------------------------------------------------
+
+Running the pre_build script
+# command: cd /var/lib/dkms/dkms_noisy_test/1.0/build/ && /var/lib/dkms/dkms_noisy_test/1.0/build/script.sh pre_build
+/var/lib/dkms/dkms_noisy_test/1.0/build/script.sh pre_build
+pre_build: line 1
+pre_build: line 2/stderr
+pre_build: line 3
+pre_build: line 4/stderr
+pre_build: line 5
+
+# exit code: 0
+# elapsed time:
+----------------------------------------------------------------
+
+Building module(s)
+# command: make -j1 KERNELRELEASE=${KERNEL_VER} -C /lib/modules/${KERNEL_VER}/build M=/var/lib/dkms/dkms_noisy_test/1.0/build
+ CC dkms_noisy_test.o
+ CC dkms_noisy_test.mod.o
+ LD dkms_noisy_test.ko
+
+# exit code: 0
+# elapsed time:
+----------------------------------------------------------------
+
+Running the post_build script
+# command: cd /var/lib/dkms/dkms_noisy_test/1.0/build/ && /var/lib/dkms/dkms_noisy_test/1.0/build/script.sh post_build
+/var/lib/dkms/dkms_noisy_test/1.0/build/script.sh post_build
+post_build: line 1
+post_build: line 2/stderr
+post_build: line 3
+post_build: line 4/stderr
+post_build: line 5
+
+# exit code: 0
+# elapsed time:
+----------------------------------------------------------------
+EOF
+
+echo 'Unbuilding the noisy test module'
+run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_noisy_test -v 1.0 << EOF
+Module dkms_noisy_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noisy_test.ko${mod_compression_ext}
+Running the post_remove script:
+/var/lib/dkms/dkms_noisy_test/1.0/source/script.sh post_remove
+post_remove: line 1
+post_remove: line 2/stderr
+post_remove: line 3
+post_remove: line 4/stderr
+post_remove: line 5
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_noisy_test' << EOF
+dkms_noisy_test/1.0: added
+EOF
+
+# neither remove the modules here nor run check_no_dkms_test,
+# keep them added for the next part
+
+############################################################################
+echo '*** Testing multiple dkms modules'
+############################################################################
+
+echo 'Adding test module with dependencies'
+run_with_expected_output dkms add test/dkms_dependencies_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_dependencies_test/1.0/source -> /usr/src/dkms_dependencies_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_dependencies_test-1.0
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0: added
+EOF
+
+echo 'Adding build-exclusive test module'
+run_with_expected_output dkms add test/dkms_build_exclusive_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_build_exclusive_test/1.0/source -> /usr/src/dkms_build_exclusive_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_build_exclusive_test-1.0
+run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
+dkms_build_exclusive_test/1.0: added
+EOF
+
+echo 'Adding noautoinstall test module'
+run_with_expected_output dkms add test/dkms_noautoinstall_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_noautoinstall_test/1.0/source -> /usr/src/dkms_noautoinstall_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_noautoinstall_test-1.0
+run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
+dkms_noautoinstall_test/1.0: added
+EOF
+
+echo 'Adding test module'
+run_with_expected_output dkms add test/dkms_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo "Running dkms autoinstall with multiple modules"
+set_signing_message "dkms_test" "1.0"
+run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_build_exclusive_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Warning: The /var/lib/dkms/dkms_build_exclusive_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/dkms.conf
+for module dkms_build_exclusive_test/1.0 includes a BUILD_EXCLUSIVE directive
+which does not match this kernel/arch/config.
+This indicates that it should not be built.
+
+Autoinstall of module dkms_noisy_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Applying patch patch2.patch... done.
+Applying patch patch1.patch... done.
+Running the pre_build script... done.
+Building module(s)... done.${SIGNING_MESSAGE_noisy}
+Running the post_build script... done.
+Running the pre_install script:
+/var/lib/dkms/dkms_noisy_test/1.0/source/script.sh pre_install
+pre_install: line 1
+pre_install: line 2/stderr
+pre_install: line 3
+pre_install: line 4/stderr
+pre_install: line 5
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noisy_test.ko${mod_compression_ext}
+Running the post_install script:
+/var/lib/dkms/dkms_noisy_test/1.0/source/script.sh post_install
+post_install: line 1
+post_install: line 2/stderr
+post_install: line 3
+post_install: line 4/stderr
+post_install: line 5
+Running depmod... done.
+
+Autoinstall of module dkms_patches_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Applying patch patch1.patch... done.
+Applying patch subdir/patch2.patch... done.
+Building module(s)... done.${SIGNING_MESSAGE_patches}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_patches_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Autoinstall of module dkms_scripts_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Running the pre_build script... done.
+Building module(s)... done.${SIGNING_MESSAGE_scripts}
+Running the post_build script... done.
+Running the pre_install script:
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_scripts_test.ko${mod_compression_ext}
+Running the post_install script:
+Running depmod... done.
-echo 'Checking that the environment is clean again'
-check_no_dkms_test
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
-############################################################################
-### Testing dkms on a regular module with AUTOINSTALL="" ###
-############################################################################
+Autoinstall of module dkms_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE_dependencies}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_test.ko${mod_compression_ext}
+Running depmod... done.
-echo 'Adding the noautoinstall test module by directory'
-run_with_expected_output dkms add test/dkms_noautoinstall_test-1.0 << EOF
-Creating symlink /var/lib/dkms/dkms_noautoinstall_test/1.0/source -> /usr/src/dkms_noautoinstall_test-1.0
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_noisy_test dkms_patches_test dkms_scripts_test dkms_test dkms_dependencies_test.
+Autoinstall on ${KERNEL_VER} was skipped for module(s) dkms_build_exclusive_test.
+EOF
+run_status_with_expected_output 'dkms_patches_test' << EOF
+dkms_patches_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_scripts_test' << EOF
+dkms_scripts_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_noisy_test' << EOF
+dkms_noisy_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
+dkms_build_exclusive_test/1.0: added
EOF
run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
dkms_noautoinstall_test/1.0: added
EOF
-if ! [[ -d /usr/src/dkms_noautoinstall_test-1.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_noautoinstall_test-1.0 was not created'
- exit 1
-fi
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
-echo "Running dkms autoinstall"
+echo "Running dkms autoinstall again with multiple modules"
run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_build_exclusive_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Warning: The /var/lib/dkms/dkms_build_exclusive_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/dkms.conf
+for module dkms_build_exclusive_test/1.0 includes a BUILD_EXCLUSIVE directive
+which does not match this kernel/arch/config.
+This indicates that it should not be built.
+
+Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_dependencies_test dkms_noisy_test dkms_patches_test dkms_scripts_test dkms_test.
+Autoinstall on ${KERNEL_VER} was skipped for module(s) dkms_build_exclusive_test.
EOF
-run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
-dkms_noautoinstall_test/1.0: added
+run_status_with_expected_output 'dkms_patches_test' << EOF
+dkms_patches_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
EOF
-
-echo 'Building the noautoinstall test module'
-set_signing_message "dkms_noautoinstall_test" "1.0"
-run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+run_status_with_expected_output 'dkms_scripts_test' << EOF
+dkms_scripts_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
EOF
-run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
-dkms_noautoinstall_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+run_status_with_expected_output 'dkms_noisy_test' << EOF
+dkms_noisy_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
EOF
-
-echo 'Installing the noautoinstall test module'
-run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
-Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noautoinstall_test.ko${mod_compression_ext}
-Running depmod... done.
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
+dkms_build_exclusive_test/1.0: added
EOF
run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
-dkms_noautoinstall_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+dkms_noautoinstall_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
EOF
-echo 'Uninstalling the noautoinstall test module'
-run_with_expected_output dkms uninstall -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
-Module dkms_noautoinstall_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+echo 'Running dkms kernel_prerm'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+dkms: removing module dkms_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
-Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noautoinstall_test.ko${mod_compression_ext}
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dependencies_test.ko${mod_compression_ext}
+
+dkms: removing module dkms_noisy_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_noisy_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noisy_test.ko${mod_compression_ext}
+Running the post_remove script:
+/var/lib/dkms/dkms_noisy_test/1.0/source/script.sh post_remove
+post_remove: line 1
+post_remove: line 2/stderr
+post_remove: line 3
+post_remove: line 4/stderr
+post_remove: line 5
+
+dkms: removing module dkms_patches_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_patches_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_patches_test.ko${mod_compression_ext}
+
+dkms: removing module dkms_scripts_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_scripts_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_scripts_test.ko${mod_compression_ext}
+Running the post_remove script:
+
+dkms: removing module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+
Running depmod... done.
EOF
+run_status_with_expected_output 'dkms_patches_test' << EOF
+dkms_patches_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_scripts_test' << EOF
+dkms_scripts_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_noisy_test' << EOF
+dkms_noisy_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
+dkms_build_exclusive_test/1.0: added
+EOF
run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
-dkms_noautoinstall_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+dkms_noautoinstall_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
EOF
-if [[ -e "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noautoinstall_test.ko${mod_compression_ext}" ]] ; then
- echo >&2 "Error: module not removed in /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_noautoinstall_test.ko${mod_compression_ext}"
- exit 1
-fi
-echo 'Unbuilding the noautoinstall test module'
-run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
-Module dkms_noautoinstall_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+echo 'Running dkms kernel_prerm again'
+run_with_expected_output dkms kernel_prerm -k "${KERNEL_VER}" << EOF
+EOF
+run_status_with_expected_output 'dkms_patches_test' << EOF
+dkms_patches_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_scripts_test' << EOF
+dkms_scripts_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_noisy_test' << EOF
+dkms_noisy_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+dkms_dependencies_test/1.0: added
+EOF
+run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
+dkms_build_exclusive_test/1.0: added
EOF
run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
dkms_noautoinstall_test/1.0: added
EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo 'Removing the test module with patches'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_patches_test -v 1.0 << EOF
+Module dkms_patches_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_patches_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_patches_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_patches_test' << EOF
+EOF
+
+echo 'Removing the test module with pre/post scripts'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_scripts_test -v 1.0 << EOF
+Module dkms_scripts_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_scripts_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_scripts_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_scripts_test' << EOF
+EOF
+
+echo 'Removing the noisy test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_noisy_test -v 1.0 << EOF
+Module dkms_noisy_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_noisy_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_noisy_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_noisy_test' << EOF
+EOF
+
+echo 'Removing the test module with dependencies'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_dependencies_test -v 1.0 << EOF
+Module dkms_dependencies_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_dependencies_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_dependencies_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_dependencies_test' << EOF
+EOF
+
+echo 'Removing the build-exclusive test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_build_exclusive_test -v 1.0 << EOF
+Module dkms_build_exclusive_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_build_exclusive_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_build_exclusive_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
+EOF
echo 'Removing the noautoinstall test module'
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_noautoinstall_test -v 1.0 << EOF
-Module dkms_noautoinstall_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_noautoinstall_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_noautoinstall_test-1.0 completely from the DKMS tree.
+Module dkms_noautoinstall_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_noautoinstall_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_noautoinstall_test/1.0 completely from the DKMS tree.
EOF
run_status_with_expected_output 'dkms_noautoinstall_test' << EOF
EOF
-if ! [[ -d /usr/src/dkms_noautoinstall_test-1.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_noautoinstall_test-1.0 was removed'
- exit 1
-fi
-echo 'Removing /usr/src/dkms_noautoinstall_test-1.0'
-rm -r /usr/src/dkms_noautoinstall_test-1.0
+echo 'Removing the test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+
+remove_module_source_tree \
+ /usr/src/dkms_patches_test-1.0 \
+ /usr/src/dkms_scripts_test-1.0 \
+ /usr/src/dkms_noisy_test-1.0 \
+ /usr/src/dkms_dependencies_test-1.0 \
+ /usr/src/dkms_build_exclusive_test-1.0 \
+ /usr/src/dkms_noautoinstall_test-1.0 \
+ /usr/src/dkms_test-1.0
echo 'Checking that the environment is clean again'
check_no_dkms_test
+fi # multiple tests
+
+if [[ ! $only || $only = malformed ]]; then
+
############################################################################
-### Testing malformed/borderline dkms.conf ###
+echo '*** Testing malformed/borderline dkms.conf'
############################################################################
-abspwd=$(readlink -f $(pwd))
+abspwd=$(readlink -f "$(pwd)")
echo 'Testing dkms add of source tree without dkms.conf (expected error)'
-run_with_expected_error 1 dkms add ${abspwd}/test/dkms_conf_test_no_conf << EOF
+run_with_expected_error 1 dkms add "${abspwd}/test/dkms_conf_test_no_conf" << EOF
+
Error! Arguments and are not specified.
Usage: add / or
add -m / or
@@ -781,7 +2911,7 @@ echo 'Testing dkms add with empty dkms.conf (expected error)'
run_with_expected_error 8 dkms add test/dkms_conf_test_empty << EOF
dkms.conf: Error! No 'PACKAGE_NAME' directive specified.
dkms.conf: Error! No 'PACKAGE_VERSION' directive specified.
-dkms.conf: Warning! Zero modules specified.
+
Error! Bad conf file.
File: ${abspwd}/test/dkms_conf_test_empty/dkms.conf does not represent a valid dkms.conf file.
EOF
@@ -794,111 +2924,337 @@ dkms.conf: Error! Directive 'DEST_MODULE_LOCATION' does not begin with
'/kernel', '/updates', or '/extra' in record #0.
dkms.conf: Error! 'BUILT_MODULE_NAME' directive ends in '.o' or '.ko' in record #1.
dkms.conf: Error! No 'DEST_MODULE_LOCATION' directive specified for record #1.
+dkms.conf: Error! Unsupported AUTOINSTALL value 'maybe'
+
+Error! Bad conf file.
+File: ${abspwd}/test/dkms_conf_test_invalid/dkms.conf does not represent a valid dkms.conf file.
+EOF
+
+# --------------------------------------------------------------------------
+
+echo 'Testing dkms.conf defining zero modules'
+run_with_expected_output dkms add test/dkms_conf_test_zero_modules << EOF
+dkms.conf: Warning! Zero modules specified.
+Creating symlink /var/lib/dkms/dkms_conf_test/1.0/source -> /usr/src/dkms_conf_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_conf_test-1.0
+run_status_with_expected_output 'dkms_conf_test' << EOF
+dkms_conf_test/1.0: added
+EOF
+
+run_with_expected_output dkms remove --all -m dkms_conf_test -v 1.0 << EOF
+Deleting module dkms_conf_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_conf_test' << EOF
+EOF
+
+echo 'Testing add/build/install of a test module building zero kernel modules'
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_conf_test -v 1.0 << EOF
+dkms.conf: Warning! Zero modules specified.
+Creating symlink /var/lib/dkms/dkms_conf_test/1.0/source -> /usr/src/dkms_conf_test-1.0
+
+dkms.conf: Warning! Zero modules specified.
+${SIGNING_PROLOGUE}
+Building module(s)... done.
+dkms.conf: Warning! Zero modules specified.
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_conf_test' << EOF
+dkms_conf_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+run_with_expected_output dkms remove --all -m dkms_conf_test -v 1.0 << EOF
+Module dkms_conf_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Running depmod... done.
+
+Deleting module dkms_conf_test/1.0 completely from the DKMS tree.
+EOF
+
+remove_module_source_tree /usr/src/dkms_conf_test-1.0
+
+# --------------------------------------------------------------------------
+
+echo 'Testing dkms.conf with defaulted BUILT_MODULE_NAME'
+run_with_expected_output dkms add test/dkms_conf_test_defaulted_BUILT_MODULE_NAME << EOF
+Creating symlink /var/lib/dkms/dkms_conf_test/1.0/source -> /usr/src/dkms_conf_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_conf_test-1.0
+run_status_with_expected_output 'dkms_conf_test' << EOF
+dkms_conf_test/1.0: added
+EOF
+
+echo 'Building test module without source (expected error)'
+run_with_expected_error 8 dkms build -k "${KERNEL_VER}" -m dkms_conf_test -v 1.0 << EOF
+
+Error! The directory /var/lib/dkms/dkms_conf_test/1.0/source does not appear to have module source located within it.
+Build halted.
+EOF
+run_status_with_expected_output 'dkms_conf_test' << EOF
+dkms_conf_test/1.0: added
+EOF
+
+run_with_expected_output dkms remove --all -m dkms_conf_test -v 1.0 << EOF
+Deleting module dkms_conf_test/1.0 completely from the DKMS tree.
+EOF
+
+remove_module_source_tree /usr/src/dkms_conf_test-1.0
+
+# --------------------------------------------------------------------------
+
+echo 'Testing dkms.conf with sparse BUILT_MODULE_NAME[] array (expected error)'
+run_with_expected_error 8 dkms add test/dkms_conf_test_sparse_arrays << EOF
+dkms.conf: Error! No 'BUILT_MODULE_NAME' directive specified for record #0.
+dkms.conf: Error! No 'DEST_MODULE_LOCATION' directive specified for record #0.
+dkms.conf: Error! No 'BUILT_MODULE_NAME' directive specified for record #2.
+dkms.conf: Error! No 'DEST_MODULE_LOCATION' directive specified for record #2.
+dkms.conf: Error! No 'BUILT_MODULE_NAME' directive specified for record #4.
dkms.conf: Error! Directive 'DEST_MODULE_LOCATION' does not begin with
-'/kernel', '/updates', or '/extra' in record #1.
+'/kernel', '/updates', or '/extra' in record #4.
+
+Error! Bad conf file.
+File: ${abspwd}/test/dkms_conf_test_sparse_arrays/dkms.conf does not represent a valid dkms.conf file.
+EOF
+
+# --------------------------------------------------------------------------
+
+echo 'Testing dkms.conf with missing patch'
+run_with_expected_output dkms add test/dkms_conf_test_patch_missing << EOF
+Creating symlink /var/lib/dkms/dkms_conf_test/1.0/source -> /usr/src/dkms_conf_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_conf_test-1.0
+run_status_with_expected_output 'dkms_conf_test' << EOF
+dkms_conf_test/1.0: added
+EOF
+
+echo ' Building test module with missing patch (expected error)'
+run_with_expected_error 5 dkms build -k "${KERNEL_VER}" -m dkms_conf_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+
+Error! Patch missing.patch as specified in dkms.conf cannot be
+found in /var/lib/dkms/dkms_conf_test/1.0/build/patches/.
+EOF
+run_status_with_expected_output 'dkms_conf_test' << EOF
+dkms_conf_test/1.0: added
+EOF
+
+run_with_expected_output dkms remove --all -m dkms_conf_test -v 1.0 << EOF
+Deleting module dkms_conf_test/1.0 completely from the DKMS tree.
+EOF
+
+remove_module_source_tree /usr/src/dkms_conf_test-1.0
+
+# --------------------------------------------------------------------------
+
+echo 'Testing dkms.conf with bad patch path (../some.patch)'
+run_with_expected_output dkms add test/dkms_conf_test_patch_badpath1 << EOF
+Creating symlink /var/lib/dkms/dkms_conf_test/1.0/source -> /usr/src/dkms_conf_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_conf_test-1.0
+run_status_with_expected_output 'dkms_conf_test' << EOF
+dkms_conf_test/1.0: added
+EOF
+
+echo ' Building test module with bad patch path (expected error)'
+run_with_expected_error 5 dkms build -k "${KERNEL_VER}" -m dkms_conf_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+
+Error! Patch ../badpath.patch as specified in dkms.conf contains '..' path component.
+EOF
+run_status_with_expected_output 'dkms_conf_test' << EOF
+dkms_conf_test/1.0: added
+EOF
+
+run_with_expected_output dkms remove --all -m dkms_conf_test -v 1.0 << EOF
+Deleting module dkms_conf_test/1.0 completely from the DKMS tree.
+EOF
+
+remove_module_source_tree /usr/src/dkms_conf_test-1.0
+
+# --------------------------------------------------------------------------
+
+echo 'Testing dkms.conf with bad patch path (path/../some.patch)'
+run_with_expected_output dkms add test/dkms_conf_test_patch_badpath2 << EOF
+Creating symlink /var/lib/dkms/dkms_conf_test/1.0/source -> /usr/src/dkms_conf_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_conf_test-1.0
+run_status_with_expected_output 'dkms_conf_test' << EOF
+dkms_conf_test/1.0: added
+EOF
+
+echo ' Building test module with bad patch path (expected error)'
+run_with_expected_error 5 dkms build -k "${KERNEL_VER}" -m dkms_conf_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+
+Error! Patch subdir/../badpath.patch as specified in dkms.conf contains '..' path component.
+EOF
+run_status_with_expected_output 'dkms_conf_test' << EOF
+dkms_conf_test/1.0: added
+EOF
+
+run_with_expected_output dkms remove --all -m dkms_conf_test -v 1.0 << EOF
+Deleting module dkms_conf_test/1.0 completely from the DKMS tree.
+EOF
+
+remove_module_source_tree /usr/src/dkms_conf_test-1.0
+
+# --------------------------------------------------------------------------
+
+echo 'Testing dkms.conf specifying a module twice (expected error)'
+run_with_expected_error 8 dkms add test/dkms_duplicate_test << EOF
+dkms.conf: Error! Duplicate module 'dkms_duplicate_test' in 'BUILT_MODULE_NAME[1]'.
+dkms.conf: Error! Duplicate module 'dkms_duplicate_test' in 'DEST_MODULE_NAME[1]'.
+
+Error! Bad conf file.
+File: /usr/src/dkms_duplicate_test-1.0/dkms.conf does not represent a valid dkms.conf file.
+EOF
+check_module_source_tree_created /usr/src/dkms_duplicate_test-1.0
+run_status_with_expected_output 'dkms_duplicate_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_duplicate_test-1.0
+
+# --------------------------------------------------------------------------
+
+echo 'Testing dkms.conf specifying a module twice in BUILT_MODULE_NAME[] (expected error)'
+run_with_expected_error 8 dkms add test/dkms_duplicate_built_test-1.0 << EOF
+dkms.conf: Error! Duplicate module 'dkms_duplicate_built_test' in 'BUILT_MODULE_NAME[1]'.
+
Error! Bad conf file.
-File: ${abspwd}/test/dkms_conf_test_invalid/dkms.conf does not represent a valid dkms.conf file.
+File: /usr/src/dkms_duplicate_built_test-1.0/dkms.conf does not represent a valid dkms.conf file.
+EOF
+check_module_source_tree_created /usr/src/dkms_duplicate_built_test-1.0
+run_status_with_expected_output 'dkms_duplicate_built_test' << EOF
EOF
-echo 'Testing dkms.conf defining zero modules'
-run_with_expected_output dkms add test/dkms_conf_test_zero_modules << EOF
-dkms.conf: Warning! Zero modules specified.
-dkms.conf: Warning! Zero modules specified.
-Creating symlink /var/lib/dkms/dkms_conf_test/1.0/source -> /usr/src/dkms_conf_test-1.0
+remove_module_source_tree /usr/src/dkms_duplicate_built_test-1.0
+
+# --------------------------------------------------------------------------
+
+echo 'Testing dkms.conf specifying a module twice in DEST_MODULE_NAME[] (expected error)'
+run_with_expected_error 8 dkms add test/dkms_duplicate_dest_test-1.0 << EOF
+dkms.conf: Error! Duplicate module 'dkms_duplicate_dest_test' in 'DEST_MODULE_NAME[1]'.
+
+Error! Bad conf file.
+File: /usr/src/dkms_duplicate_dest_test-1.0/dkms.conf does not represent a valid dkms.conf file.
EOF
-run_status_with_expected_output 'dkms_conf_test' << EOF
-dkms_conf_test/1.0: added
+check_module_source_tree_created /usr/src/dkms_duplicate_dest_test-1.0
+run_status_with_expected_output 'dkms_duplicate_dest_test' << EOF
EOF
-run_with_expected_output dkms remove --all -m dkms_conf_test -v 1.0 << EOF
-Deleting module dkms_conf_test-1.0 completely from the DKMS tree.
+remove_module_source_tree /usr/src/dkms_duplicate_dest_test-1.0
+
+# --------------------------------------------------------------------------
+
+echo 'Testing dkms.conf with CR/LF line endings'
+run_with_expected_output dkms add test/dkms_crlf_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_crlf_test/1.0/source -> /usr/src/dkms_crlf_test-1.0
EOF
-run_status_with_expected_output 'dkms_conf_test' << EOF
+check_module_source_tree_created /usr/src/dkms_crlf_test-1.0
+run_status_with_expected_output 'dkms_crlf_test' << EOF
+dkms_crlf_test/1.0: added
EOF
-echo 'Testing add/build/install of a test module building zero kernel modules'
-run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_conf_test -v 1.0 << EOF
-dkms.conf: Warning! Zero modules specified.
-Creating symlink /var/lib/dkms/dkms_conf_test/1.0/source -> /usr/src/dkms_conf_test-1.0
-Cleaning build area... done.
-Building module(s)... done.
-Cleaning build area... done.
+echo ' Building and installing the test module'
+set_signing_message "dkms_crlf_test" "1.0" "dkms_dos_test"
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_crlf_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dos_test.ko${mod_compression_ext}
Running depmod... done.
EOF
-run_status_with_expected_output 'dkms_conf_test' << EOF
-dkms.conf: Warning! Zero modules specified.
-dkms_conf_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+run_status_with_expected_output 'dkms_crlf_test' << EOF
+dkms_crlf_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
EOF
-run_with_expected_output dkms remove --all -m dkms_conf_test -v 1.0 << EOF
-dkms.conf: Warning! Zero modules specified.
-dkms.conf: Warning! Zero modules specified.
-Module dkms_conf_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+echo ' Removing the test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_crlf_test -v 1.0 << EOF
+Module dkms_crlf_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_dos_test.ko${mod_compression_ext}
Running depmod... done.
-Deleting module dkms_conf_test-1.0 completely from the DKMS tree.
+
+Deleting module dkms_crlf_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_crlf_test' << EOF
EOF
-echo 'Removing /usr/src/dkms_conf_test-1.0'
-rm -r /usr/src/dkms_conf_test-1.0
+remove_module_source_tree /usr/src/dkms_crlf_test-1.0
-echo 'Testing dkms.conf with defaulted BUILT_MODULE_NAME'
-run_with_expected_output dkms add test/dkms_conf_test_defaulted_BUILT_MODULE_NAME << EOF
-Creating symlink /var/lib/dkms/dkms_conf_test/1.0/source -> /usr/src/dkms_conf_test-1.0
+# --------------------------------------------------------------------------
+
+echo 'Testing dkms.conf with deprecated directives'
+run_with_expected_output dkms add test/dkms_deprecated_test-1.0 << EOF
+Deprecated feature: REMAKE_INITRD (/usr/src/dkms_deprecated_test-1.0/dkms.conf)
+Creating symlink /var/lib/dkms/dkms_deprecated_test/1.0/source -> /usr/src/dkms_deprecated_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_deprecated_test-1.0
+run_status_with_expected_output 'dkms_deprecated_test' << EOF
+dkms_deprecated_test/1.0: added
EOF
-echo 'Building test module without source (expected error)'
-run_with_expected_error 8 dkms build -k "${KERNEL_VER}" -m dkms_conf_test -v 1.0 << EOF
-Error! The directory /var/lib/dkms/dkms_conf_test/1.0/source does not appear to have module source located within it.
-Build halted.
+echo ' Building and installing the test module'
+set_signing_message "dkms_deprecated_test" "1.0"
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_deprecated_test -v 1.0 << EOF
+Deprecated feature: REMAKE_INITRD (/var/lib/dkms/dkms_deprecated_test/1.0/source/dkms.conf)
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_deprecated_test.ko${mod_compression_ext}
+Running depmod... done.
EOF
-run_status_with_expected_output 'dkms_conf_test' << EOF
-dkms_conf_test/1.0: added
+run_status_with_expected_output 'dkms_deprecated_test' << EOF
+dkms_deprecated_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
EOF
-run_with_expected_output dkms remove --all -m dkms_conf_test -v 1.0 << EOF
-Deleting module dkms_conf_test-1.0 completely from the DKMS tree.
+echo ' Removing the test module'
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_deprecated_test -v 1.0 << EOF
+Module dkms_deprecated_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_deprecated_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_deprecated_test/1.0 completely from the DKMS tree.
EOF
+run_status_with_expected_output 'dkms_deprecated_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_deprecated_test-1.0
-echo 'Removing /usr/src/dkms_conf_test-1.0'
-rm -r /usr/src/dkms_conf_test-1.0
+# --------------------------------------------------------------------------
echo 'Checking that the environment is clean again'
check_no_dkms_test
+fi # malformed tests
+
+if [[ ! $only || $only = multiversion ]]; then
+
############################################################################
-### Testing dkms on a module with multiple versions ###
+echo '*** Testing dkms on a module with multiple versions'
############################################################################
echo 'Adding the multiver test modules by directory'
run_with_expected_output dkms add test/dkms_multiver_test/1.0 << EOF
Creating symlink /var/lib/dkms/dkms_multiver_test/1.0/source -> /usr/src/dkms_multiver_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_multiver_test-1.0
run_status_with_expected_output 'dkms_multiver_test' << EOF
dkms_multiver_test/1.0: added
EOF
-if ! [[ -d /usr/src/dkms_multiver_test-1.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_multiver_test-1.0 was not created'
- exit 1
-fi
run_with_expected_output dkms add test/dkms_multiver_test/2.0 << EOF
Creating symlink /var/lib/dkms/dkms_multiver_test/2.0/source -> /usr/src/dkms_multiver_test-2.0
EOF
+check_module_source_tree_created /usr/src/dkms_multiver_test-2.0
run_status_with_expected_output 'dkms_multiver_test' << EOF
dkms_multiver_test/1.0: added
dkms_multiver_test/2.0: added
EOF
-if ! [[ -d /usr/src/dkms_multiver_test-1.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_multiver_test-2.0 was not created'
- exit 1
-fi
echo 'Building the multiver test modules'
set_signing_message "dkms_multiver_test" "1.0"
run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_multiver_test -v 1.0 << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
EOF
run_status_with_expected_output 'dkms_multiver_test' << EOF
dkms_multiver_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
@@ -906,9 +3262,8 @@ dkms_multiver_test/2.0: added
EOF
set_signing_message "dkms_multiver_test" "2.0"
run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_multiver_test -v 2.0 << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
EOF
run_status_with_expected_output 'dkms_multiver_test' << EOF
dkms_multiver_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
@@ -933,9 +3288,11 @@ dkms_multiver_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
dkms_multiver_test/2.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
EOF
run_with_expected_error 6 dkms install -k "${KERNEL_VER}" -m dkms_multiver_test -v 1.0 << EOF
+
Error! Module version 1.0 for dkms_multiver_test.ko${mod_compression_ext}
is not newer than what is already found in kernel ${KERNEL_VER} (2.0).
You may override by specifying --force.
+
Error! Installation aborted.
EOF
run_status_with_expected_output 'dkms_multiver_test' << EOF
@@ -945,14 +3302,14 @@ EOF
echo 'Uninstalling the multiver test modules'
run_with_expected_output dkms uninstall -k "${KERNEL_VER}" -m dkms_multiver_test -v 1.0 << EOF
-Module dkms_multiver_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_multiver_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
EOF
run_status_with_expected_output 'dkms_multiver_test' << EOF
dkms_multiver_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
dkms_multiver_test/2.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
EOF
run_with_expected_output dkms uninstall -k "${KERNEL_VER}" -m dkms_multiver_test -v 2.0 << EOF
-Module dkms_multiver_test-2.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Module dkms_multiver_test/2.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_multiver_test.ko${mod_compression_ext}
Running depmod... done.
@@ -968,14 +3325,14 @@ fi
echo 'Unbuilding the multiver test modules'
run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_multiver_test -v 1.0 << EOF
-Module dkms_multiver_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_multiver_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
EOF
run_status_with_expected_output 'dkms_multiver_test' << EOF
dkms_multiver_test/1.0: added
dkms_multiver_test/2.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
EOF
run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_multiver_test -v 2.0 << EOF
-Module dkms_multiver_test 2.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_multiver_test/2.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
EOF
run_status_with_expected_output 'dkms_multiver_test' << EOF
dkms_multiver_test/1.0: added
@@ -984,68 +3341,65 @@ EOF
echo 'Removing the multiver test modules'
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_multiver_test -v 1.0 << EOF
-Module dkms_multiver_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_multiver_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_multiver_test-1.0 completely from the DKMS tree.
+Module dkms_multiver_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_multiver_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_multiver_test/1.0 completely from the DKMS tree.
EOF
run_status_with_expected_output 'dkms_multiver_test' << EOF
dkms_multiver_test/2.0: added
EOF
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_multiver_test -v 2.0 << EOF
-Module dkms_multiver_test 2.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_multiver_test 2.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_multiver_test-2.0 completely from the DKMS tree.
+Module dkms_multiver_test/2.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_multiver_test/2.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_multiver_test/2.0 completely from the DKMS tree.
EOF
run_status_with_expected_output 'dkms_multiver_test' << EOF
EOF
-echo 'Removing /usr/src/dkms_multiver_test-1.0 /usr/src/dkms_multiver_test-2.0'
-rm -r /usr/src/dkms_multiver_test-1.0 /usr/src/dkms_multiver_test-2.0
+remove_module_source_tree /usr/src/dkms_multiver_test-1.0 /usr/src/dkms_multiver_test-2.0
echo 'Checking that the environment is clean again'
check_no_dkms_test
+fi # multiversion tests
+
+if [[ ! $only || $only = noversion ]]; then
+
############################################################################
-### Testing dkms operations ...
+echo '*** Testing dkms operations on modules with no or empty version'
############################################################################
echo 'Adding the nover/emptyver test modules by directory'
run_with_expected_output dkms add test/dkms_nover_test << EOF
Creating symlink /var/lib/dkms/dkms_nover_test/1.0/source -> /usr/src/dkms_nover_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_nover_test-1.0
run_status_with_expected_output 'dkms_nover_test' << EOF
dkms_nover_test/1.0: added
EOF
-if ! [[ -d /usr/src/dkms_nover_test-1.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_nover_test-1.0 was not created'
- exit 1
-fi
run_with_expected_output dkms add test/dkms_emptyver_test << EOF
Creating symlink /var/lib/dkms/dkms_emptyver_test/1.0/source -> /usr/src/dkms_emptyver_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_emptyver_test-1.0
run_status_with_expected_output 'dkms_emptyver_test' << EOF
dkms_emptyver_test/1.0: added
EOF
-if ! [[ -d /usr/src/dkms_emptyver_test-1.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_emptyver_test-1.0 was not created'
- exit 1
-fi
echo 'Building the nover/emptyver test modules'
set_signing_message "dkms_nover_test" "1.0"
run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_nover_test -v 1.0 << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
EOF
run_status_with_expected_output 'dkms_nover_test' << EOF
dkms_nover_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
EOF
set_signing_message "dkms_emptyver_test" "1.0"
run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_emptyver_test -v 1.0 << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
EOF
run_status_with_expected_output 'dkms_emptyver_test' << EOF
dkms_emptyver_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
@@ -1069,7 +3423,7 @@ EOF
echo 'Uninstalling the nover/emptyver test modules'
run_with_expected_output dkms uninstall -k "${KERNEL_VER}" -m dkms_nover_test -v 1.0 << EOF
-Module dkms_nover_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Module dkms_nover_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_nover_test.ko${mod_compression_ext}
Running depmod... done.
@@ -1082,7 +3436,7 @@ if [[ -e "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_nover_test.ko${mo
exit 1
fi
run_with_expected_output dkms uninstall -k "${KERNEL_VER}" -m dkms_emptyver_test -v 1.0 << EOF
-Module dkms_emptyver_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Module dkms_emptyver_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_emptyver_test.ko${mod_compression_ext}
Running depmod... done.
@@ -1097,13 +3451,13 @@ fi
echo 'Unbuilding the nover/emptyver test modules'
run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_nover_test -v 1.0 << EOF
-Module dkms_nover_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_nover_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
EOF
run_status_with_expected_output 'dkms_nover_test' << EOF
dkms_nover_test/1.0: added
EOF
run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_emptyver_test -v 1.0 << EOF
-Module dkms_emptyver_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_emptyver_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
EOF
run_status_with_expected_output 'dkms_emptyver_test' << EOF
dkms_emptyver_test/1.0: added
@@ -1111,41 +3465,38 @@ EOF
echo 'Removing the nover/emptyver test modules'
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_nover_test -v 1.0 << EOF
-Module dkms_nover_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_nover_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_nover_test-1.0 completely from the DKMS tree.
+Module dkms_nover_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_nover_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_nover_test/1.0 completely from the DKMS tree.
EOF
run_status_with_expected_output 'dkms_nover_test' << EOF
EOF
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_emptyver_test -v 1.0 << EOF
-Module dkms_emptyver_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_emptyver_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_emptyver_test-1.0 completely from the DKMS tree.
+Module dkms_emptyver_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_emptyver_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_emptyver_test/1.0 completely from the DKMS tree.
EOF
run_status_with_expected_output 'dkms_emptyver_test' << EOF
EOF
-echo 'Removing /usr/src/dkms_nover_test-1.0 /usr/src/dkms_emptyver_test-1.0'
-rm -r /usr/src/dkms_nover_test-1.0 /usr/src/dkms_emptyver_test-1.0
+remove_module_source_tree /usr/src/dkms_nover_test-1.0 /usr/src/dkms_emptyver_test-1.0
echo 'Adding the nover update test modules 1.0 by directory'
run_with_expected_output dkms add test/dkms_nover_update_test/1.0 << EOF
Creating symlink /var/lib/dkms/dkms_nover_update_test/1.0/source -> /usr/src/dkms_nover_update_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_nover_update_test-1.0
run_status_with_expected_output 'dkms_nover_update_test' << EOF
dkms_nover_update_test/1.0: added
EOF
-if ! [[ -d /usr/src/dkms_nover_update_test-1.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_nover_update_test-1.0 was not created'
- exit 1
-fi
echo 'Installing the nover update test 1.0 modules'
set_signing_message "dkms_nover_update_test" "1.0"
run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_nover_update_test -v 1.0 << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_nover_update_test.ko${mod_compression_ext}
Running depmod... done.
EOF
@@ -1157,21 +3508,17 @@ echo 'Adding the nover update test modules 2.0 by directory'
run_with_expected_output dkms add test/dkms_nover_update_test/2.0 << EOF
Creating symlink /var/lib/dkms/dkms_nover_update_test/2.0/source -> /usr/src/dkms_nover_update_test-2.0
EOF
+check_module_source_tree_created /usr/src/dkms_nover_update_test-2.0
run_status_with_expected_output 'dkms_nover_update_test' << EOF
dkms_nover_update_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
dkms_nover_update_test/2.0: added
EOF
-if ! [[ -d /usr/src/dkms_nover_update_test-2.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_nover_update_test-2.0 was not created'
- exit 1
-fi
echo 'Installing the nover update test 2.0 modules'
set_signing_message "dkms_nover_update_test" "2.0"
run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_nover_update_test -v 2.0 << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_nover_update_test.ko${mod_compression_ext}
Running depmod... done.
EOF
@@ -1184,22 +3531,18 @@ echo 'Adding the nover update test modules 3.0 by directory'
run_with_expected_output dkms add test/dkms_nover_update_test/3.0 << EOF
Creating symlink /var/lib/dkms/dkms_nover_update_test/3.0/source -> /usr/src/dkms_nover_update_test-3.0
EOF
+check_module_source_tree_created /usr/src/dkms_nover_update_test-3.0
run_status_with_expected_output 'dkms_nover_update_test' << EOF
dkms_nover_update_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
dkms_nover_update_test/2.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
dkms_nover_update_test/3.0: added
EOF
-if ! [[ -d /usr/src/dkms_nover_update_test-3.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_nover_update_test-3.0 was not created'
- exit 1
-fi
echo 'Building the nover update test 3.0 modules'
set_signing_message "dkms_nover_update_test" "3.0"
run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_nover_update_test -v 3.0 << EOF
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
EOF
run_status_with_expected_output 'dkms_nover_update_test' << EOF
dkms_nover_update_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
@@ -1216,7 +3559,8 @@ else
echo ' Installing the nover update test 3.0 modules (expected error)'
set_signing_message "dkms_nover_update_test" "3.0"
run_with_expected_error 6 dkms install -k "${KERNEL_VER}" -m dkms_nover_update_test -v 3.0 << EOF
-Module /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_nover_update_test.ko${mod_compression_ext} already installed at version , override by specifying --force
+Module /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_nover_update_test.ko${mod_compression_ext} already installed (unversioned module), override by specifying --force
+
Error! Installation aborted.
EOF
run_status_with_expected_output 'dkms_nover_update_test' << EOF
@@ -1228,122 +3572,116 @@ fi
echo 'Removing the nover update test modules'
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_nover_update_test -v 3.0 << EOF
-Module dkms_nover_update_test 3.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_nover_update_test-3.0 completely from the DKMS tree.
+Module dkms_nover_update_test/3.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_nover_update_test/3.0 completely from the DKMS tree.
EOF
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_nover_update_test -v 2.0 << EOF
-Module dkms_nover_update_test-2.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Module dkms_nover_update_test/2.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_nover_update_test.ko${mod_compression_ext}
Running depmod... done.
-Deleting module dkms_nover_update_test-2.0 completely from the DKMS tree.
+
+Deleting module dkms_nover_update_test/2.0 completely from the DKMS tree.
EOF
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_nover_update_test -v 1.0 << EOF
-Module dkms_nover_update_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_nover_update_test-1.0 completely from the DKMS tree.
+Module dkms_nover_update_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_nover_update_test/1.0 completely from the DKMS tree.
EOF
run_status_with_expected_output 'dkms_nover_update_test' << EOF
EOF
-echo 'Removing /usr/src/dkms_nover_update_test-{1,2,3}.0'
-rm -r /usr/src/dkms_nover_update_test-{1,2,3}.0
+remove_module_source_tree /usr/src/dkms_nover_update_test-{1,2,3}.0
echo 'Checking that the environment is clean'
check_no_dkms_test
+fi # multiversion tests
+
+if [[ ! $only || $only = autoinstall ]]; then
+
############################################################################
-### Testing dkms autoinstall ###
+echo '*** Testing dkms autoinstall error handling'
############################################################################
-echo 'Running autoinstall error testing'
-
echo 'Adding failing test module by directory'
run_with_expected_output dkms add test/dkms_failing_test-1.0 << EOF
Creating symlink /var/lib/dkms/dkms_failing_test/1.0/source -> /usr/src/dkms_failing_test-1.0
EOF
-echo 'Running autoinstall with failing test module (expected error)'
-run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}" << EOF
-Cleaning build area... done.
-Building module(s)...(bad exit status: 2)
-Failed command:
-make -j1 KERNELRELEASE=${KERNEL_VER} all
-Error! Bad return status for module build on kernel: ${KERNEL_VER} (${KERNEL_ARCH})
-Consult /var/lib/dkms/dkms_failing_test/1.0/build/make.log for more information.
-Autoinstall on ${KERNEL_VER} failed for module(s) dkms_failing_test(10).
-Error! One or more modules failed to install during autoinstall.
-Refer to previous errors for more information.
-EOF
+check_module_source_tree_created /usr/src/dkms_failing_test-1.0
echo 'Adding test module with dependencies on failing test module by directory'
-run_with_expected_output dkms add test/dkms_dependencies_test-1.0 << EOF
-Creating symlink /var/lib/dkms/dkms_dependencies_test/1.0/source -> /usr/src/dkms_dependencies_test-1.0
+run_with_expected_output dkms add test/dkms_failing_dependencies_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_failing_dependencies_test/1.0/source -> /usr/src/dkms_failing_dependencies_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_failing_dependencies_test-1.0
+
echo 'Running autoinstall with failing test module and test module with dependencies on the failing module (expected error)'
run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}" << EOF
-Cleaning build area... done.
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_failing_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
Building module(s)...(bad exit status: 2)
Failed command:
make -j1 KERNELRELEASE=${KERNEL_VER} all
+
Error! Bad return status for module build on kernel: ${KERNEL_VER} (${KERNEL_ARCH})
Consult /var/lib/dkms/dkms_failing_test/1.0/build/make.log for more information.
+
Autoinstall on ${KERNEL_VER} failed for module(s) dkms_failing_test(10).
-dkms_dependencies_test/1.0 autoinstall failed due to missing dependencies: dkms_failing_test.
+dkms_failing_dependencies_test/1.0 autoinstall failed due to missing dependencies: dkms_failing_test.
+
Error! One or more modules failed to install during autoinstall.
Refer to previous errors for more information.
EOF
echo 'Removing failing test module'
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_failing_test -v 1.0 << EOF
-Module dkms_failing_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_failing_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_failing_test-1.0 completely from the DKMS tree.
-EOF
-echo 'Removing /usr/src/dkms_failing_test-1.0'
-rm -r /usr/src/dkms_failing_test-1.0
+Module dkms_failing_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_failing_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-echo 'Running autoinstall with test module with missing dependencies (expected error)'
-run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}" << EOF
-dkms_dependencies_test/1.0 autoinstall failed due to missing dependencies: dkms_failing_test.
-Error! One or more modules failed to install during autoinstall.
-Refer to previous errors for more information.
+Deleting module dkms_failing_test/1.0 completely from the DKMS tree.
EOF
+remove_module_source_tree /usr/src/dkms_failing_test-1.0
+
echo 'Removing test module with dependencies'
-run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_dependencies_test -v 1.0 << EOF
-Module dkms_dependencies_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_dependencies_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_dependencies_test-1.0 completely from the DKMS tree.
+run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_failing_dependencies_test -v 1.0 << EOF
+Module dkms_failing_dependencies_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_failing_dependencies_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_failing_dependencies_test/1.0 completely from the DKMS tree.
EOF
-echo 'Removing /usr/src/dkms_dependencies_test-1.0'
-rm -r /usr/src/dkms_dependencies_test-1.0
+
+remove_module_source_tree /usr/src/dkms_failing_dependencies_test-1.0
echo 'Checking that the environment is clean again'
check_no_dkms_test
+fi # autoinstall tests
+
+if [[ ! $only || $only = exclusive ]]; then
+
############################################################################
-### Testing BUILD_EXCLUSIVE_* ###
+echo '*** Testing modules with BUILD_EXCLUSIVE_* directives'
############################################################################
-echo 'Running tests with BUILD_EXCLUSIVE_* modules'
set_signing_message "dkms_test" "1.0"
echo 'Adding the build-exclusive test module by directory'
run_with_expected_output dkms add test/dkms_build_exclusive_test-1.0 << EOF
Creating symlink /var/lib/dkms/dkms_build_exclusive_test/1.0/source -> /usr/src/dkms_build_exclusive_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_build_exclusive_test-1.0
run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
dkms_build_exclusive_test/1.0: added
EOF
-if ! [[ -d /usr/src/dkms_build_exclusive_test-1.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_build_exclusive_test-1.0 was not created'
- return 1
-fi
# Should this really fail?
echo '(Not) building the build-exclusive test module'
run_with_expected_error 77 dkms build -k "${KERNEL_VER}" -m dkms_build_exclusive_test -v 1.0 << EOF
Warning: 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
+for module dkms_build_exclusive_test/1.0 includes a BUILD_EXCLUSIVE directive
which does not match this kernel/arch/config.
This indicates that it should not be built.
EOF
@@ -1353,10 +3691,13 @@ EOF
echo "Running dkms autoinstall (1 x skip)"
run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_build_exclusive_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
Warning: 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
+for module dkms_build_exclusive_test/1.0 includes a BUILD_EXCLUSIVE directive
which does not match this kernel/arch/config.
This indicates that it should not be built.
+
Autoinstall on ${KERNEL_VER} was skipped for module(s) dkms_build_exclusive_test.
EOF
run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
@@ -1367,21 +3708,25 @@ echo 'Adding the test module by directory'
run_with_expected_output dkms add test/dkms_test-1.0 << EOF
Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0: added
EOF
echo "Running dkms autoinstall (1 x skip, 1 x pass)"
run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_build_exclusive_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
Warning: 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
+for module dkms_build_exclusive_test/1.0 includes a BUILD_EXCLUSIVE directive
which does not match this kernel/arch/config.
This indicates that it should not be built.
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE}
Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
Running depmod... done.
+
Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test.
Autoinstall on ${KERNEL_VER} was skipped for module(s) dkms_build_exclusive_test.
EOF
@@ -1394,7 +3739,7 @@ EOF
echo 'Unbuilding the test module'
run_with_expected_output dkms unbuild -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
-Module dkms_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
Running depmod... done.
@@ -1407,75 +3752,86 @@ echo 'Adding failing test module by directory'
run_with_expected_output dkms add test/dkms_failing_test-1.0 << EOF
Creating symlink /var/lib/dkms/dkms_failing_test/1.0/source -> /usr/src/dkms_failing_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_failing_test-1.0
echo "Running dkms autoinstall (1 x skip, 1 x fail, 1 x pass) (expected error)"
run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_build_exclusive_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
Warning: 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
+for module dkms_build_exclusive_test/1.0 includes a BUILD_EXCLUSIVE directive
which does not match this kernel/arch/config.
This indicates that it should not be built.
-Cleaning build area... done.
+
+Autoinstall of module dkms_failing_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
Building module(s)...(bad exit status: 2)
Failed command:
make -j1 KERNELRELEASE=${KERNEL_VER} all
+
Error! Bad return status for module build on kernel: ${KERNEL_VER} (${KERNEL_ARCH})
Consult /var/lib/dkms/dkms_failing_test/1.0/build/make.log for more information.
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
+Building module(s)... done.${SIGNING_MESSAGE}
Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
Running depmod... done.
+
Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test.
Autoinstall on ${KERNEL_VER} was skipped for module(s) dkms_build_exclusive_test.
Autoinstall on ${KERNEL_VER} failed for module(s) dkms_failing_test(10).
+
Error! One or more modules failed to install during autoinstall.
Refer to previous errors for more information.
EOF
echo 'Removing failing test module'
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_failing_test -v 1.0 << EOF
-Module dkms_failing_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_failing_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_failing_test-1.0 completely from the DKMS tree.
+Module dkms_failing_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_failing_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_failing_test/1.0 completely from the DKMS tree.
EOF
-echo 'Removing /usr/src/dkms_failing_test-1.0'
-rm -r /usr/src/dkms_failing_test-1.0
+
+remove_module_source_tree /usr/src/dkms_failing_test-1.0
echo 'Removing the test module'
run_with_expected_output dkms remove --all -m dkms_test -v 1.0 << EOF
-Module dkms_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
Running depmod... done.
-Deleting module dkms_test-1.0 completely from the DKMS tree.
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
EOF
run_status_with_expected_output 'dkms_test' << EOF
EOF
-echo 'Removing /usr/src/dkms_test-1.0'
-rm -r /usr/src/dkms_test-1.0
+
+remove_module_source_tree /usr/src/dkms_test-1.0
echo 'Adding the build-exclusive dependencies test module by directory'
run_with_expected_output dkms add test/dkms_build_exclusive_dependencies_test-1.0 << EOF
Creating symlink /var/lib/dkms/dkms_build_exclusive_dependencies_test/1.0/source -> /usr/src/dkms_build_exclusive_dependencies_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_build_exclusive_dependencies_test-1.0
run_status_with_expected_output 'dkms_build_exclusive_dependencies_test' << EOF
dkms_build_exclusive_dependencies_test/1.0: added
EOF
-if ! [[ -d /usr/src/dkms_build_exclusive_dependencies_test-1.0 ]] ; then
- echo >&2 'Error: directory /usr/src/dkms_build_exclusive_dependencies_test-1.0 was not created'
- return 1
-fi
echo "Running dkms autoinstall (2 x skip, with dependency)"
run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+${SIGNING_PROLOGUE}
+Autoinstall of module dkms_build_exclusive_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
Warning: 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
+for module dkms_build_exclusive_test/1.0 includes a BUILD_EXCLUSIVE directive
which does not match this kernel/arch/config.
This indicates that it should not be built.
+
+Autoinstall of module dkms_build_exclusive_dependencies_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
Warning: The /var/lib/dkms/dkms_build_exclusive_dependencies_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/dkms.conf
-for module dkms_build_exclusive_dependencies_test includes a BUILD_EXCLUSIVE directive
+for module dkms_build_exclusive_dependencies_test/1.0 includes a BUILD_EXCLUSIVE directive
which does not match this kernel/arch/config.
This indicates that it should not be built.
+
Autoinstall on ${KERNEL_VER} was skipped for module(s) dkms_build_exclusive_test dkms_build_exclusive_dependencies_test.
EOF
run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
@@ -1487,28 +3843,33 @@ EOF
echo 'Removing the build-exclusive dependencies test module'
run_with_expected_output dkms remove --all -m dkms_build_exclusive_dependencies_test -v 1.0 << EOF
-Deleting module dkms_build_exclusive_dependencies_test-1.0 completely from the DKMS tree.
+Deleting module dkms_build_exclusive_dependencies_test/1.0 completely from the DKMS tree.
EOF
run_status_with_expected_output 'dkms_build_exclusive_dependencies_test' << EOF
EOF
-echo 'Removing /usr/src/dkms_build_exclusive_dependencies_test-1.0'
-rm -r /usr/src/dkms_build_exclusive_dependencies_test-1.0
+
+remove_module_source_tree /usr/src/dkms_build_exclusive_dependencies_test-1.0
echo 'Removing the build-exclusive test module'
run_with_expected_output dkms remove --all -m dkms_build_exclusive_test -v 1.0 << EOF
-Deleting module dkms_build_exclusive_test-1.0 completely from the DKMS tree.
+Deleting module dkms_build_exclusive_test/1.0 completely from the DKMS tree.
EOF
run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
EOF
-echo 'Removing /usr/src/dkms_build_exclusive_test-1.0'
-rm -r /usr/src/dkms_build_exclusive_test-1.0
+
+remove_module_source_tree /usr/src/dkms_build_exclusive_test-1.0
echo 'Checking that the environment is clean again'
check_no_dkms_test
+fi # exclusive tests
+
+if [[ ! $only || $only = os-release ]]; then
+
############################################################################
-### Testing os-release detection ###
+echo '*** Testing os-release detection'
############################################################################
+
echo "Backing up /etc/os-release and /usr/lib/os-release"
osrelease_cleanup() {
rm -f _os-release
@@ -1517,16 +3878,16 @@ osrelease_cleanup() {
}
for f in /etc/os-release /usr/lib/os-release; do
- if [ -e "$f" ]; then
+ if [[ -e "$f" ]]; then
cp --preserve=all -f "$f" _os-release
break
fi
done
-[ -f _os-release ] || { echo >&2 "Error: file os-release not found"; exit 1; }
+[[ -f _os-release ]] || { echo >&2 "Error: file os-release not found"; exit 1; }
trap osrelease_cleanup EXIT
mv_osrelease() {
- if [ -f "$1" ]; then
+ if [[ -f "$1" ]]; then
mv "$1" "$2" || { echo >&2 "Error: could not move os-release $1"; exit 1; }
fi
}
@@ -1535,6 +3896,7 @@ mv_osrelease "/usr/lib/os-release" "_usrlib-os-release"
echo "Adding the dkms_test-1.0 module with no os-release files (expected error)"
run_with_expected_error 4 dkms add test/dkms_test-1.0 << EOF
+
Error! System is missing os-release file.
EOF
@@ -1544,18 +3906,21 @@ echo "Adding the dkms_test-1.0 module with file /etc/os-release"
run_with_expected_output dkms add test/dkms_test-1.0 << EOF
Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0: added
EOF
echo 'Removing dkms_test module'
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
-Module dkms_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_test-1.0 completely from the DKMS tree.
+Module dkms_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
EOF
-echo "Removing /usr/src/dkms_test-1.0"
-rm -r /usr/src/dkms_test-1.0
+
+remove_module_source_tree /usr/src/dkms_test-1.0
+
echo "Deleting /etc/os-release"
rm -f /etc/os-release
@@ -1565,40 +3930,160 @@ echo "Adding the dkms_test-1.0 module with file /usr/lib/os-release"
run_with_expected_output dkms add test/dkms_test-1.0 << EOF
Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
run_status_with_expected_output 'dkms_test' << EOF
dkms_test/1.0: added
EOF
echo 'Removing dkms_test module'
run_with_expected_output dkms remove -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
-Module dkms_test 1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Module dkms_test 1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_test-1.0 completely from the DKMS tree.
+Module dkms_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+Module dkms_test/1.0 is not built for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
EOF
-echo "Removing /usr/src/dkms_test-1.0"
-rm -r /usr/src/dkms_test-1.0
+
+remove_module_source_tree /usr/src/dkms_test-1.0
+
echo "Deleting /usr/lib/os-release"
rm -f /usr/lib/os-release
echo "Restoring /etc/os-release and /usr/bin/os-release"
osrelease_cleanup
-trap - EXIT
+trap tmpdir_cleanup EXIT
echo 'Checking that the environment is clean again'
check_no_dkms_test
+fi # os-release tests
+
+if [[ ! $only || $only = incomplete ]]; then
+
############################################################################
-### Testing 'broken' status ###
+echo '*** Testing '"'incomplete'"' status'
############################################################################
-echo
-echo 'Running BROKEN tests'
-echo
+echo 'Adding the test module by directory'
+run_with_expected_output dkms add test/dkms_test-1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
+EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo 'Building the test module'
+set_signing_message "dkms_test" "1.0"
+run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+EOF
+
+echo 'Installing the test module'
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Making the built/installed module "incomplete"'
+rm "/var/lib/dkms/dkms_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/module/dkms_test.ko${mod_compression_ext}"
+# if the module didn't exist in the build tree it probably wasn't installed either
+rm "/lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}"
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed (Built modules are missing in the kernel modules folder)
+EOF
+
+echo 'Uninstalling the "incomplete" test module'
+run_with_expected_output dkms uninstall -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Module dkms_test.ko${mod_compression_ext} was not found within /lib/modules/${KERNEL_VER}/
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built (Built modules are missing in the kernel modules folder)
+EOF
+
+echo 'Installing the "incomplete" test module (expected error)'
+run_with_expected_error 6 dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+
+Error! Missing module dkms_test in /var/lib/dkms/dkms_test/1.0/${KERNEL_VER}/${KERNEL_ARCH}/module
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built (Built modules are missing in the kernel modules folder)
+EOF
+
+echo 'Removing the "incomplete" test module with --all'
+run_with_expected_output dkms remove --all -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+
+echo 'Adding the test module by version'
+run_with_expected_output dkms add -m dkms_test -v 1.0 << EOF
+Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0: added
+EOF
+
+echo 'Building the test module'
+run_with_expected_output dkms build -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
+EOF
+
+echo 'Installing the test module'
+run_with_expected_output dkms install -k "${KERNEL_VER}" -m dkms_test -v 1.0 << EOF
+Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+dkms_test/1.0, ${KERNEL_VER}, ${KERNEL_ARCH}: installed
+EOF
+
+echo 'Removing the test module with --all'
+run_with_expected_output dkms remove --all -m dkms_test -v 1.0 << EOF
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Before uninstall, this module version was ACTIVE on this kernel.
+Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
+Running depmod... done.
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
+EOF
+run_status_with_expected_output 'dkms_test' << EOF
+EOF
+
+remove_module_source_tree /usr/src/dkms_test-1.0
+
+echo 'Checking that the environment is clean again'
+check_no_dkms_test
+
+fi # incomplete tests
+
+if [[ ! $only || $only = broken ]]; then
+
+############################################################################
+echo '*** Testing '"'broken'"' status'
+############################################################################
echo 'Adding the test module by directory'
run_with_expected_output dkms add test/dkms_test-1.0 << EOF
Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_test-1.0
echo ' Removing symlink /var/lib/dkms/dkms_test/1.0/source'
rm /var/lib/dkms/dkms_test/1.0/source
@@ -1606,6 +4091,7 @@ rm /var/lib/dkms/dkms_test/1.0/source
echo 'Checking broken status'
run_with_expected_output dkms status dkms_test/1.0 << EOF
dkms_test/1.0: broken
+
Error! dkms_test/1.0: Missing the module source directory or the symbolic link pointing to it.
Manual intervention is required!
EOF
@@ -1618,29 +4104,33 @@ EOF
echo ' Removing symlink /var/lib/dkms/dkms_test/1.0/source'
rm /var/lib/dkms/dkms_test/1.0/source
-echo 'Building broken test module (expected erorr)'
+echo 'Building broken test module (expected error)'
run_with_expected_error 4 dkms build dkms_test/1.0 << EOF
+
Error! dkms_test/1.0 is broken!
Missing the source directory or the symbolic link pointing to it.
Manual intervention is required!
EOF
-echo 'Installing broken test module (expected erorr)'
+echo 'Installing broken test module (expected error)'
run_with_expected_error 4 dkms install dkms_test/1.0 << EOF
+
Error! dkms_test/1.0 is broken!
Missing the source directory or the symbolic link pointing to it.
Manual intervention is required!
EOF
-echo 'Unbuild broken test module (expected erorr)'
+echo 'Unbuild broken test module (expected error)'
run_with_expected_error 4 dkms unbuild dkms_test/1.0 << EOF
+
Error! dkms_test/1.0 is broken!
Missing the source directory or the symbolic link pointing to it.
Manual intervention is required!
EOF
-echo 'Uninstall broken test module (expected erorr)'
+echo 'Uninstall broken test module (expected error)'
run_with_expected_error 4 dkms uninstall dkms_test/1.0 << EOF
+
Error! dkms_test/1.0 is broken!
Missing the source directory or the symbolic link pointing to it.
Manual intervention is required!
@@ -1650,17 +4140,20 @@ echo 'Adding the multiver test module 1.0 by directory'
run_with_expected_output dkms add test/dkms_multiver_test/1.0 << EOF
Creating symlink /var/lib/dkms/dkms_multiver_test/1.0/source -> /usr/src/dkms_multiver_test-1.0
EOF
+check_module_source_tree_created /usr/src/dkms_multiver_test-1.0
echo 'Checking broken status'
run_with_expected_output dkms status << EOF
dkms_multiver_test/1.0: added
dkms_test/1.0: broken
+
Error! dkms_test/1.0: Missing the module source directory or the symbolic link pointing to it.
Manual intervention is required!
EOF
-echo 'Remove broken test module (expected erorr)'
+echo 'Remove broken test module (expected error)'
run_with_expected_error 4 dkms remove dkms_test/1.0 << EOF
+
Error! dkms_test/1.0 is broken!
Missing the source directory or the symbolic link pointing to it.
Manual intervention is required!
@@ -1671,13 +4164,13 @@ run_with_expected_output dkms add dkms_test/1.0 << EOF
Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
EOF
-echo ' Removing source tree /usr/src/dkms_test-1.0/'
-rm -rf /usr/src/dkms_test-1.0/
+remove_module_source_tree /usr/src/dkms_test-1.0/
echo 'Checking broken status'
run_with_expected_output dkms status << EOF
dkms_multiver_test/1.0: added
dkms_test/1.0: broken
+
Error! dkms_test/1.0: Missing the module source directory or the symbolic link pointing to it.
Manual intervention is required!
EOF
@@ -1692,18 +4185,18 @@ echo 'Adding and building the test module by directory'
set_signing_message "dkms_test" "1.0"
run_with_expected_output dkms build test/dkms_test-1.0 -k "${KERNEL_VER}" << EOF
Creating symlink /var/lib/dkms/dkms_test/1.0/source -> /usr/src/dkms_test-1.0
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
EOF
echo 'Adding and building the multiver test module 1.0 by directory'
set_signing_message "dkms_multiver_test" "1.0"
run_with_expected_output dkms build test/dkms_multiver_test/1.0 -k "${KERNEL_VER}" << EOF
Creating symlink /var/lib/dkms/dkms_multiver_test/1.0/source -> /usr/src/dkms_multiver_test-1.0
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
EOF
echo ' Removing symlink /var/lib/dkms/dkms_multiver_test/1.0/source'
@@ -1713,21 +4206,25 @@ echo 'Adding and building the multiver test module 2.0 by directory'
set_signing_message "dkms_multiver_test" "2.0"
run_with_expected_output dkms build test/dkms_multiver_test/2.0 -k "${KERNEL_VER}" << EOF
Creating symlink /var/lib/dkms/dkms_multiver_test/2.0/source -> /usr/src/dkms_multiver_test-2.0
-Cleaning build area... done.
-Building module(s)... done.
-${SIGNING_MESSAGE}Cleaning build area... done.
+
+${SIGNING_PROLOGUE}
+Building module(s)... done.${SIGNING_MESSAGE}
EOF
echo 'Running dkms autoinstall'
run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
+
Error! dkms_multiver_test/1.0 is broken! Missing the source directory or the symbolic link pointing to it.
Manual intervention is required!
+Autoinstall of module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH})
Installing /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
Running depmod... done.
+
Autoinstall on ${KERNEL_VER} succeeded for module(s) dkms_test.
EOF
run_with_expected_output dkms status << EOF
dkms_multiver_test/1.0: broken
+
Error! dkms_multiver_test/1.0: Missing the module source directory or the symbolic link pointing to it.
Manual intervention is required!
dkms_multiver_test/2.0, ${KERNEL_VER}, ${KERNEL_ARCH}: built
@@ -1737,27 +4234,32 @@ EOF
echo 'Removing all modules'
echo ' Removing the test module'
run_with_expected_output dkms remove dkms_test/1.0 -k "${KERNEL_VER}" << EOF
-Module dkms_test-1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
+Module dkms_test/1.0 for kernel ${KERNEL_VER} (${KERNEL_ARCH}):
Before uninstall, this module version was ACTIVE on this kernel.
Deleting /lib/modules/${KERNEL_VER}/${expected_dest_loc}/dkms_test.ko${mod_compression_ext}
Running depmod... done.
-Deleting module dkms_test-1.0 completely from the DKMS tree.
+
+Deleting module dkms_test/1.0 completely from the DKMS tree.
EOF
echo ' Removing the multi_ver_test 2.0 module'
run_with_expected_output dkms remove -m dkms_multiver_test -v 2.0 -k "${KERNEL_VER}" << EOF
-Module dkms_multiver_test 2.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
-Deleting module dkms_multiver_test-2.0 completely from the DKMS tree.
+Module dkms_multiver_test/2.0 is not installed for kernel ${KERNEL_VER} (${KERNEL_ARCH}). Skipping...
+
+Deleting module dkms_multiver_test/2.0 completely from the DKMS tree.
EOF
-echo ' Removing directories: /var/lib/dkms/dkms_test/ /var/lib/dkms/dkms_multiver_test /usr/src/dkms_test-1.0 /usr/src/dkms_multiver_test-?.0'
-rm -rf /var/lib/dkms/dkms_test/ /var/lib/dkms/dkms_multiver_test /usr/src/dkms_test-1.0 /usr/src/dkms_multiver_test-?.0
+remove_module_source_tree /usr/src/dkms_test-1.0 /usr/src/dkms_multiver_test-?.0
+echo ' Removing directories: /var/lib/dkms/dkms_test/ /var/lib/dkms/dkms_multiver_test'
+rm -rf /var/lib/dkms/dkms_test/ /var/lib/dkms/dkms_multiver_test
echo 'Checking that the environment is clean again'
check_no_dkms_test
-echo
-echo 'End of BROKEN tests'
-echo
+fi # broken tests
+
+############################################################################
+
+echo '*** All tests successful :)'
-echo 'All tests successful :)'
+# vim: et:ts=4:sw=4
diff --git a/test/dkms_build_exclusive_test-1.0/dkms.conf b/test/dkms_build_exclusive_test-1.0/dkms.conf
index 5b948c7..94d8214 100644
--- a/test/dkms_build_exclusive_test-1.0/dkms.conf
+++ b/test/dkms_build_exclusive_test-1.0/dkms.conf
@@ -1,5 +1,8 @@
PACKAGE_NAME="dkms_build_exclusive_test"
PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_build_exclusive_test"
DEST_MODULE_LOCATION[0]="/updates/dkms"
+BUILT_MODULE_NAME[1]="dkms_build_exclusive_test2"
+DEST_MODULE_LOCATION[1]="/updates/dkms"
BUILD_EXCLUSIVE_ARCH="none"
AUTOINSTALL="yes"
diff --git a/test/dkms_circular_dependencies_test-1.0/Makefile b/test/dkms_circular_dependencies_test-1.0/Makefile
new file mode 100644
index 0000000..d6d18c7
--- /dev/null
+++ b/test/dkms_circular_dependencies_test-1.0/Makefile
@@ -0,0 +1,7 @@
+obj-m += dkms_circular_dependencies_test.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_circular_dependencies_test-1.0/dkms.conf b/test/dkms_circular_dependencies_test-1.0/dkms.conf
new file mode 100644
index 0000000..bb5ce33
--- /dev/null
+++ b/test/dkms_circular_dependencies_test-1.0/dkms.conf
@@ -0,0 +1,6 @@
+PACKAGE_NAME="dkms_circular_dependencies_test"
+PACKAGE_VERSION="1.0"
+BUILD_DEPENDS="dkms_circular_dependencies_test"
+BUILT_MODULE_NAME[0]="dkms_circular_dependencies_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
diff --git a/test/dkms_circular_dependencies_test-1.0/dkms_circular_dependencies_test.c b/test/dkms_circular_dependencies_test-1.0/dkms_circular_dependencies_test.c
new file mode 100644
index 0000000..93d0098
--- /dev/null
+++ b/test/dkms_circular_dependencies_test-1.0/dkms_circular_dependencies_test.c
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+#define DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_test_init);
+module_exit(dkms_test_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_conf_test_invalid/dkms.conf b/test/dkms_conf_test_invalid/dkms.conf
index 39c43fd..7c3dc88 100644
--- a/test/dkms_conf_test_invalid/dkms.conf
+++ b/test/dkms_conf_test_invalid/dkms.conf
@@ -4,3 +4,4 @@ DEST_MODULE_NAME[0]="bar.ko"
DEST_MODULE_LOCATION="/wrong/path"
BUILT_MODULE_NAME[1]="bar.o"
DEST_MODULE_NAME[1]="foo"
+AUTOINSTALL="maybe"
diff --git a/test/dkms_conf_test_patch_badpath1/badpath.patch b/test/dkms_conf_test_patch_badpath1/badpath.patch
new file mode 100644
index 0000000..e69de29
diff --git a/test/dkms_conf_test_patch_badpath1/dkms.conf b/test/dkms_conf_test_patch_badpath1/dkms.conf
new file mode 100644
index 0000000..f155389
--- /dev/null
+++ b/test/dkms_conf_test_patch_badpath1/dkms.conf
@@ -0,0 +1,6 @@
+PACKAGE_NAME="dkms_conf_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
+PATCH="../badpath.patch"
diff --git a/test/dkms_conf_test_patch_badpath1/patches/dummy.patch b/test/dkms_conf_test_patch_badpath1/patches/dummy.patch
new file mode 100644
index 0000000..e69de29
diff --git a/test/dkms_conf_test_patch_badpath2/dkms.conf b/test/dkms_conf_test_patch_badpath2/dkms.conf
new file mode 100644
index 0000000..389cf8c
--- /dev/null
+++ b/test/dkms_conf_test_patch_badpath2/dkms.conf
@@ -0,0 +1,6 @@
+PACKAGE_NAME="dkms_conf_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
+PATCH="subdir/../badpath.patch"
diff --git a/test/dkms_conf_test_patch_badpath2/patches/badpath.patch b/test/dkms_conf_test_patch_badpath2/patches/badpath.patch
new file mode 100644
index 0000000..e69de29
diff --git a/test/dkms_conf_test_patch_badpath2/patches/subdir/dummy.patch b/test/dkms_conf_test_patch_badpath2/patches/subdir/dummy.patch
new file mode 100644
index 0000000..e69de29
diff --git a/test/dkms_conf_test_patch_missing/dkms.conf b/test/dkms_conf_test_patch_missing/dkms.conf
new file mode 100644
index 0000000..0376c69
--- /dev/null
+++ b/test/dkms_conf_test_patch_missing/dkms.conf
@@ -0,0 +1,6 @@
+PACKAGE_NAME="dkms_conf_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
+PATCH="missing.patch"
diff --git a/test/dkms_conf_test_patch_missing/dummy.c b/test/dkms_conf_test_patch_missing/dummy.c
new file mode 100644
index 0000000..e69de29
diff --git a/test/dkms_conf_test_sparse_arrays/dkms.conf b/test/dkms_conf_test_sparse_arrays/dkms.conf
new file mode 100644
index 0000000..f65f47b
--- /dev/null
+++ b/test/dkms_conf_test_sparse_arrays/dkms.conf
@@ -0,0 +1,7 @@
+PACKAGE_NAME="dkms_conf_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[1]="dkms_sparse_arrays_test_1"
+DEST_MODULE_LOCATION[1]="/kernel/extra"
+BUILT_MODULE_NAME[3]="dkms_sparse_arrays_test_3"
+DEST_MODULE_LOCATION[3]="/kernel/extra"
+DEST_MODULE_LOCATION[4]="/oops"
diff --git a/test/dkms_crlf_test-1.0/Makefile b/test/dkms_crlf_test-1.0/Makefile
new file mode 100644
index 0000000..8968d8f
--- /dev/null
+++ b/test/dkms_crlf_test-1.0/Makefile
@@ -0,0 +1,7 @@
+obj-m += dkms_dos_test.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_crlf_test-1.0/dkms.conf b/test/dkms_crlf_test-1.0/dkms.conf
new file mode 100644
index 0000000..9cfbceb
--- /dev/null
+++ b/test/dkms_crlf_test-1.0/dkms.conf
@@ -0,0 +1,5 @@
+PACKAGE_NAME="dkms_crlf_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_dos_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
diff --git a/test/dkms_crlf_test-1.0/dkms_dos_test.c b/test/dkms_crlf_test-1.0/dkms_dos_test.c
new file mode 100644
index 0000000..1839258
--- /dev/null
+++ b/test/dkms_crlf_test-1.0/dkms_dos_test.c
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+#define DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_crlf_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_crlf_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_crlf_test_init);
+module_exit(dkms_crlf_test_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_dependencies_rebuild_test-1.0/Makefile b/test/dkms_dependencies_rebuild_test-1.0/Makefile
new file mode 100644
index 0000000..25f7708
--- /dev/null
+++ b/test/dkms_dependencies_rebuild_test-1.0/Makefile
@@ -0,0 +1,7 @@
+obj-m += dkms_dependencies_rebuild_test.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_dependencies_rebuild_test-1.0/dkms.conf b/test/dkms_dependencies_rebuild_test-1.0/dkms.conf
new file mode 100644
index 0000000..0982fd8
--- /dev/null
+++ b/test/dkms_dependencies_rebuild_test-1.0/dkms.conf
@@ -0,0 +1,8 @@
+PACKAGE_NAME="dkms_dependencies_rebuild_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_dependencies_rebuild_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
+
+BUILD_DEPENDS="dkms_test"
+BUILD_DEPENDS_REBUILD="yes"
diff --git a/test/dkms_dependencies_rebuild_test-1.0/dkms_dependencies_rebuild_test.c b/test/dkms_dependencies_rebuild_test-1.0/dkms_dependencies_rebuild_test.c
new file mode 100644
index 0000000..88a0d8e
--- /dev/null
+++ b/test/dkms_dependencies_rebuild_test-1.0/dkms_dependencies_rebuild_test.c
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+#define DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module with rebuild dependencies");
+
+static int __init dkms_dependencies_rebuild_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module with rebuild dependencies -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_dependencies_rebuild_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module with rebuild dependencies.\n");
+}
+
+module_init(dkms_dependencies_rebuild_test_init);
+module_exit(dkms_dependencies_rebuild_test_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_dependencies_test-1.0/Makefile b/test/dkms_dependencies_test-1.0/Makefile
index b6c4692..5166fa8 100644
--- a/test/dkms_dependencies_test-1.0/Makefile
+++ b/test/dkms_dependencies_test-1.0/Makefile
@@ -1,3 +1,7 @@
+obj-m += dkms_dependencies_test.o
+
all:
- @echo ERROR: This module should never build.
- @exit 1
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_dependencies_test-1.0/dkms.conf b/test/dkms_dependencies_test-1.0/dkms.conf
index cba44d7..ca28bb5 100644
--- a/test/dkms_dependencies_test-1.0/dkms.conf
+++ b/test/dkms_dependencies_test-1.0/dkms.conf
@@ -1,7 +1,6 @@
PACKAGE_NAME="dkms_dependencies_test"
PACKAGE_VERSION="1.0"
+BUILD_DEPENDS="dkms_test"
BUILT_MODULE_NAME[0]="dkms_dependencies_test"
DEST_MODULE_LOCATION[0]="/kernel/extra"
-BUILD_DEPENDS="dkms_failing_test"
-MAKE="make all"
AUTOINSTALL="yes"
diff --git a/test/dkms_dependencies_test-1.0/dkms_dependencies_test.c b/test/dkms_dependencies_test-1.0/dkms_dependencies_test.c
new file mode 100644
index 0000000..e4b3736
--- /dev/null
+++ b/test/dkms_dependencies_test-1.0/dkms_dependencies_test.c
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+#define DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_dependencies_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_dependencies_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_dependencies_test_init);
+module_exit(dkms_dependencies_test_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_deprecated_test-1.0/Makefile b/test/dkms_deprecated_test-1.0/Makefile
new file mode 100644
index 0000000..74b5768
--- /dev/null
+++ b/test/dkms_deprecated_test-1.0/Makefile
@@ -0,0 +1,7 @@
+obj-m += dkms_deprecated_test.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_deprecated_test-1.0/dkms.conf b/test/dkms_deprecated_test-1.0/dkms.conf
new file mode 100644
index 0000000..0c7c6a2
--- /dev/null
+++ b/test/dkms_deprecated_test-1.0/dkms.conf
@@ -0,0 +1,7 @@
+PACKAGE_NAME="dkms_deprecated_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_deprecated_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
+REMAKE_INITRD="yes"
+CLEAN="true"
diff --git a/test/dkms_deprecated_test-1.0/dkms_deprecated_test.c b/test/dkms_deprecated_test-1.0/dkms_deprecated_test.c
new file mode 100644
index 0000000..93d0098
--- /dev/null
+++ b/test/dkms_deprecated_test-1.0/dkms_deprecated_test.c
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+#define DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_test_init);
+module_exit(dkms_test_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_duplicate_built_test-1.0/Makefile b/test/dkms_duplicate_built_test-1.0/Makefile
new file mode 100644
index 0000000..2b4124e
--- /dev/null
+++ b/test/dkms_duplicate_built_test-1.0/Makefile
@@ -0,0 +1,7 @@
+obj-m += dkms_duplicate_built_test.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_duplicate_built_test-1.0/dkms.conf b/test/dkms_duplicate_built_test-1.0/dkms.conf
new file mode 100644
index 0000000..f9bfe61
--- /dev/null
+++ b/test/dkms_duplicate_built_test-1.0/dkms.conf
@@ -0,0 +1,11 @@
+PACKAGE_NAME="dkms_duplicate_built_test"
+PACKAGE_VERSION="1.0"
+AUTOINSTALL="yes"
+
+BUILT_MODULE_NAME[0]="dkms_duplicate_built_test"
+DEST_MODULE_NAME[0]="dkms_duplicate1_built_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+
+BUILT_MODULE_NAME[1]="dkms_duplicate_built_test"
+DEST_MODULE_NAME[1]="dkms_duplicate2_built_test"
+DEST_MODULE_LOCATION[1]="/kernel/extra"
diff --git a/test/dkms_duplicate_built_test-1.0/dkms_duplicate_built_test.c b/test/dkms_duplicate_built_test-1.0/dkms_duplicate_built_test.c
new file mode 100644
index 0000000..93d0098
--- /dev/null
+++ b/test/dkms_duplicate_built_test-1.0/dkms_duplicate_built_test.c
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+#define DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_test_init);
+module_exit(dkms_test_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_duplicate_dest_test-1.0/Makefile b/test/dkms_duplicate_dest_test-1.0/Makefile
new file mode 100644
index 0000000..624a74f
--- /dev/null
+++ b/test/dkms_duplicate_dest_test-1.0/Makefile
@@ -0,0 +1,8 @@
+obj-m += dkms_duplicate1_dest_test.o
+obj-m += dkms_duplicate2_dest_test.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_duplicate_dest_test-1.0/dkms.conf b/test/dkms_duplicate_dest_test-1.0/dkms.conf
new file mode 100644
index 0000000..1333b70
--- /dev/null
+++ b/test/dkms_duplicate_dest_test-1.0/dkms.conf
@@ -0,0 +1,11 @@
+PACKAGE_NAME="dkms_duplicate_dest_test"
+PACKAGE_VERSION="1.0"
+AUTOINSTALL="yes"
+
+BUILT_MODULE_NAME[0]="dkms_duplicate1_dest_test"
+DEST_MODULE_NAME[0]="dkms_duplicate_dest_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+
+BUILT_MODULE_NAME[1]="dkms_duplicate2_dest_test"
+DEST_MODULE_NAME[1]="dkms_duplicate_dest_test"
+DEST_MODULE_LOCATION[1]="/kernel/extra"
diff --git a/test/dkms_duplicate_dest_test-1.0/dkms_duplicate1_dest_test.c b/test/dkms_duplicate_dest_test-1.0/dkms_duplicate1_dest_test.c
new file mode 100644
index 0000000..a18614e
--- /dev/null
+++ b/test/dkms_duplicate_dest_test-1.0/dkms_duplicate1_dest_test.c
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+#define DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_test1_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_test1_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_test1_init);
+module_exit(dkms_test1_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_duplicate_dest_test-1.0/dkms_duplicate2_dest_test.c b/test/dkms_duplicate_dest_test-1.0/dkms_duplicate2_dest_test.c
new file mode 100644
index 0000000..1f208bf
--- /dev/null
+++ b/test/dkms_duplicate_dest_test-1.0/dkms_duplicate2_dest_test.c
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+#define DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_test2_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_test2_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_test2_init);
+module_exit(dkms_test2_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_duplicate_test/Makefile b/test/dkms_duplicate_test/Makefile
new file mode 100644
index 0000000..67d6fc6
--- /dev/null
+++ b/test/dkms_duplicate_test/Makefile
@@ -0,0 +1,7 @@
+obj-m += dkms_duplicate_test.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_duplicate_test/dkms.conf b/test/dkms_duplicate_test/dkms.conf
new file mode 100644
index 0000000..3ca87f0
--- /dev/null
+++ b/test/dkms_duplicate_test/dkms.conf
@@ -0,0 +1,7 @@
+PACKAGE_NAME="dkms_duplicate_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_duplicate_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+BUILT_MODULE_NAME[1]="dkms_duplicate_test"
+DEST_MODULE_LOCATION[1]="/kernel/extra"
+AUTOINSTALL="yes"
diff --git a/test/dkms_duplicate_test/dkms_duplicate_test.c b/test/dkms_duplicate_test/dkms_duplicate_test.c
new file mode 100644
index 0000000..77acc62
--- /dev/null
+++ b/test/dkms_duplicate_test/dkms_duplicate_test.c
@@ -0,0 +1,20 @@
+#include
+#include
+#include
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module with no version");
+
+static int __init dkms_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module - Loaded\n");
+ return 0;
+}
+
+static void __exit dkms_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_test_init);
+module_exit(dkms_test_cleanup);
diff --git a/test/dkms_failing_dependencies_test-1.0/Makefile b/test/dkms_failing_dependencies_test-1.0/Makefile
new file mode 100644
index 0000000..b6c4692
--- /dev/null
+++ b/test/dkms_failing_dependencies_test-1.0/Makefile
@@ -0,0 +1,3 @@
+all:
+ @echo ERROR: This module should never build.
+ @exit 1
diff --git a/test/dkms_failing_dependencies_test-1.0/dkms.conf b/test/dkms_failing_dependencies_test-1.0/dkms.conf
new file mode 100644
index 0000000..d641d4d
--- /dev/null
+++ b/test/dkms_failing_dependencies_test-1.0/dkms.conf
@@ -0,0 +1,7 @@
+PACKAGE_NAME="dkms_failing_dependencies_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_failing_dependencies_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+BUILD_DEPENDS="dkms_failing_test"
+MAKE="make all"
+AUTOINSTALL="yes"
diff --git a/test/dkms_noisy_test-1.0/Makefile b/test/dkms_noisy_test-1.0/Makefile
new file mode 100644
index 0000000..1a20700
--- /dev/null
+++ b/test/dkms_noisy_test-1.0/Makefile
@@ -0,0 +1,4 @@
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_noisy_test-1.0/dkms.conf b/test/dkms_noisy_test-1.0/dkms.conf
new file mode 100644
index 0000000..52941c2
--- /dev/null
+++ b/test/dkms_noisy_test-1.0/dkms.conf
@@ -0,0 +1,12 @@
+PACKAGE_NAME="dkms_noisy_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_noisy_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
+PATCH=(patch2.patch patch1.patch)
+POST_ADD="script.sh post_add"
+PRE_BUILD="script.sh pre_build"
+POST_BUILD="script.sh post_build"
+PRE_INSTALL="script.sh pre_install"
+POST_INSTALL="script.sh post_install"
+POST_REMOVE="script.sh post_remove"
diff --git a/test/dkms_noisy_test-1.0/dkms_noisy_test.c b/test/dkms_noisy_test-1.0/dkms_noisy_test.c
new file mode 100644
index 0000000..1d6d7d5
--- /dev/null
+++ b/test/dkms_noisy_test-1.0/dkms_noisy_test.c
@@ -0,0 +1,19 @@
+#include
+#include
+#define DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_noisy_test-1.0/patches/patch1.patch b/test/dkms_noisy_test-1.0/patches/patch1.patch
new file mode 100644
index 0000000..4c01fcf
--- /dev/null
+++ b/test/dkms_noisy_test-1.0/patches/patch1.patch
@@ -0,0 +1,19 @@
+diff -ur 1/Makefile 2/Makefile
+--- 1/Makefile 2024-10-27 02:08:27.104704591 +0100
++++ 2/Makefile 2024-10-27 02:06:45.157263482 +0100
+@@ -1,4 +1,5 @@
+ all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
++clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+diff -ur 1/dkms_noisy_test.c 2/dkms_noisy_test.c
+--- 1/dkms_noisy_test.c 2024-10-27 02:08:16.528761716 +0100
++++ 2/dkms_noisy_test.c 2024-10-27 02:07:01.709171430 +0100
+@@ -16,4 +16,6 @@
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+ }
+
++module_init(dkms_test_init);
++module_exit(dkms_test_cleanup);
+ MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_noisy_test-1.0/patches/patch2.patch b/test/dkms_noisy_test-1.0/patches/patch2.patch
new file mode 100644
index 0000000..b38c628
--- /dev/null
+++ b/test/dkms_noisy_test-1.0/patches/patch2.patch
@@ -0,0 +1,20 @@
+diff -ur 2/Makefile 3/Makefile
+--- 2/Makefile 2024-10-27 02:06:45.157263482 +0100
++++ 3/Makefile 2024-10-27 02:05:12.925786989 +0100
+@@ -1,3 +1,5 @@
++obj-m += dkms_noisy_test.o
++
+ all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+diff -ur 2/dkms_noisy_test.c 3/dkms_noisy_test.c
+--- 2/dkms_noisy_test.c 2024-10-27 02:07:01.709171430 +0100
++++ 3/dkms_noisy_test.c 2024-10-27 02:05:12.925786989 +0100
+@@ -1,5 +1,7 @@
+ #include
++#include
+ #include
++
+ #define DKMS_TEST_VER "1.0"
+
+ MODULE_LICENSE("GPL");
diff --git a/test/dkms_noisy_test-1.0/script.sh b/test/dkms_noisy_test-1.0/script.sh
new file mode 100755
index 0000000..c176000
--- /dev/null
+++ b/test/dkms_noisy_test-1.0/script.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+echo "$0" "$@"
+echo "$1: line 1"
+echo "$1: line 2/stderr" >&2
+echo "$1: line 3"
+echo "$1: line 4/stderr" >&2
+echo "$1: line 5"
diff --git a/test/dkms_nover_update_test/1.0/dkms.conf b/test/dkms_nover_update_test/1.0/dkms.conf
index 638f0f6..e3835c8 100644
--- a/test/dkms_nover_update_test/1.0/dkms.conf
+++ b/test/dkms_nover_update_test/1.0/dkms.conf
@@ -4,7 +4,6 @@ PACKAGE_VERSION="1.0"
BUILT_MODULE_NAME="dkms_nover_update_test"
# MAKE="make -C /lib/modules/${kernelver}/build SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules"
-# CLEAN="make -C /lib/modules/${kernelver}/build SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build M=$PWD clean"
AUTOINSTALL="yes"
diff --git a/test/dkms_nover_update_test/2.0/dkms.conf b/test/dkms_nover_update_test/2.0/dkms.conf
index 78429dc..ac5e8eb 100644
--- a/test/dkms_nover_update_test/2.0/dkms.conf
+++ b/test/dkms_nover_update_test/2.0/dkms.conf
@@ -4,7 +4,6 @@ PACKAGE_VERSION="2.0"
BUILT_MODULE_NAME="dkms_nover_update_test"
# MAKE="make -C /lib/modules/${kernelver}/build SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules"
-# CLEAN="make -C /lib/modules/${kernelver}/build SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build M=$PWD clean"
AUTOINSTALL="yes"
diff --git a/test/dkms_nover_update_test/3.0/dkms.conf b/test/dkms_nover_update_test/3.0/dkms.conf
index e82354d..2754d4e 100644
--- a/test/dkms_nover_update_test/3.0/dkms.conf
+++ b/test/dkms_nover_update_test/3.0/dkms.conf
@@ -4,7 +4,6 @@ PACKAGE_VERSION="3.0"
BUILT_MODULE_NAME="dkms_nover_update_test"
# MAKE="make -C /lib/modules/${kernelver}/build SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules"
-# CLEAN="make -C /lib/modules/${kernelver}/build SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build M=$PWD clean"
AUTOINSTALL="yes"
diff --git a/test/dkms_patches_test-1.0/Makefile b/test/dkms_patches_test-1.0/Makefile
new file mode 100644
index 0000000..1a20700
--- /dev/null
+++ b/test/dkms_patches_test-1.0/Makefile
@@ -0,0 +1,4 @@
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_patches_test-1.0/dkms.conf b/test/dkms_patches_test-1.0/dkms.conf
new file mode 100644
index 0000000..0897e0d
--- /dev/null
+++ b/test/dkms_patches_test-1.0/dkms.conf
@@ -0,0 +1,6 @@
+PACKAGE_NAME="dkms_patches_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_patches_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
+PATCH=(patch1.patch subdir/patch2.patch)
diff --git a/test/dkms_patches_test-1.0/dkms_patches_test.c b/test/dkms_patches_test-1.0/dkms_patches_test.c
new file mode 100644
index 0000000..1d6d7d5
--- /dev/null
+++ b/test/dkms_patches_test-1.0/dkms_patches_test.c
@@ -0,0 +1,19 @@
+#include
+#include
+#define DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_patches_test-1.0/patches/patch1.patch b/test/dkms_patches_test-1.0/patches/patch1.patch
new file mode 100644
index 0000000..2c5ed90
--- /dev/null
+++ b/test/dkms_patches_test-1.0/patches/patch1.patch
@@ -0,0 +1,19 @@
+diff -ur 1/Makefile 2/Makefile
+--- 1/Makefile 2024-10-27 02:08:27.104704591 +0100
++++ 2/Makefile 2024-10-27 02:06:45.157263482 +0100
+@@ -1,4 +1,5 @@
+ all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
++clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+diff -ur 1/dkms_patches_test.c 2/dkms_patches_test.c
+--- 1/dkms_patches_test.c 2024-10-27 02:08:16.528761716 +0100
++++ 2/dkms_patches_test.c 2024-10-27 02:07:01.709171430 +0100
+@@ -16,4 +16,6 @@
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+ }
+
++module_init(dkms_test_init);
++module_exit(dkms_test_cleanup);
+ MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_patches_test-1.0/patches/subdir/patch2.patch b/test/dkms_patches_test-1.0/patches/subdir/patch2.patch
new file mode 100644
index 0000000..e9313e1
--- /dev/null
+++ b/test/dkms_patches_test-1.0/patches/subdir/patch2.patch
@@ -0,0 +1,20 @@
+diff -ur 2/Makefile 3/Makefile
+--- 2/Makefile 2024-10-27 02:06:45.157263482 +0100
++++ 3/Makefile 2024-10-27 02:05:12.925786989 +0100
+@@ -1,3 +1,5 @@
++obj-m += dkms_patches_test.o
++
+ all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+diff -ur 2/dkms_patches_test.c 3/dkms_patches_test.c
+--- 2/dkms_patches_test.c 2024-10-27 02:07:01.709171430 +0100
++++ 3/dkms_patches_test.c 2024-10-27 02:05:12.925786989 +0100
+@@ -1,5 +1,7 @@
+ #include
++#include
+ #include
++
+ #define DKMS_TEST_VER "1.0"
+
+ MODULE_LICENSE("GPL");
diff --git a/test/dkms_replace_test-2.0/Makefile b/test/dkms_replace_test-2.0/Makefile
new file mode 100644
index 0000000..c6c2d32
--- /dev/null
+++ b/test/dkms_replace_test-2.0/Makefile
@@ -0,0 +1,7 @@
+obj-m += dkms_test.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_replace_test-2.0/dkms.conf b/test/dkms_replace_test-2.0/dkms.conf
new file mode 100644
index 0000000..7f83a01
--- /dev/null
+++ b/test/dkms_replace_test-2.0/dkms.conf
@@ -0,0 +1,5 @@
+PACKAGE_NAME="dkms_replace_test"
+PACKAGE_VERSION="2.0"
+BUILT_MODULE_NAME[0]="dkms_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
diff --git a/test/dkms_replace_test-2.0/dkms_test.c b/test/dkms_replace_test-2.0/dkms_test.c
new file mode 100644
index 0000000..7026f98
--- /dev/null
+++ b/test/dkms_replace_test-2.0/dkms_test.c
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+#define DKMS_TEST_VER "2.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_test_init);
+module_exit(dkms_test_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_scripts_test-1.0/Makefile b/test/dkms_scripts_test-1.0/Makefile
new file mode 100644
index 0000000..7cd2bc2
--- /dev/null
+++ b/test/dkms_scripts_test-1.0/Makefile
@@ -0,0 +1,7 @@
+obj-m += dkms_scripts_test.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_scripts_test-1.0/dkms.conf b/test/dkms_scripts_test-1.0/dkms.conf
new file mode 100644
index 0000000..5497143
--- /dev/null
+++ b/test/dkms_scripts_test-1.0/dkms.conf
@@ -0,0 +1,11 @@
+PACKAGE_NAME="dkms_scripts_test"
+PACKAGE_VERSION="1.0"
+BUILT_MODULE_NAME[0]="dkms_scripts_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
+POST_ADD="script.sh post_add"
+PRE_BUILD="script.sh pre_build"
+POST_BUILD="script.sh post_build"
+PRE_INSTALL="script.sh pre_install"
+POST_INSTALL="script.sh post_install"
+POST_REMOVE="script.sh post_remove"
diff --git a/test/dkms_scripts_test-1.0/dkms_scripts_test.c b/test/dkms_scripts_test-1.0/dkms_scripts_test.c
new file mode 100644
index 0000000..93d0098
--- /dev/null
+++ b/test/dkms_scripts_test-1.0/dkms_scripts_test.c
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+#define DKMS_TEST_VER "1.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_test_init);
+module_exit(dkms_test_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/dkms_scripts_test-1.0/script.sh b/test/dkms_scripts_test-1.0/script.sh
new file mode 100755
index 0000000..c52d3c2
--- /dev/null
+++ b/test/dkms_scripts_test-1.0/script.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exit 0
diff --git a/test/dkms_test-2.0/Makefile b/test/dkms_test-2.0/Makefile
new file mode 100644
index 0000000..c6c2d32
--- /dev/null
+++ b/test/dkms_test-2.0/Makefile
@@ -0,0 +1,7 @@
+obj-m += dkms_test.o
+
+all:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
diff --git a/test/dkms_test-2.0/dkms.conf b/test/dkms_test-2.0/dkms.conf
new file mode 100644
index 0000000..69a439c
--- /dev/null
+++ b/test/dkms_test-2.0/dkms.conf
@@ -0,0 +1,5 @@
+PACKAGE_NAME="dkms_test"
+PACKAGE_VERSION="2.0"
+BUILT_MODULE_NAME[0]="dkms_test"
+DEST_MODULE_LOCATION[0]="/kernel/extra"
+AUTOINSTALL="yes"
diff --git a/test/dkms_test-2.0/dkms_test.c b/test/dkms_test-2.0/dkms_test.c
new file mode 100644
index 0000000..7026f98
--- /dev/null
+++ b/test/dkms_test-2.0/dkms_test.c
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+#define DKMS_TEST_VER "2.0"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("A Simple dkms test module");
+
+static int __init dkms_test_init(void)
+{
+ printk(KERN_INFO "DKMS Test Module -%s Loaded\n",DKMS_TEST_VER);
+ return 0;
+}
+
+static void __exit dkms_test_cleanup(void)
+{
+ printk(KERN_INFO "Cleaning up after dkms test module.\n");
+}
+
+module_init(dkms_test_init);
+module_exit(dkms_test_cleanup);
+MODULE_VERSION(DKMS_TEST_VER);
diff --git a/test/framework/bad_cert_file_path.conf b/test/framework/bad_cert_file_path.conf
index 34e1094..53fba23 100644
--- a/test/framework/bad_cert_file_path.conf
+++ b/test/framework/bad_cert_file_path.conf
@@ -1,3 +1,3 @@
# The key file will be generated by openssl. Use a temporary path to avoid corrupting the default private key file on the system
-mok_signing_key="/tmp/dkms_test_private_key"
+mok_signing_key="@tmpdir@/dkms_test_private_key"
mok_certificate="/no/such/path.crt"
diff --git a/test/framework/fail_sign_file_path.conf b/test/framework/fail_sign_file_path.conf
new file mode 100644
index 0000000..a1056a4
--- /dev/null
+++ b/test/framework/fail_sign_file_path.conf
@@ -0,0 +1,3 @@
+sign_file="/bin/false"
+mok_signing_key="@tmpdir@/dkms_test_private_key"
+mok_certificate="@tmpdir@/dkms_test_certificate"
diff --git a/test/framework/post_transaction.conf b/test/framework/post_transaction.conf
new file mode 100644
index 0000000..e9a657b
--- /dev/null
+++ b/test/framework/post_transaction.conf
@@ -0,0 +1 @@
+post_transaction="echo This is a test message as post transaction. Kernel version is $kernelver"
diff --git a/test/framework/temp_key_cert.conf b/test/framework/temp_key_cert.conf
index 9bde615..dca29f6 100644
--- a/test/framework/temp_key_cert.conf
+++ b/test/framework/temp_key_cert.conf
@@ -1,2 +1,2 @@
-mok_signing_key="/tmp/dkms_test_private_key"
-mok_certificate="/tmp/dkms_test_certificate"
+mok_signing_key="@tmpdir@/dkms_test_private_key"
+mok_certificate="@tmpdir@/dkms_test_certificate"
diff --git a/test/framework/variables_in_path.conf b/test/framework/variables_in_path.conf
index 87213e6..cb880c4 100644
--- a/test/framework/variables_in_path.conf
+++ b/test/framework/variables_in_path.conf
@@ -1,3 +1,3 @@
sign_file="/lib/modules/${kernelver}/build/scripts/sign-file"
-mok_signing_key="/tmp/dkms_test_dir_${kernelver}/key"
-mok_certificate="/tmp/dkms_test_dir_${kernelver}/cert"
+mok_signing_key="@tmpdir@/dkms_test_dir_${kernelver}/key"
+mok_certificate="@tmpdir@/dkms_test_dir_${kernelver}/cert"