The following steps are tested/taken on a Debian Bullseye system. They are assumed to be working with Ubuntu systems also.
For this example the steps are used to build the ice
module (used for Intel E810 NIC's).
Install the required packages first - the dkms
package is required to actually make use of DKMS and the usual build tools will be needed:
apt -y install dkms build-essential debhelper fakeroot
The kernel headers must also be installed:
apt -y install linux-headers-amd64
## OR
apt -y install linux-headers-amd64-`uname -r`
Extract the module source files somewhere; usually /usr/local/src
is a good place for this.
cd /usr/local/src
wget https://downloadmirror.intel.com/738725/ice-1.9.11.tar.gz
tar zxvf ice-1.9.11.tar.gz
In the driver directory a new folder named debian
needs to be created; this will be used to store the changelog/control files:
cd ice-1.9.11
mkdir debian
cd debian
Create a changelog file. The changelog file format should match this template:
cat << EOF > changelog
ice-dkms (1.9.11-0) bullseye; urgency=medium
* Initial package.
-- Me <packages@gbe0.com> Mon, 21 Nov 2022 18:00:00 +0800
EOF
You will need to change the following things for the module you are building:
ice-dkms
: ice
should be changed to the name of the module you will be building.1.9.11-0
: The version of the module should be set.bullseye
: The correct release name should be set.Create the control file using the following template:
cat << \EOF > control
Source: ice-dkms
Maintainer: Me <packages@gbe0.com>
Build-Depends: debhelper (>= 13), dkms
Package: ice-dkms
Architecture: all
Depends: ${misc:Depends}
Description: DKMS source for the Intel E810 network driver
EOF
Again, the template needs to be adjusted with the relevant details for the module you are building.
Create a rules file using the following template:
cat << \EOF > rules
#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
%:
dh $@ --with dkms
override_dh_install:
dh_install src/* usr/local/src/ice-$(DEB_VERSION_UPSTREAM)/
override_dh_dkms:
dh_dkms -V $(DEB_VERSION_UPSTREAM)
override_dh_auto_configure:
override_dh_auto_build:
override_dh_auto_test:
override_dh_auto_install:
override_dh_auto_clean:
EOF
The DKMS configuration file needs to be added using the following template:
cat << \EOF > ice-dkms.dkms
PACKAGE_NAME="ice"
PACKAGE_VERSION="#MODULE_VERSION#"
BUILT_MODULE_NAME[0]="$PACKAGE_NAME"
DEST_MODULE_LOCATION[0]="/updates/dkms"
AUTOINSTALL="YES"
REMAKE_INITRD="YES"
EOF
Finally the compat file can be created with the major release ID for the distro:
echo 11 > compat
Finally the package can be built using dpkg-buildpackage
. This needs to be executed from the parent directory (/usr/local/src/ice-1.9.11
in this case).
cd /usr/local/src/ice-1.9.11
dpkg-buildpackage
You will then be left with the relevant .dpkg
file in /usr/local/src
that can be installed to get the module.