Skip to content

Commit 4581325

Browse files
Add support for opendoas & void-linux to setup_tests script (#145)
Some systems (like mine) do not have `sudo` installed, but use the `opendoas` package to perform the same function. The Void Linux package manager (xbps) was fairly easy to implement support for, though I restructured that part of code to do it. I can think of one issue, but it was already present in the script in the first place: it's perfectly possible to have package managers from other distributions on your system, for managing chroot-like things. Maybe better OS detection or something more OS-independent would be better in the longterm.
1 parent c8417ad commit 4581325

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

setup_tests.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,33 @@
33
set -e
44
anki_test_revision=ed8340a4e3a2006d6285d7adf9b136c735ba2085
55

6+
# Checks if the first argument is a valid executable in a POSIX-compatible way
7+
command_exists() {
8+
command -v "$1" >/dev/null
9+
}
10+
11+
# fallback to doas if sudo is not installed
12+
if command_exists sudo; then
13+
elevator="sudo"
14+
elif command_exists doas; then
15+
elevator="doas"
16+
else
17+
echo "error: neither sudo nor doas is installed" 1>&2
18+
exit 1
19+
fi
20+
621
# install pyaudio system deps
7-
sudo apt-get -y update && sudo apt-get install -y python-all-dev portaudio19-dev ripgrep moreutils \
8-
|| sudo pacman -S --noconfirm --needed portaudio python-virtualenv ripgrep moreutils
22+
if command_exists apt-get; then
23+
$elevator apt-get -y update
24+
$elevator apt-get install -y python-all-dev portaudio19-dev ripgrep moreutils
25+
elif command_exists pacman; then
26+
$elevator pacman -S pacman -S --noconfirm --needed portaudio python-virtualenv ripgrep moreutils
27+
elif command_exists xbps-install; then
28+
$elevator xbps-install --sync --yes portaudio python3-virtualenv ripgrep moreutils
29+
else
30+
echo "error: couldn't find a suitable package manager"
31+
exit 1
32+
fi
933

1034
# enter venv if needed
1135
if [[ -z "$VIRTUAL_ENV" ]]; then

0 commit comments

Comments
 (0)