Skip to content
Open
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
31 changes: 21 additions & 10 deletions dkms_common.postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ARCH=$4
UPGRADE=$5

if [ -z "$NAME" ] || [ -z "$VERSION" ]; then
echo "Need NAME, and VERSION defined"
echo "Need NAME and VERSION defined"
echo "ARCH is optional"
exit 1
fi
Expand All @@ -115,6 +115,8 @@ if [ -f /etc/dkms/no-autoinstall ]; then
exit 0
fi

continue_on_error="true"

# read framework configuration options
for fwcf in /etc/dkms/framework.conf /etc/dkms/framework.conf.d/*.conf ; do
if [ -f "$fwcf" ] && [ -r "$fwcf" ]; then
Expand All @@ -128,13 +130,13 @@ done
KERNELS=$(ls -dv "$MODDIR"/*/build 2>/dev/null | sed 's|'"$MODDIR"'/\(.*\)/build|\1|' || true)
CURRENT_KERNEL=$(uname -r)

#We never want to keep an older version side by side to prevent conflicts
# We never want to keep an older version side by side to prevent conflicts
if [ -e "/var/lib/dkms/$NAME/$VERSION" ]; then
echo "Removing old $NAME/$VERSION DKMS files..."
dkms remove -m "$NAME" -v "$VERSION" --all
fi

#Load new files, by source package and by tarball
# Load new files, by source package and by tarball
if [ -f "$TARBALL_ROOT/$NAME-$VERSION.dkms.tar.gz" ]; then
if ! dkms ldtarball --archive "$TARBALL_ROOT/$NAME-$VERSION.dkms.tar.gz"; then
echo ""
Expand Down Expand Up @@ -216,16 +218,18 @@ if [ -n "$ARCH" ]; then
echo "Building for architecture $ARCH"
fi

exit_code=0
failed_kernels=""
for KERNEL in $KERNELS; do
echo ""
dkms_status=$(dkms status -m "$NAME" -v "$VERSION" -k "$KERNEL" ${ARCH:+-a "$ARCH"})
if [ "$(echo "$KERNEL" | grep -c "BOOT")" -gt 0 ]; then
echo "Module build and install for $KERNEL was skipped as "
echo "it is a BOOT variant"
continue
fi

#if the module isn't yet built, try to build it
# if the module isn't yet built, try to build it
dkms_status=$(dkms status -m "$NAME" -v "$VERSION" -k "$KERNEL" ${ARCH:+-a "$ARCH"})
if [ "$(echo "$dkms_status" | grep -c ": built")" -eq 0 ]; then
if [ ! -L "/var/lib/dkms/$NAME/$VERSION/source" ]; then
echo "This package appears to be a binaries-only package"
Expand All @@ -245,21 +249,28 @@ for KERNEL in $KERNELS; do
0)
;;
*)
exit $res
exit_code=$res
[ "$continue_on_error" != "true" ] && break
failed_kernels+=" $KERNEL"
continue
;;
esac
dkms_status=$(dkms status -m "$NAME" -v "$VERSION" -k "$KERNEL" ${ARCH:+-a "$ARCH"})
else
echo "Module build for kernel $KERNEL was skipped since the"
echo "kernel headers for this kernel do not seem to be installed."
continue
fi
dkms_status=$(dkms status -m "$NAME" -v "$VERSION" -k "$KERNEL" ${ARCH:+-a "$ARCH"})
fi

#if the module is built (either pre-built or just now), install it
if [ "$(echo "$dkms_status" | grep -c ": built")" -eq 1 ] &&
[ "$(echo "$dkms_status" | grep -c ": installed")" -eq 0 ]; then
# if the module is built (either pre-built or just now), install it
if [ "$(echo "$dkms_status" | grep -c ": built")" -ne 0 ]; then
dkms install -m "$NAME" -v "$VERSION" -k "$KERNEL" ${ARCH:+-a "$ARCH"}
fi
done

[ -n "$failed_kernels" ] && echo "Builds for the following kernel(s) failed:$failed_kernels"

exit $exit_code

# vim: et:ts=4:sw=4
4 changes: 4 additions & 0 deletions dkms_framework.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@
# The command listed is executed if set to any non null value. $kernelver can be
# used in path to represent the target kernel version.
# post_transaction=""

# In common.postinst, if en error is encountered while building a module for
# a kernel, continue on to the next kernel if true, otherwise stop.
# continue_on_error="true"
Loading