Debian Codegraph @

hw-detect.finish-install.d/08hw-detect

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 set -e
4
5 # This logic to detect virtualization technology is inspired
6 # from systemd-detect-virt (detect_vm() in src/basic/virt.c)
7 detect_virt_dmi_entryscip-shell shell shell-project 0.0.0 detect_virt_dmi_entry().() {
8 local entry=$1
9 if [scip-shell system . . `[`. ! -e "$entry" ]; then
10 return
11 fi
12 case "$(catscip-shell system . . cat. $entry)" in
13 KVM*) echoscip-shell system . . echo. "kvm";;
14 QEMU*) echoscip-shell system . . echo. "qemu";;
15 VMware*) echoscip-shell system . . echo. "vmware";;
16 VMW*) echoscip-shell system . . echo. "vmware";;
17 innotek*) echoscip-shell system . . echo. "oracle";;
18 Xen*) echoscip-shell system . . echo. "xen";;
19 Bochs*) echoscip-shell system . . echo. "bochs";;
20 Parallels*) echoscip-shell system . . echo. "parallels";;
21 BHYVE*) echoscip-shell system . . echo. "bhyve";;
22 esac
23 }
24
25 detect_virt_dmiscip-shell shell shell-project 0.0.0 detect_virt_dmi().() {
26 local path
27 local result
28 for path in scip-shell filesystem . . `/sys/class/dmi/id/sys_vendor`./sys/class/dmi/id/pscip-shell filesystem . . `/sys/class/dmi/id/sys_vendor`.roduct_namescip-shell filesystem . . `/sys/class/dmi/id/product_name`. \
29 /sys/class/dmi/id/sysscip-shell filesystem . . `/sys/class/dmi/id/board_vendor`._vendor \
30 /sys/class/dmi/id/board_venscip-shell filesystem . . `/sys/class/dmi/id/bios_vendor`.dor \
31 /sys/class/dmi/id/bios_vendor; do
32 result=$(detect_virt_dmi_entryscip-shell shell shell-project 0.0.0 detect_virt_dmi_entry(). $path)
33 if [scip-shell system . . `[`. -n "$result" ]; then
34 echoscip-shell system . . echo. "$result"
35 return
36 fi
37 done
38 }
39
40 logscip-shell shell shell-project 0.0.0 log().() {
41 loggerscip-shell system . . logger. -t hw-detect "$@"
42 }
43
44 mount_sys_and_procscip-shell shell shell-project 0.0.0 mount_sys_and_proc().() {
45 local to_umount=""
46 if [scip-shell system . . `[`. ! -e /target/sys/classscip-shell filesystem . . `/target/sys/class`. ]; then
47 mountscip-shell system . . mount. -t sysfs none /target/sysscip-shell filesystem . . `/target/sys`.
48 to_umount="/target/sysscip-shell filesystem . . `/target/sys`."
49 fi
50 if [scip-shell system . . `[`. ! -e /target/proc/sysscip-shell filesystem . . `/target/proc/sys`. ]; then
51 mountscip-shell system . . mount. -t proc none /target/procscip-shell filesystem . . `/target/proc`.
52 to_umount="$to_umount /target/proc"
53 fi
54 echoscip-shell system . . echo. "$to_umount"
55 }
56
57 detect_virtscip-shell shell shell-project 0.0.0 detect_virt().() {
58 # First try to use systemd-detect-virt, it knows a lot more.
59 if [scip-shell system . . `[`. -x /target/usr/bin/systemd-detect-virtscip-shell filesystem . . `/target/usr/bin/systemd-detect-virt`. ]; then
60 to_umount=$(mount_sys_and_procscip-shell shell shell-project 0.0.0 mount_sys_and_proc().)
61 virt=$(chrootscip-shell system . . chroot. /targetscip-shell filesystem . . `/target`. systemd-detect-virt || truescip-shell system . . true.)
62 for path in $to_umount; do
63 umountscip-shell system . . umount. $path || truescip-shell system . . true.
64 done
65 logscip-shell shell shell-project 0.0.0 log(). "detected virtualization '$virt' (with systemd-detect-virt)"
66 fi
67 # Otherwise, rely on DMI information
68 if [scip-shell system . . `[`. -z "$virt" ]; then
69 virt=$(detect_virt_dmiscip-shell shell shell-project 0.0.0 detect_virt_dmi().)
70 logscip-shell shell shell-project 0.0.0 log(). "detected virtualization '$virt' (with DMI data)"
71 fi
72 echoscip-shell system . . echo. -n "$virt"
73 }
74
75 detect_desktopscip-shell shell shell-project 0.0.0 detect_desktop().() {
76 if chrootscip-shell system . . chroot. /targetscip-shell filesystem . . `/target`. dpkg-query -W -f='${db:Status-Status}\n' \
77 libwayland-server0 xserver-xorg-core task-desktop 2>/dev/nullscip-shell filesystem . . `/dev/null`. \
78 | grepscip-shell system . . grep. -q ^installed; then
79 return 0
80 fi
81 return 1
82 }
83
84 disable_modules_loadingscip-shell shell shell-project 0.0.0 disable_modules_loading().() {
85 if [scip-shell system . . `[`. ! -d /target/etc/modprobe.dscip-shell filesystem . . `/target/etc/modprobe.d`. ]; then
86 return
87 fi
88 catscip-shell system . . cat. >/target/etc/modprobe.d/di-hw-detect-blacklist.confscip-shell filesystem . . `/target/etc/modprobe.d/di-hw-detect-blacklist.conf`. <<EOF
89 # Disable loading of all modules during initial installation
90 # (temporary change made by debian-installer $0)
91 alias * all-modules
92 blacklist all-modules
93 EOF
94 }
95
96 enable_modules_loadingscip-shell shell shell-project 0.0.0 enable_modules_loading().() {
97 rmscip-shell system . . rm. -f /target/etc/modprobe.d/di-hw-detect-blacklist.confscip-shell filesystem . . `/target/etc/modprobe.d/di-hw-detect-blacklist.conf`.
98
99 # Now regenerate the initrd without the blacklist that got
100 # embedded and that we don't want
101 in-target update-initramfs -u -k all || truescip-shell system . . true.
102 }
103
104
105 case "$(detect_virtscip-shell shell shell-project 0.0.0 detect_virt().)" in
106 vmware)
107 if detect_desktopscip-shell shell shell-project 0.0.0 detect_desktop().; then
108 apt-install --with-recommends open-vm-tools-desktop || truescip-shell system . . true.
109 else
110 apt-install --with-recommends open-vm-tools || truescip-shell system . . true.
111 fi
112 ;;
113 oracle)
114 # XXX: Virtualbox uses DKMS, which will load modules that
115 # will break d-i's X server, so disable module loading for now
116 # see #931017 for the dkms bug report
117 disable_modules_loadingscip-shell shell shell-project 0.0.0 disable_modules_loading().
118 if detect_desktopscip-shell shell shell-project 0.0.0 detect_desktop().; then
119 apt-install --with-recommends virtualbox-guest-x11 || truescip-shell system . . true.
120 else
121 apt-install --with-recommends virtualbox-guest-utils || truescip-shell system . . true.
122 fi
123 enable_modules_loadingscip-shell shell shell-project 0.0.0 enable_modules_loading().
124 ;;
125 microsoft)
126 apt-install --with-recommends hyperv-daemons || truescip-shell system . . true.
127 ;;
128 kvm|qemu)
129 apt-install --with-recommends qemu-guest-agent || truescip-shell system . . true.
130 if detect_desktopscip-shell shell shell-project 0.0.0 detect_desktop().; then
131 apt-install --with-recommends spice-vdagent || truescip-shell system . . true.
132 fi
133 ;;
134 xen)
135 # XXX: do we need anything for Xen?
136 ;;
137 esac
138
139 # Might have been queued early on, expecting either 0 or 1 by construction:
140 if [scip-shell system . . `[`. -s /tmp/microcode.listscip-shell filesystem . . `/tmp/microcode.list`. ]; then
141 pkg=$(catscip-shell system . . cat. /tmp/microcode.listscip-shell filesystem . . `/tmp/microcode.list`.)
142 logscip-shell shell shell-project 0.0.0 log(). "installing $pkg"
143 apt-install --with-recommends $pkg || truescip-shell system . . true.
144 fi