Skip to content

Commit ccdcaee

Browse files
committed
Add build_environment
1 parent ee8feda commit ccdcaee

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

dkms.8.in

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,27 @@ Run no more than this number of jobs in parallel.
953953
.B compress_gzip_opts, compress_xz_opts, compress_zstd_opts
954954
Control how modules are compressed. By default, the highest available level of compression is used.
955955
.TP
956+
.B build_environment
957+
If the directive is set to any non null-value, the content of the directive will be imported into the DKMS shell with the
958+
.B source
959+
command when building modules.
960+
961+
Can be used to specify a custom
962+
.B gcc
963+
installed in a custom path; and the variable
964+
.B $kernelver
965+
can be used to represent the target kernel version. Some examples:
966+
967+
Define a custom script to point to a specific GCC (
968+
.B CC=/opt/gcc12/bin/gcc
969+
):
970+
.B build_environment="/opt/gcc12/env"
971+
972+
Enable the software collection
973+
.B gcc-toolset-11
974+
and use it for building an UEK kernel on Oracle Linux:
975+
.B build_environment="/opt/rh/gcc-toolset-11/enable"
976+
.TP
956977
.B post_transaction
957978
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
958979
.B dkms autoinstall, dkms install

dkms.in

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ show_deprecation_warnings=0
103103
# All of the variables not related to signing we will accept from framework.conf.
104104
readonly dkms_framework_nonsigning_variables="source_tree dkms_tree install_tree tmp_location
105105
verbose symlink_modules autoinstall_all_kernels modprobe_on_install parallel_jobs
106-
compress_gzip_opts compress_xz_opts compress_zstd_opts
107-
post_transaction"
106+
compress_gzip_opts compress_xz_opts compress_zstd_opts build_environment post_transaction"
108107
# All of the signing related variables we will accept from framework.conf.
109108
readonly dkms_framework_signing_variables="sign_file mok_signing_key mok_certificate"
110109

@@ -1381,6 +1380,12 @@ do_build()
13811380
{
13821381
[[ $kernelver && $arch ]] || die 16 "do_build: Empty \$kernelver or \$arch"
13831382

1383+
# Source build environment file if specified
1384+
if [[ -n "$build_environment" && -f "$build_environment" ]]; then
1385+
# shellcheck disable=SC1090
1386+
source "$build_environment"
1387+
fi
1388+
13841389
# If the module has not been added, try to add it.
13851390
if ! is_module_added "$module" "$module_version" ; then
13861391
add_module
@@ -3302,7 +3307,6 @@ addon_modules_dir="${ADDON_MODULES_DIR}"
33023307
# Source in configuration not related to signing
33033308
read_framework_conf "$dkms_framework_nonsigning_variables"
33043309

3305-
33063310
# Clear out command line argument variables
33073311
module=""
33083312
module_version=""

dkms_framework.conf.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
# compress_xz_opts="--check=crc32 --lzma2=dict=1MiB -6"
5757
# compress_zstd_opts="-q --rm -T0 -3"
5858

59+
# Path to a file containing environment variables to be sourced by DKMS.
60+
# This file will be sourced for the build command.
61+
# build_environment=""
62+
5963
# Command to run at the end of every DKMS transaction, for example after a new
6064
# kernel has been installed on the system and all modules have been successfully
6165
# built and installed.

0 commit comments

Comments
 (0)