1
0
mirror of https://github.com/krislamo/kernmod.git synced 2024-09-19 21:30:35 +00:00

Build and install DKMS Debian package

This commit is contained in:
Kris Lamoureux 2022-01-31 23:04:50 -05:00
parent d00996062e
commit e48f1aaf3c
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
7 changed files with 30 additions and 16 deletions

33
build.sh Normal file → Executable file
View File

@ -1,28 +1,29 @@
#!/bin/bash
PACKAGE="helloworld"
VERSION="0.1"
REVISION="1"
BUILDDIR="$(mktemp -d)/${PACKAGE}_$VERSION-$REVISION"
# Install build prerequisites
# Place sources and build package
mkdir -p "$BUILDDIR/usr/src/${PACKAGE}-$VERSION"
mkdir -p "$BUILDDIR/etc"
mkdir -p "$BUILDDIR/DEBIAN"
cp -r /vagrant/src/usr/src/* "$BUILDDIR/usr/src/${PACKAGE}-$VERSION"
cp -r /vagrant/src/etc/* "$BUILDDIR/etc"
cp -r /vagrant/src/DEBIAN/* "$BUILDDIR/DEBIAN"
cd "$BUILDDIR/.."
dpkg-deb --build "${PACKAGE}_$VERSION-$REVISION"
# Install package
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y dkms build-essential linux-headers-$(uname -r)
# Place source and configuration files on the system
cd /vagrant
mkdir /usr/src/helloworld-$VERSION
cp Makefile /usr/src/helloworld-$VERSION/Makefile
cp helloworld.c /usr/src/helloworld-$VERSION/helloworld.c
cp dkms.conf /usr/src/helloworld-$VERSION/dkms.conf
cp helloworld.conf /etc/modules-load.d/helloworld.conf
# Build and install kernel module with DKMS
dkms add -m helloworld -v $VERSION
dkms build -m helloworld -v $VERSION
dkms install -m helloworld -v $VERSION
apt-get install -y linux-headers-$(uname -r)
apt-get install -y "./${PACKAGE}_$VERSION-$REVISION.deb"
# Load module and show details about it
modprobe helloworld
modinfo helloworld
cat /proc/modules | grep helloworld
rmmod helloworld
modprobe helloworld
cat /var/log/messages | grep helloworld

8
src/DEBIAN/control Normal file
View File

@ -0,0 +1,8 @@
Package: helloworld
Version: 0.1-1
Section: base
Priority: optional
Architecture: amd64
Depends: dkms
Maintainer: Kris Lamoureux <kris@lamoureux.io>
Description: hello, world

5
src/DEBIAN/postinst Executable file
View File

@ -0,0 +1,5 @@
VERSION="0.1"
dkms add -m helloworld -v $VERSION
dkms build -m helloworld -v $VERSION
dkms install -m helloworld -v $VERSION
modprobe helloworld