Skip to content

Commit a205e55

Browse files
committed
add BUILD_EXCLUSIVE_CONFIG
support build exclusion depending on kernel features being present/absent, e.g. BUILD_EXCLUSIVE_CONFIG="CONFIG_FOO !CONFIG_BAR" Closes dell#219
1 parent 803c28e commit a205e55

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

dkms.8.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,16 @@ This optional directive functions very similarly to
682682
except that it matches against the kernel architecture. For example, if you set
683683
it to ="i.86", your module would not be built for ia32e, x86_64, amd64, s390, etc.
684684
.TP
685+
.B BUILD_EXCLUSIVE_CONFIG=
686+
This optional directive allows you to specify a space separated list of
687+
kernel configuration options ("CONFIG_FOO") that must be enabled in the
688+
targeted kernels ".config" file (either to be compiled in or to be built
689+
as a module) or absent (if prefixed with an exclamation mark, e.g.
690+
"!CONFIG_BAR") in order to build the module.
691+
For example, if you set it as ="CONFIG_PCI !CONFIG_PREEMPT_RT", your module
692+
would only be built for kernels that have PCI enabled, but the RT patchset
693+
disabled.
694+
.TP
685695
.B POST_ADD=
686696
The name of the script to be run after an
687697
.B add

dkms.in

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ shopt -s extglob
2727
# The last group of variables has been deprecated
2828
readonly dkms_conf_variables="CLEAN PACKAGE_NAME
2929
PACKAGE_VERSION POST_ADD POST_BUILD POST_INSTALL POST_REMOVE PRE_BUILD
30-
PRE_INSTALL BUILD_DEPENDS BUILD_EXCLUSIVE_ARCH
30+
PRE_INSTALL BUILD_DEPENDS BUILD_EXCLUSIVE_ARCH BUILD_EXCLUSIVE_CONFIG
3131
BUILD_EXCLUSIVE_KERNEL BUILD_EXCLUSIVE_KERNEL_MIN BUILD_EXCLUSIVE_KERNEL_MAX
3232
build_exclude OBSOLETE_BY MAKE MAKE_MATCH
3333
PATCH PATCH_MATCH patch_array BUILT_MODULE_NAME
@@ -625,6 +625,15 @@ read_conf()
625625
[[ $BUILD_EXCLUSIVE_KERNEL_MIN && "$(VER "$1")" < "$(VER "$BUILD_EXCLUSIVE_KERNEL_MIN")" ]] && build_exclude="yes"
626626
[[ $BUILD_EXCLUSIVE_KERNEL_MAX && "$(VER "$1")" > "$(VER "$BUILD_EXCLUSIVE_KERNEL_MAX")" ]] && build_exclude="yes"
627627
[[ $BUILD_EXCLUSIVE_ARCH && ! $2 =~ $BUILD_EXCLUSIVE_ARCH ]] && build_exclude="yes"
628+
if [[ $BUILD_EXCLUSIVE_CONFIG && -e "${kernel_config}" ]]; then
629+
local kconf
630+
for kconf in $BUILD_EXCLUSIVE_CONFIG ; do
631+
case "$kconf" in
632+
!*) grep -q -E "^${kconf#!}=[ym]" "${kernel_config}" && build_exclude="yes" ;;
633+
*) grep -q -E "^${kconf}=[ym]" "${kernel_config}" || build_exclude="yes" ;;
634+
esac
635+
done
636+
fi
628637

629638
# Fail if absolutely no DEST_MODULE_LOCATION
630639
if ((${#dest_module_location[@]} == 0)); then
@@ -1023,7 +1032,7 @@ prepare_build()
10231032

10241033
# Error out if build_exclude is set
10251034
[[ $build_exclude ]] && die 77 \
1026-
$"The $base_dir/dkms.conf for module $module includes a BUILD_EXCLUSIVE directive which does not match this kernel/arch."\
1035+
$"The $base_dir/dkms.conf for module $module includes a BUILD_EXCLUSIVE directive which does not match this kernel/arch/config."\
10271036
$"This indicates that it should not be built."
10281037

10291038
# Error out if source_tree is basically empty (binary-only dkms tarball w/ --force check)

run_test.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ fi
12471247
echo '(Not) building the build-exclusive test module'
12481248
set_signing_message "dkms_build_exclusive_test" "1.0"
12491249
run_with_expected_error 77 dkms build -k "${KERNEL_VER}" -m dkms_build_exclusive_test -v 1.0 << EOF
1250-
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.
1250+
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.
12511251
This indicates that it should not be built.
12521252
EOF
12531253
run_status_with_expected_output 'dkms_build_exclusive_test' << EOF
@@ -1256,7 +1256,7 @@ EOF
12561256

12571257
echo "Running dkms autoinstall (1 x skip)"
12581258
run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
1259-
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.
1259+
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.
12601260
This indicates that it should not be built.
12611261
dkms autoinstall on ${KERNEL_VER}/${KERNEL_ARCH} was skipped for dkms_build_exclusive_test
12621262
EOF
@@ -1274,7 +1274,7 @@ EOF
12741274

12751275
echo "Running dkms autoinstall (1 x skip, 1 x pass)"
12761276
run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
1277-
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.
1277+
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.
12781278
This indicates that it should not be built.
12791279
12801280
Building module:
@@ -1323,7 +1323,7 @@ EOF
13231323

13241324
echo "Running dkms autoinstall (1 x skip, 1 x fail, 1 x pass) (expected error)"
13251325
run_with_expected_error 11 dkms autoinstall -k "${KERNEL_VER}" << EOF
1326-
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.
1326+
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.
13271327
This indicates that it should not be built.
13281328
13291329
Building module:
@@ -1393,9 +1393,9 @@ fi
13931393

13941394
echo "Running dkms autoinstall (2 x skip, with dependency)"
13951395
run_with_expected_output dkms autoinstall -k "${KERNEL_VER}" << EOF
1396-
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.
1396+
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.
13971397
This indicates that it should not be built.
1398-
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.
1398+
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.
13991399
This indicates that it should not be built.
14001400
dkms autoinstall on ${KERNEL_VER}/${KERNEL_ARCH} was skipped for dkms_build_exclusive_test dkms_build_exclusive_dependencies_test
14011401
EOF

0 commit comments

Comments
 (0)