50-dkms 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. set -e
  3. set -u
  4. echo "Building VirtualBox guest modules"
  5. hw_arch="`dpkg --print-architecture`"
  6. if [ "$hw_arch" != i386 -a "$hw_arch" != amd64 ]; then
  7. exit 0
  8. fi
  9. . /usr/share/amnesia/build/variables
  10. # the -dkms package must be installed *after* dkms to be properly registered
  11. apt-get install --yes build-essential dkms
  12. # Note: we only build for the 32-bit kernel, since building for 64-bit is too painful
  13. # with multiarch; and anyway, the 64-bit kernel module doesn't play well with
  14. # a 32-bit userspace (https://www.virtualbox.org/ticket/8336), which is why
  15. # we instruct users to set up a 32-bit VM.
  16. # Installing the headers triggers the building of the modules for that kernel
  17. apt-get install --yes \
  18. "linux-headers-${KERNEL_VERSION}-686" \
  19. virtualbox-guest-dkms
  20. # clean the build directory
  21. rm -r /var/lib/dkms/virtualbox-guest/
  22. # virtualbox-guest-dkms's postrm script deletes any previously
  23. # built binary module; let's delete it before the package gets purged.
  24. rm /var/lib/dpkg/info/virtualbox-guest-dkms.prerm
  25. # Also copy the udev rules installed by virtualbox-guest-dkms to enable guest
  26. # additions by default.
  27. cp -a /lib/udev/rules.d/60-virtualbox-guest-dkms.rules /etc/udev/rules.d/