Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add BUILD_EXCLUSIVE_CONFIG #269

Merged
merged 16 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Install Alpine dependencies
if: matrix.distro.name == 'alpine'
run: |
apk --no-cache --update add bash gcc linux${{ matrix.distro.variant }} linux${{ matrix.distro.variant }}-dev make openssl
apk --no-cache --update add bash gcc linux${{ matrix.distro.variant }} linux${{ matrix.distro.variant }}-dev make openssl coreutils

- name: Install Arch Linux dependencies
if: matrix.distro.name == 'archlinux'
Expand Down
25 changes: 25 additions & 0 deletions dkms.8.in
Original file line number Diff line number Diff line change
Expand Up @@ -664,12 +664,37 @@ 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
.B BUILD_EXCLUSIVE_KERNEL_MIN=
and
.B BUILD_EXCLUSIVE_KERNEL_MAX=
These optional directives allow one to specify the minimal and maximal kernel
versions supported by the module. If one (or both) of these are defined, the
module will not be built for kernels outside the specified version limits.
For example, if you set
.B BUILD_EXCLUSIVE_KERNEL_MIN
as "=3.5", your module would be built for e.g. "3.5-rc2", "3.6.18" or other
later versions but not for "3.4.999" or earlier kernels.
Similarly, if you set
.B BUILD_EXCLUSIVE_KERNEL_MAX
as ="4.12", your module would be built for e.g. "4.11.999", "3.9-rc5" or
other earlier versions, but not for "4.12-rc1" or later kernels.
.TP
.B BUILD_EXCLUSIVE_ARCH=
This optional directive functions very similarly to
.B BUILD_EXCLUSIVE_KERNEL
except that it matches against the kernel architecture. For example, if you set
it to ="i.86", your module would not be built for ia32e, x86_64, amd64, s390, etc.
.TP
.B BUILD_EXCLUSIVE_CONFIG=
This optional directive allows you to specify a space separated list of
kernel configuration options ("CONFIG_FOO") that must be enabled in the
targeted kernels ".config" file (either to be compiled in or to be built
as a module) or absent (if prefixed with an exclamation mark, e.g.
"!CONFIG_BAR") in order to build the module.
For example, if you set it as ="CONFIG_PCI !CONFIG_PREEMPT_RT", your module
would only be built for kernels that have PCI enabled, but the RT patchset
disabled.
.TP
.B POST_ADD=
The name of the script to be run after an
.B add
Expand Down
42 changes: 30 additions & 12 deletions dkms.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ shopt -s extglob
# The last group of variables has been deprecated
readonly dkms_conf_variables="CLEAN PACKAGE_NAME
PACKAGE_VERSION POST_ADD POST_BUILD POST_INSTALL POST_REMOVE PRE_BUILD
PRE_INSTALL BUILD_DEPENDS BUILD_EXCLUSIVE_KERNEL BUILD_EXCLUSIVE_ARCH
PRE_INSTALL BUILD_DEPENDS BUILD_EXCLUSIVE_ARCH BUILD_EXCLUSIVE_CONFIG
BUILD_EXCLUSIVE_KERNEL BUILD_EXCLUSIVE_KERNEL_MIN BUILD_EXCLUSIVE_KERNEL_MAX
build_exclude OBSOLETE_BY MAKE MAKE_MATCH
PATCH PATCH_MATCH patch_array BUILT_MODULE_NAME
built_module_name BUILT_MODULE_LOCATION built_module_location
Expand Down Expand Up @@ -268,7 +269,7 @@ setup_kernels_arches()
kernelver[$i]=${line%/*}
arch[$i]=${line#*/}
i=$(($i + 1))
done < <(module_status_built "$module" "$module_version")
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)
Expand Down Expand Up @@ -639,7 +640,18 @@ read_conf()

# Set build_exclude
[[ $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"
[[ $BUILD_EXCLUSIVE_ARCH && ! $2 =~ $BUILD_EXCLUSIVE_ARCH ]] && build_exclude="yes"
if [[ $BUILD_EXCLUSIVE_CONFIG && -e "${kernel_config}" ]]; then
local kconf
for kconf in $BUILD_EXCLUSIVE_CONFIG ; do
case "$kconf" in
!*) grep -q "^${kconf#!}=[ym]" "${kernel_config}" && build_exclude="yes" ;;
*) grep -q "^${kconf}=[ym]" "${kernel_config}" || build_exclude="yes" ;;
esac
done
fi

# Set clean
[[ $clean ]] || clean="make clean"
Expand Down Expand Up @@ -672,7 +684,7 @@ get_module_verinfo(){
;;
esac
done < <(modinfo "$1")

echo -E "${ver}"
# Use obsolete checksum info if srcversion is not available
echo -E "${srcver:-$checksum}"
Expand Down Expand Up @@ -719,7 +731,7 @@ check_version_sanity()
local lib_tree="$install_tree/$1" res=
echo $"Running module version sanity check."
local i=0
if [ -n $3 ]; then
if [ -n "$3" ]; then
# Magic split into array syntax saves trivial awk and cut calls.
local -a obs=(${3//-/ })
local -a my=(${1//-/ })
Expand Down Expand Up @@ -767,7 +779,7 @@ check_version_sanity()
return 0
fi
local dkms_module=$(compressed_or_uncompressed "$dkms_tree/$module/$module_version/$1/$2/module/" "${4}")

local cmp_res="$(compare_module_version "${kernels_module}" "${dkms_module}")"
if [[ "${cmp_res}" = ">" ]]; then
if [[ ! "$force" ]]; then
Expand Down Expand Up @@ -1024,7 +1036,7 @@ prepare_build()

# 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."\
$"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)
Expand Down Expand Up @@ -1952,7 +1964,7 @@ load_tarball()
trap "rm -rf $temp_dir_name" EXIT
tar -xaf $archive_location -C $temp_dir_name

if [[ ! $temp_dir_name/dkms_main_tree ]]; then
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)
Expand Down Expand Up @@ -2289,15 +2301,15 @@ autoinstall() {

done

if [[ "${#installed_modules[@]}" > 0 ]]; then
if [[ "${#installed_modules[@]}" -gt 0 ]]; then
echo "dkms autoinstall on $kernelver/$arch succeeded for ${installed_modules[@]}"
fi

if [[ "${#skipped_modules[@]}" > 0 ]]; then
if [[ "${#skipped_modules[@]}" -gt 0 ]]; then
echo "dkms autoinstall on $kernelver/$arch was skipped for ${skipped_modules[@]}"
fi

if [[ "${#failed_modules[@]}" > 0 ]]; then
if [[ "${#failed_modules[@]}" -gt 0 ]]; then
echo "dkms autoinstall on $kernelver/$arch failed for ${failed_modules[@]}"
fi

Expand All @@ -2306,7 +2318,7 @@ autoinstall() {
echo "$m/$v autoinstall failed due to missing dependencies: ${build_depends[$m]}"
done

if [[ "${#failed_modules[@]}" > 0 || "${#to_install[@]}" > 0 ]]; then
if [[ "${#failed_modules[@]}" -gt 0 || "${#to_install[@]}" -gt 0 ]]; then
die 11 $"One or more modules failed to install during autoinstall." \
$"Refer to previous errors for more information."
fi
Expand All @@ -2331,6 +2343,7 @@ unset CC CXX CFLAGS CXXFLAGS LDFLAGS
# Set important variables
current_kernel=$(uname -r)
current_os=$(uname -s)
running_distribution=$(distro_version)
dkms_tree="/var/lib/dkms"
source_tree="/usr/src"
install_tree="/lib/modules"
Expand All @@ -2349,7 +2362,6 @@ rm -f "$tmpfile"
# These can come from the environment or the config file
[[ ! ${ADDON_MODULES_DIR} && -e /etc/sysconfig/module-init-tools ]] && . /etc/sysconfig/module-init-tools
addon_modules_dir="${ADDON_MODULES_DIR}"
[[ ! ${addon_modules_dir} ]] && running_distribution="$(distro_version)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks right, but has a high risk of causing regressions. Let's merge it here and it can be reverted independently if needed.

weak_modules="${WEAK_MODULES_BIN}"

# Source in configuration not related to signing
Expand Down Expand Up @@ -2519,6 +2531,12 @@ 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." \
Expand Down
2 changes: 1 addition & 1 deletion dkms_autoinstaller
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ case "$1" in
# Ignore others on debian/ubuntu too
;;
*)
echo $"Usage: $0 {start}"
echo "Usage: $0 {start}"
exit 2
esac
2 changes: 1 addition & 1 deletion dkms_common.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ if [ -r /etc/dkms/framework.conf ]; then
. /etc/dkms/framework.conf
fi

KERNELS=$(ls /lib/modules/ 2>/dev/null || true)
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
Expand Down
2 changes: 1 addition & 1 deletion dkms_find-provides
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/sh
#!/bin/bash

# heavily based upon find-suggests.ksyms by Andreas Gruenbacher <[email protected]>.
# with modifications by Michael Brown <[email protected]>
Expand Down
6 changes: 3 additions & 3 deletions lsb_release
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# * Changes in 1.2
# - Fixed more bash'isms
# - LSB_VERSION is no longer required in /etc/lsb-release file
#
#
# * Changes in 1.1
# - removed some bash-ism and typos
# Notice: script remains broken with ash because of awk issues
Expand Down Expand Up @@ -101,7 +101,7 @@ DESCSTR_DELI="release"
###############################################################################

# Display Program Version for internal use (needed by help2man)
DisplayProgramVersion() {
DisplayProgramVersion() {
echo "FSG $(basename $0) v$SCRIPTVERSION"
echo
echo "Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc."
Expand Down Expand Up @@ -389,7 +389,7 @@ else
fi
fi

# Update args to All if requested
# Update args to All if requested
if [ -n "$ARG_A" ]
then
[ -z "$ARG_C" ] && ARG_C="y"
Expand Down
Loading