Permalink
Browse files

Allow building for all installed kernels in the common postinst

This adds a configuration option to framework.conf to allow building for
all installed kernels instead of the currrent and latest one. This is
especially usefull for live systems which have several kernels installed
for different hardware configurations (ie. PAE and non-PAE kernels). In
this situation it's desirable to build the DKMS modules for all
installed kernels as you are quite likely to boot into other kernels on
different machines. By default this option is set to off.

This commit is loosely based on a patch found in the Debian bug tracking
system at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=710535

It also reworks some of the kernel selection code in general to contain
less special cases and to not have an own loop for checking the current
kernel. This rework should not contain any functional changes beside
this new configuration setting.
  • Loading branch information...
gaudenz committed Aug 18, 2014
1 parent e1b70fa commit 4591326f9d78db8ccd9dc8266edf0952ff469eb2
Showing with 37 additions and 31 deletions.
  1. +6 −0 dkms.8
  2. +26 −30 dkms_common.postinst
  3. +5 −1 dkms_framework.conf
View
6 dkms.8
@@ -937,6 +937,12 @@ variable controls wheter binary modules are copied to /lib/modules or if only sy
created there. Note that these variables can also
be manipulated on the command line with \-\-dkmstree, \-\-sourcetree, \-\-installtree
and \-\-symlink-modules options.
The
.B $autoinstall_all_kernels
variable is 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.
.SH dkms_autoinstaller
This boot\-time service automatically installs any module which has
.B AUTOINSTALL="yes"
View
@@ -146,6 +146,11 @@ if [ -z "$NAME" ] || [ -z "$VERSION" ]; then
exit 1
fi
# read framework configuration options
if [ -r /etc/dkms/framework.conf ]; then
. /etc/dkms/framework.conf
fi
KERNELS=$(ls /lib/modules/)
CURRENT_KERNEL=$(uname -r)
@@ -189,45 +194,36 @@ fi
#
# NOTE: if the headers are not installed then the
# module won't be built, as usual
if [ -z "$UPGRADE" ]; then
echo "First Installation: checking all kernels..."
for KERNEL in $KERNELS; do
if [ ${KERNEL} = ${CURRENT_KERNEL} ]; then
# Kernel found
KERNELS=$CURRENT_KERNEL
break
fi
done
else
KERNELS=$CURRENT_KERNEL
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.
NEWEST_KERNEL=$(get_newest_kernel "$KERNELS")
# If the current kernel doesn't come from the host of a chroot
if [ `_is_kernel_name_correct $CURRENT_KERNEL` = "yes" ]; then
# See if it's worth building the module for both the newest kernel
# and for the current kernel
if [ -n "$NEWEST_KERNEL" ] && [ ${CURRENT_KERNEL} != ${NEWEST_KERNEL} ]; then
echo "Building for $CURRENT_KERNEL and $NEWEST_KERNEL"
KERNELS="$CURRENT_KERNEL $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 "Building only for $CURRENT_KERNEL"
fi
# The current kernel is not useful as it's the host's
else
echo "It is likely that $CURRENT_KERNEL belongs to a chroot's host"
# Let's use only the newest kernel
if [ -n "$NEWEST_KERNEL" ]; then
KERNELS="$NEWEST_KERNEL"
echo "Building only for $NEWEST_KERNEL"
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
if which lsb_release >/dev/null && [ $(lsb_release -s -i) = "Ubuntu" ]; then
case $ARCH in
@@ -281,7 +277,7 @@ for KERNEL in $KERNELS; do
esac
dkms_status=`dkms status -m $NAME -v $VERSION -k $KERNEL $ARCH`
else
echo "Module build for the currently running kernel was skipped since the"
echo "Module build for kernel $KERNEL was skipped since the"
echo "kernel source for this kernel does not seem to be installed."
fi
fi
View
@@ -21,4 +21,8 @@
## 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.
# symlink_modules=""
# symlink_modules=""
## Automatic installation and upgrade for all installed kernels (if set to a
## non-null value)
# autoinstall_all_kernels=""

0 comments on commit 4591326

Please sign in to comment.