diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 index c2ebe8e..e8089b0 --- a/build.sh +++ b/build.sh @@ -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 diff --git a/src/DEBIAN/control b/src/DEBIAN/control new file mode 100644 index 0000000..1fc5dab --- /dev/null +++ b/src/DEBIAN/control @@ -0,0 +1,8 @@ +Package: helloworld +Version: 0.1-1 +Section: base +Priority: optional +Architecture: amd64 +Depends: dkms +Maintainer: Kris Lamoureux +Description: hello, world diff --git a/src/DEBIAN/postinst b/src/DEBIAN/postinst new file mode 100755 index 0000000..c578ae0 --- /dev/null +++ b/src/DEBIAN/postinst @@ -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 diff --git a/helloworld.conf b/src/etc/modules-load.d/helloworld.conf similarity index 100% rename from helloworld.conf rename to src/etc/modules-load.d/helloworld.conf diff --git a/Makefile b/src/usr/src/Makefile similarity index 100% rename from Makefile rename to src/usr/src/Makefile diff --git a/dkms.conf b/src/usr/src/dkms.conf similarity index 100% rename from dkms.conf rename to src/usr/src/dkms.conf diff --git a/helloworld.c b/src/usr/src/helloworld.c similarity index 100% rename from helloworld.c rename to src/usr/src/helloworld.c