Closed nbartos closed 8 years ago
I don't know of a good place, good dkms docs don't seem to exist. I'm not sure if it helps, but this is the script I use to build DKMS packages, when there is no other build script that comes with it. Note that I've only tested this script on ubuntu.
#!/bin/bash
# Yes, for some stupid reason, this requires root.
#
# Here is an example dkms.conf:
# PACKAGE_NAME=8812au
# PACKAGE_VERSION=4.2.2
#
# DEST_MODULE_LOCATION=/kernel/drivers/net/wireless
# BUILT_MODULE_NAME=8812au
#
# MAKE="'make' all"
# CLEAN="'make' clean"
# AUTOINSTALL="yes"
set -xeuo pipefail
if [ ! -e dkms.conf ]
then
echo -e "\nThis needs to be ran from the module source directory with a dkms.conf." >&2
exit 1
fi
PACKAGE_NAME=$(sed -En 's@^PACKAGE_NAME *= *"* *([^" ]+)"*@\1@gp' dkms.conf)
PACKAGE_VERSION=$(sed -En 's@^PACKAGE_VERSION *= *"* *([^" ]+)"*@\1@gp' dkms.conf)
if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" ]
then
echo -e "\nError getting PACKAGE_NAME and/or PACKAGE_VERSION from dkms.conf" >&2
exit 1
fi
SRC="/usr/src/$PACKAGE_NAME-$PACKAGE_VERSION"
if [ -e "$SRC" ]
then
echo -e "\nWarning: $SRC directory already exists, seeing if it's owned by a package..." >&2
if dpkg -S "$SRC"
then
echo -e "\nError: $SRC exists and is owned by a package. Remove the package first." >&2
exit 1
fi
echo -e "\nNot owned by a package, removing it..."
sudo rm -rf "$SRC"
fi
# Try to only copy source files, otherwise temp files get packaged.
#make clean
#git clean -ffdxi
sudo mkdir -p "$SRC"
sudo chown -Rh nbartos "$SRC"
rsync -aH --exclude=.git --exclude=.gitignore ./ "$SRC/"
if ! sudo dkms add -m "$PACKAGE_NAME" -v "$PACKAGE_VERSION"
then
echo -e "\ndkms add failed, trying to cleanup."
sudo rm -rf "/usr/src/$PACKAGE_NAME-$PACKAGE_VERSION" "/var/lib/dkms/$PACKAGE_NAME"
exit 1
fi
sudo chown -Rh nbartos "/var/lib/dkms/$PACKAGE_NAME"
dkms build -m "$PACKAGE_NAME" -v "$PACKAGE_VERSION"
dkms mkdeb -m "$PACKAGE_NAME" -v "$PACKAGE_VERSION"
cp -f "/var/lib/dkms/$PACKAGE_NAME/$PACKAGE_VERSION/deb/$PACKAGE_NAME-dkms_${PACKAGE_VERSION}_all.deb" ./
sudo rm -rf "/usr/src/$PACKAGE_NAME-$PACKAGE_VERSION" "/var/lib/dkms/$PACKAGE_NAME"
Sorry for the delay, looks sane. Merged. Do you know if there is a good place for DKMS documentation?