summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2017-03-16 08:00:12 +0000
committerintrigeri <intrigeri@boum.org>2017-03-16 08:00:12 +0000
commit676ae125b00cf3ab4c820ae453ef566106e9a121 (patch)
tree120ae2e9773f3ceb9c2c1866e9eb8bbe682c1cc9
parent80951df7f8aa59d6b2a730c21892dc5f9bfdf749 (diff)
Reintroduce dkms hook, that was removed by mistake in commit:e9d0204.
-rwxr-xr-xconfig/chroot_local-hooks/50-dkms46
1 files changed, 46 insertions, 0 deletions
diff --git a/config/chroot_local-hooks/50-dkms b/config/chroot_local-hooks/50-dkms
new file mode 100755
index 0000000..bbf243f
--- /dev/null
+++ b/config/chroot_local-hooks/50-dkms
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+set -e
+set -u
+
+echo "Building VirtualBox guest modules"
+
+hw_arch="`dpkg --print-architecture`"
+if [ "$hw_arch" != i386 -a "$hw_arch" != amd64 ]; then
+ exit 0
+fi
+
+. /usr/share/amnesia/build/variables
+
+# the -dkms package must be installed *after* dkms to be properly registered
+apt-get install --yes build-essential dkms
+
+# Note: we only build for the 32-bit kernel, since building for 64-bit is too painful
+# with multiarch; and anyway, the 64-bit kernel module doesn't play well with
+# a 32-bit userspace (https://www.virtualbox.org/ticket/8336), which is why
+# we instruct users to set up a 32-bit VM.
+
+# Installing the headers triggers the building of the modules for that kernel
+apt-get install --yes \
+ "linux-headers-${KERNEL_VERSION}-686" \
+ virtualbox-guest-dkms
+
+MODULES_VERSION="$(dpkg-query -W -f='${Version}\n' virtualbox-guest-dkms \
+ | sed -E 's,-.*,,')"
+dkms build \
+ -a i386 -k "${KERNEL_VERSION}-686" \
+ -m virtualbox-guest -v "$MODULES_VERSION"
+dkms install \
+ -a i386 -k "${KERNEL_VERSION}-686" \
+ -m virtualbox-guest -v "$MODULES_VERSION"
+
+# clean the build directory
+rm -r /var/lib/dkms/virtualbox-guest/
+
+# virtualbox-guest-dkms's postrm script deletes any previously
+# built binary module; let's delete it before the package gets purged.
+rm /var/lib/dpkg/info/virtualbox-guest-dkms.prerm
+
+# Also copy the udev rules installed by virtualbox-guest-dkms to enable guest
+# additions by default.
+cp -a /lib/udev/rules.d/60-virtualbox-guest-dkms.rules /etc/udev/rules.d/