Skip to content

Commit

Permalink
dkms: remove support for 2.x era kernels
Browse files Browse the repository at this point in the history
Drop the various VER 2.6 checks and essentially dead
no-{clean,prepare}-kernel switches.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
  • Loading branch information
evelikov committed Oct 9, 2021
1 parent 64eb0a3 commit a6b6302
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 165 deletions.
160 changes: 6 additions & 154 deletions dkms
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ show_usage()
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 $" [--kernelsourcedir=source-location] [--no-prepare-kernel] [--no-initrd]"
echo $" [--kernelsourcedir=source-location] [--no-initrd]"
echo $" [--binaries-only] [--source-only] [--verbose]"
echo $" [--no-depmod] [--modprobe-on-install] [-j number] [--version]"
}
Expand Down Expand Up @@ -206,7 +206,6 @@ set_module_suffix()
# $1 = the kernel to base the module_suffix on
kernel_test="${1:-$(uname -r)}"
module_uncompressed_suffix=".ko"
[[ $(VER $kernel_test) < $(VER 2.5) ]] && module_uncompressed_suffix=".o"
grep -q '\.gz:' /lib/modules/$kernel_test/modules.dep 2>/dev/null && module_compressed_suffix=".gz"
grep -q '\.xz:' /lib/modules/$kernel_test/modules.dep 2>/dev/null && module_compressed_suffix=".xz"
grep -q '\.zst:' /lib/modules/$kernel_test/modules.dep 2>/dev/null && module_compressed_suffix=".zst"
Expand Down Expand Up @@ -632,13 +631,8 @@ read_conf()
done

# Use the generic make and make clean commands if not specified
if [[ $(VER $1) < $(VER 2.6.6) ]]; then
[[ ! $make_command ]] && make_command="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build modules"
[[ ! $clean ]] && clean="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build clean"
else
[[ ! $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"
fi
[[ ! $make_command ]] && make_command="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build modules"
[[ ! $clean ]] && clean="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build clean"

# Set modules_conf_array
for ((index=0; index < ${#MODULES_CONF[@]}; index++)); do
Expand Down Expand Up @@ -1084,122 +1078,7 @@ prepare_kernel()
$"Please install the linux-headers-$1 package or use the --kernelsourcedir option to tell DKMS where it's located."
}

[[ $no_prepare_kernel ]] && return

if [[ (! ( $(VER $1) < $(VER 2.6.5) ) || -d /etc/SuSEconfig) && \
-d "$kernel_source_dir" && \
-z "$ksourcedir_fromcli" ]]; then
echo $""
echo $"Kernel preparation unnecessary for this kernel. Skipping..."
no_clean_kernel="no-clean-kernel"
return 1
fi

# Prepare kernel for module build
echo $""
echo $"Preparing kernel $1 for module build:"
echo $"(This is not compiling a kernel, just preparing kernel symbols)"
cd $kernel_source_dir
[[ -r .config ]] && {
config_contents=$(cat .config)
echo $"Storing current .config to be restored when complete"
}

# Set kernel_config
if [[ -e /etc/redhat-release || -e /etc/fedora-release ]]; then
# Note this also applies to VMware 3.x
if [[ -z $kernel_config && -d $kernel_source_dir/configs ]]; then
local kernel_trunc=${1%%-*}
# Try a .config specific to whatever kernel we are running
if [[ $1 =~ $rh_kernels && -e $kernel_source_dir/configs/kernel-$kernel_trunc-$2-${BASH_REMATCH[1]}.config ]]; then
kernel_config="$kernel_source_dir/configs/kernel-$kernel_trunc-$2-${BASH_REMATCH[1]}.config"
elif [[ -e $kernel_source_dir/configs/kernel-$kernel_trunc-$2.config ]]; then
# If that one does not exist, try a generic one.
kernel_config="$kernel_source_dir/configs/kernel-$kernel_trunc-$2.config"
else
# If that does not exist, fall back to no config file
kernel_config=""
fi
fi
elif [[ (-e /etc/SuSE-release || -d /etc/SuSEconfig) && -z $kernel_config && -d $kernel_source_dir/arch ]]; then
local kernel_trunc=${1%%-*}
case $2 in
i586|i686)
config_arch="i386"
;;
*)
config_arch=$2
;;
esac
for config_type in default smp bigsmp; do
[[ $1 =~ $config_type ]] && kernel_config="$kernel_source_dir/arch/$config_arch/defconfig.$config_type"
[[ -e $kernel_config ]] || kernel_config=""
done
[[ $kernel_config ]] || kernel_config="$kernel_source_dir/arch/$config_arch/defconfig.default"
[[ -e $kernel_config ]] || kernel_config=""
fi

# Do preparation
if [ -e /boot/vmlinuz.version.h ]; then
echo $"Running UnitedLinux preparation routine"
local kernel_config="/boot/vmlinuz.config"
invoke_command "make mrproper" "make mrproper" background
[[ $config_contents ]] && echo "$config_contents" > .config
invoke_command "cp /boot/vmlinuz.version.h include/linux/version.h" "using /boot/vmlinux.version.h"
invoke_command "cp -f $kernel_config .config" "using $kernel_config"
invoke_command "make KERNELRELEASE=$1 cloneconfig" "make cloneconfig" background
invoke_command "make -j$parallel_jobs CONFIG_MODVERSIONS=1 KERNELRELEASE=$1 dep" "make CONFIG_MODVERSIONS=1 dep" background
elif grep -q rhconfig.h $kernel_source_dir/include/linux/{modversions,version}.h 2>/dev/null; then
echo $"Running Red Hat style preparation routine"
invoke_command "make clean" "make clean" background
[[ $config_contents ]] && echo "$config_contents" > .config

if [[ $kernel_config ]]; then
echo $"using $kernel_config"
cp -f "$kernel_config" .config
elif [[ -e .config ]]; then
warn $"Using $kernel_source_dir/.config" \
$"(I hope this is the correct config for this kernel)"
else
warn $"Cannot find a .config file to prepare your kernel with." \
$"Try using the --config option to specify where one can be found." \
$"Your build will likely fail because of this."
fi

# Hack to workaround broken tmp_include_depends for Red Hat
if grep -q "/usr/src/build" $kernel_source_dir/tmp_include_depends 2>/dev/null; then
sed 's/\/usr\/src\/build\/.*\/install//g' $kernel_source_dir/tmp_include_depends > $kernel_source_dir/tmp_include_depends.new
mv -f $kernel_source_dir/tmp_include_depends.new $kernel_source_dir/tmp_include_depends
fi

invoke_command "make KERNELRELEASE=$1 oldconfig" "make oldconfig" background
kerneldoth_contents=$(cat /boot/kernel.h 2>/dev/null)
invoke_command "/usr/lib/dkms/mkkerneldoth --kernelver $1 --targetarch $2 --output /boot/kernel.h" "running mkkerneldoth" background
else
echo $"Running Generic preparation routine"
invoke_command "make mrproper" "make mrproper" background
[[ $config_contents ]] && echo "$config_contents" > .config

if [[ $kernel_config ]]; then
echo $"using $kernel_config"
cp -f "$kernel_config" .config
elif [[ -e .config ]]; then
warn $"using $kernel_source_dir/.config" \
$"(I hope this is the correct config for this kernel)"
else
warn $"Warning! Cannot find a .config file to prepare your kernel with." \
$"Try using the --config option to specify where one can be found." \
$"Your build will likely fail because of this."
fi

invoke_command "make KERNELRELEASE=$1 oldconfig" "make oldconfig" background
if [[ $(VER $1) < $(VER 2.5) ]]; then
invoke_command "make -j$parallel_jobs KERNELRELEASE=$1 dep" "make dep" background
else
invoke_command "make -j$parallel_jobs KERNELRELEASE=$1 prepare-all scripts" "make prepare-all" background
fi
fi
cd - >/dev/null
echo $"Kernel preparation unnecessary for this kernel. Skipping..."
}

# Get ready to build a module that has been registered with DKMS.
Expand Down Expand Up @@ -1323,18 +1202,7 @@ clean_build()
invoke_command "$clean" "cleaning build area" background
cd - >/dev/null

if [[ ! ( $(VER $kernelver) < $(VER 2.6.6) ) && \
-d $kernel_source_dir && \
! -h $kernel_source_dir && \
! $ksourcedir_fromcli ]]; then
echo $"Kernel cleanup unnecessary for this kernel. Skipping..."
elif [[ ! $no_clean_kernel ]]; then
cd "$kernel_source_dir"
[[ $kerneldoth_contents ]] || invoke_command "make mrproper" "cleaning kernel tree (make mrproper)" background
[[ $config_contents ]] || echo "$config_contents" > .config
[[ $kerneldoth_contents ]] && echo "$kerneldoth_contents" > /boot/kernel.h
cd - >/dev/null
fi
echo $"Kernel cleanup unnecessary for this kernel. Skipping..."

# Clean the build directory
rm -rf "$dkms_tree/$module/$module_version/build"
Expand Down Expand Up @@ -2368,15 +2236,7 @@ run_match()
done < <(echo "$template_kernel_status")

# Clean up the kernel tree
if [[ ! ( $(VER $kernelver) < $(VER 2.6.6) ) && -d "$kernel_source_dir" && ! -h "$kernel_source_dir" && -z "$ksourcedir_fromcli" ]]; then
echo $"Kernel cleanup unnecessary for this kernel. Skipping..."
elif [[ ! $no_clean_kernel ]]; then
cd "$kernel_source_dir"
[[ $kerneldoth_contents ]] || invoke_command "make mrproper" "cleaning kernel tree (make mrproper)" background
[[ $config_contents ]] && echo "$config_contents" > .config
[[ $kerneldoth_contents ]] && echo "$kerneldoth_contents" > /boot/kernel.h
cd - >/dev/null
fi
echo $"Kernel cleanup unnecessary for this kernel. Skipping..."
fi
}

Expand Down Expand Up @@ -2643,8 +2503,6 @@ ksourcedir_fromcli=""
action=""
force=""
force_version_override=""
no_prepare_kernel=""
no_clean_kernel=""
binaries_only=""
source_only=""
all=""
Expand Down Expand Up @@ -2697,12 +2555,6 @@ while (($# > 0)); do
echo $"#RELEASE_STRING#"
exit 0
;;
--no-prepare-kernel)
no_prepare_kernel="no-prepare-kernel"
;;
--no-clean-kernel)
no_clean_kernel="no-clean-kernel"
;;
--no-initrd)
no_initrd="no-initrd"
;;
Expand Down
9 changes: 0 additions & 9 deletions dkms.8
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,6 @@ for a module/module-version. This is useful for things like
, etc. This saves the trouble of having to actually specify \-k kernel1 \-a
arch1 \-k kernel2 \-a arch2 for every kernel you have built your module for.
.TP
.B \-\-no\-prepare\-kernel
This option keeps DKMS from first preparing your kernel before building
a module for it. Generally, this option should not be used so as to
ensure that modules are compiled correctly.
.TP
.B \-\-no\-clean\-kernel
This option keeps DKMS from cleaning your kernel source tree after a
build.
.TP
.B \-\-no\-depmod
This option prevents DKMS from running the depmod command during
.B install
Expand Down
3 changes: 1 addition & 2 deletions dkms.bash-completion
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ _dkms()
esac

options="$options -m -v -k -a --arch -q --quiet -V \
--version --all --no-prepare-kernel \
--no-clean-kernel --kernelsourcedir \
--version --all --kernelsourcedir \
--directive"

COMPREPLY=( $( compgen -W "$options" -- $cur ) )
Expand Down

0 comments on commit a6b6302

Please sign in to comment.