50-dkms 1.78 KB
Newer Older
1
2
3
#!/bin/sh

set -e
4
set -u
intrigeri's avatar
intrigeri committed
5
set -x
6

7
echo "Building VirtualBox guest modules"
8

9
. /usr/share/tails/build/variables
10

11
# Import ensure_hook_dependency_is_installed()
12
# and install_fake_package()
13
14
. /usr/local/lib/tails-shell-library/build.sh

intrigeri's avatar
intrigeri committed
15
# Any -dkms package must be installed *after* dkms to be properly registered
16
ensure_hook_dependency_is_installed dkms
17

anonym's avatar
anonym committed
18
ensure_hook_dependency_is_installed \
19
   virtualbox-guest-dkms
20

21
for log in /var/lib/dkms/*/*/build/make.log; do
22
   [ -e "$log" ] || break  # handle the case when no file matched the glob
23
24
25
26
   echo "---- $log"
   cat "$log"
done

27
28
29
30
# Ensure the modules were actually built and installed: when
# dkms.conf for a DKMS module includes a BUILD_EXCLUSIVE directive
# which does not match our kernel version, the modules won't be built
# and then we should abort the build.
31
for module in vboxguest vboxsf vboxvideo ; do
32
33
34
   for modules_dir in /lib/modules/* ; do
      found=$(find "$modules_dir" -name "${module}.ko" | wc -l)
      if [ "$found" = 0 ]; then
35
36
37
38
39
40
	  echo "Can not find ${module} module in '${modules_dir}" >&2
	  exit 1
      fi
   done
done

41
42
43
# 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
44
45
46
47
48
49
50
51

# Install a fake package so that the real virtualbox-guest-dkms can be purged
# when the clean-up for this hook happens, even if virtualbox-guest-utils
# depends on it. The 4th parameter needs to embed the real package version
# since there's a dependency on the source version between packages.
REAL_PKG_VERSION=$(dpkg-query -W -f='${Version}\n' virtualbox-guest-dkms)
FAKE_PKG_VERSION=${REAL_PKG_VERSION}+tails.fake1
install_fake_package virtualbox-guest-dkms-dummy "${FAKE_PKG_VERSION}" kernel "virtualbox-guest-dkms (= ${REAL_PKG_VERSION})"