Repository navigation
Expand file tree
/
Copy pathinstall-deps.sh
More file actions
executable file
·192 lines (187 loc) · 7.84 KB
/
Copy pathinstall-deps.sh
File metadata and controls
executable file
·192 lines (187 loc) · 7.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/bin/env bash
# Copyright 2026, Mehrab Kooner
# SPDX-License-Identifier: BSL-1.0
#
# Install the packages build-driver.sh needs, with the distribution's package manager (Arch based: pacman, Debian
# based: apt, Fedora based: dnf). DriverKit's "Install dependencies" button runs it (through pkexec, which asks for
# your password).
#
# ./install-deps.sh [--no-hand-tracking] [--list] [--dry-run]
#
# With what hand tracking needs, OpenCV and onnxruntime (Monado's Mercury hand tracker and the MediaPipe hand models,
# which come with the repository). A distribution without onnxruntime gets the rest, and a driver without hand tracking.
#
# --no-hand-tracking without them (--hand-tracking, the default, is accepted too)
# --list print the distribution found and the command, install nothing
# --dry-run the same, after checking which packages are missing (no root needed)
#
# It also installs the udev rules that let you (not only root) open the headset and the Sense controllers: our copy
# of Monado's xr-hardware rules (udev/70-xrhardware.rules) as /etc/udev/rules.d/70-xrhardware.rules, then reloads
# and triggers udev, as xr-hardware's own install line does but from this repository instead of a download. Skipped
# when that file is already the same as ours.
#
# Needs root to install: asks through sudo when run from a terminal.
set -euo pipefail
HT=1
LIST=0
DRY=0
UPDATED=0
for a in "$@"; do
case "$a" in
--hand-tracking) HT=1 ;;
--no-hand-tracking) HT=0 ;;
--list) LIST=1 ;;
--dry-run) DRY=1 ;;
-h | --help) sed -n '4,20p' "$0"; exit 0 ;;
*) echo "unknown option $a"; exit 2 ;;
esac
done
# udev rules: without them only root can open the headset's USB device and the Sense controllers' HID devices, and
# Monado (running as you) finds no controllers and logs nothing about it (a user's 2026-11-23 PC: the controllers
# connected over Bluetooth, no hidraw node was usable, left/right "<none>").
RULES_FILE=/etc/udev/rules.d/70-xrhardware.rules
# Our copy of Monado's xr-hardware rules (udev/70-xrhardware.rules in the repository, next to this script; DriverKit
# writes it beside its copy of this script). Taken unchanged from
# https://gitlab.freedesktop.org/monado/utilities/xr-hardware (commit 143de7a5, 2026-08-09, BSL-1.0): TAG+="uaccess"
# for XR devices, the PS VR2 and both Sense controllers among them; nothing is run.
RULES_SRC="$(cd "$(dirname "$0")" && pwd)/udev/70-xrhardware.rules"
RULES_NEEDED=1
RULES_HAVE=""
if [ -r "$RULES_FILE" ] && [ -r "$RULES_SRC" ] && cmp -s "$RULES_SRC" "$RULES_FILE"; then
RULES_NEEDED=0
RULES_HAVE="$RULES_FILE, the same as ours"
fi
install_udev_rules() {
if [ ! -r "$RULES_SRC" ]; then
echo "ERROR: the udev rules aren't next to this script ($RULES_SRC): get the whole PSVR2-DriverKit folder"
return 1
fi
mkdir -p /etc/udev/rules.d
install -m 644 "$RULES_SRC" "$RULES_FILE"
if command -v udevadm >/dev/null; then
udevadm control --reload-rules
udevadm trigger
fi
echo " udev rules installed: $RULES_FILE (reconnect the controllers, or turn them off and on, if they were on)"
}
NAME="your system"
if [ -r /etc/os-release ]; then
# shellcheck disable=SC1091
NAME="$(. /etc/os-release && echo "${PRETTY_NAME:-${NAME:-your system}}")"
fi
# The compilers, CMake/Ninja, the Monado build's libraries and Rust (DriverKit).
ARCH_BASE=(base-devel git cmake ninja python pkgconf eigen vulkan-headers vulkan-icd-loader glslang shaderc libusb
systemd-libs libjpeg-turbo ceres-solver suitesparse google-glog gflags jsoncpp libx11 libxcb libxrandr wayland
wayland-protocols libdrm zlib patchelf libcap rust)
DEB_BASE=(build-essential git cmake ninja-build python3 pkg-config libeigen3-dev libvulkan-dev glslang-tools glslc
libusb-1.0-0-dev libudev-dev libjpeg-dev libceres-dev libsuitesparse-dev libgoogle-glog-dev libgflags-dev
libjsoncpp-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxrandr-dev libwayland-dev wayland-protocols libdrm-dev
zlib1g-dev patchelf libcap2-bin cargo)
FED_BASE=(gcc-c++ git cmake ninja-build python3 pkgconf-pkg-config eigen3-devel vulkan-loader-devel vulkan-headers
glslang glslc libusb1-devel systemd-devel libjpeg-turbo-devel ceres-solver-devel suitesparse-devel glog-devel
gflags-devel jsoncpp-devel libX11-devel libxcb-devel libXrandr-devel wayland-devel wayland-protocols-devel
libdrm-devel zlib-devel patchelf libcap cargo openblas-openmp)
# Hand tracking. onnxruntime's development files: Arch extra, Debian 13 / Ubuntu 25.04 and newer, Fedora 43 and newer.
# OpenCV comes as one package with its CMake files on each (opencv / libopencv-dev / opencv-devel); the driver links
# only core, imgproc, imgcodecs, video and calib/features (build-driver.sh: XRT_OPENCV_HIGHGUI=OFF), not its GUI and
# video I/O libraries.
# curl: build-driver.sh downloads Mercury's models with it.
ARCH_HT=(opencv onnxruntime-cpu curl)
DEB_HT=(libopencv-dev libonnxruntime-dev curl)
FED_HT=(opencv-devel onnxruntime-devel curl)
if command -v pacman >/dev/null; then
FAMILY="Arch based"
PKGS=("${ARCH_BASE[@]}")
[ "$HT" = 1 ] && PKGS+=("${ARCH_HT[@]}")
# Only what isn't there yet, by what installed packages provide: rustup already gives cargo, onnxruntime-cuda or
# -rocm already give onnxruntime (installing rust or onnxruntime-cpu next to them would conflict).
MISSING=()
for p in "${PKGS[@]}"; do
want="$p"
[ "$p" = onnxruntime-cpu ] && want=onnxruntime
[ "$p" = rust ] && want=cargo
pacman -T "$want" >/dev/null 2>&1 || MISSING+=("$p")
done
CMD=(pacman -S --needed --noconfirm "${MISSING[@]}")
elif command -v apt-get >/dev/null; then
FAMILY="Debian based"
PKGS=("${DEB_BASE[@]}")
if [ "$HT" = 1 ]; then
# A system that hasn't fetched its package lists yet knows no libonnxruntime-dev: fetch them before asking.
if [ "$(id -u)" = 0 ] && [ "$LIST$DRY" = 00 ]; then
echo " apt-get update"
apt-get update
UPDATED=1
fi
if ! apt-cache show libonnxruntime-dev >/dev/null 2>&1; then
echo "NOTE: $NAME has no libonnxruntime-dev package: hand tracking needs Debian 13, Ubuntu 25.04 or newer."
echo " Installing what the driver needs without it."
HT=0
else
PKGS+=("${DEB_HT[@]}")
fi
fi
MISSING=("${PKGS[@]}")
CMD=(apt-get install -y "${PKGS[@]}")
elif command -v dnf >/dev/null; then
FAMILY="Fedora based"
PKGS=("${FED_BASE[@]}")
if [ "$HT" = 1 ]; then
if ! dnf -q info onnxruntime-devel >/dev/null 2>&1; then
echo "NOTE: $NAME has no onnxruntime-devel package: hand tracking needs Fedora 43 or newer."
echo " Installing what the driver needs without it."
HT=0
else
PKGS+=("${FED_HT[@]}")
fi
fi
MISSING=("${PKGS[@]}")
CMD=(dnf install -y "${PKGS[@]}")
else
echo "ERROR: no pacman, apt-get or dnf found on $NAME: install the packages by hand (DriverKit's Compile Driver tab"
echo " lists them for Arch, Debian/Ubuntu and Fedora)."
exit 1
fi
echo "== $NAME ($FAMILY)$([ "$HT" = 1 ] && echo ", with hand tracking")"
PKGS_NEEDED=1
[ "$FAMILY" = "Arch based" ] && [ ${#MISSING[@]} -eq 0 ] && PKGS_NEEDED=0
if [ "$LIST" = 1 ] || [ "$DRY" = 1 ]; then
if [ "$PKGS_NEEDED" = 0 ]; then
echo " packages: all installed already"
else
echo " ${CMD[*]}"
fi
if [ "$RULES_NEEDED" = 1 ]; then
echo " udev rules: would install our copy ($RULES_SRC) as $RULES_FILE"
else
echo " udev rules: installed ($RULES_HAVE)"
fi
exit 0
fi
if [ "$PKGS_NEEDED" = 0 ] && [ "$RULES_NEEDED" = 0 ]; then
echo " everything is installed (udev rules: $RULES_HAVE)"
exit 0
fi
if [ "$(id -u)" != 0 ]; then
echo " needs root: asking through sudo"
exec sudo bash "$0" "$@"
fi
if [ "$FAMILY" = "Debian based" ] && [ "$PKGS_NEEDED" = 1 ]; then
if [ "$UPDATED" = 0 ]; then
echo " apt-get update"
apt-get update
fi
export DEBIAN_FRONTEND=noninteractive
fi
if [ "$PKGS_NEEDED" = 1 ]; then
echo " ${CMD[*]}"
"${CMD[@]}"
else
echo " packages: all installed already"
fi
if [ "$RULES_NEEDED" = 1 ]; then
install_udev_rules || exit 1
else
echo " udev rules: installed ($RULES_HAVE)"
fi
echo "DONE dependencies installed"