refactor: make audio mandatory and split iced app modules
This commit is contained in:
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
||||
REPO_ROOT="$(readlink -f "$SCRIPT_DIR/..")"
|
||||
|
||||
IMAGE="${RETEAMSPEAK_AUDIO_IMAGE:-docker.io/library/rust:1.91-bookworm}"
|
||||
|
||||
podman run --rm \
|
||||
-v "$REPO_ROOT:/workspace:Z" \
|
||||
-w /workspace/src \
|
||||
"$IMAGE" \
|
||||
bash -lc "apt-get update >/dev/null && \
|
||||
apt-get install -y --no-install-recommends cmake pkg-config libasound2-dev libopus-dev >/dev/null && \
|
||||
/usr/local/cargo/bin/cargo check -p re-teamspeak"
|
||||
Executable
+122
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
||||
REPO_ROOT="$(readlink -f "$SCRIPT_DIR/..")"
|
||||
UID_VALUE="$(id -u)"
|
||||
GID_VALUE="$(id -g)"
|
||||
RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$UID_VALUE}"
|
||||
IMAGE="${RETEAMSPEAK_AUDIO_IMAGE:-docker.io/library/rust:1.91-bookworm}"
|
||||
|
||||
if [[ $# -gt 0 && "$1" == "--" ]]; then
|
||||
shift
|
||||
if [[ $# -eq 0 ]]; then
|
||||
printf 'Expected a container command after --\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
CONTAINER_CMD=("$@")
|
||||
else
|
||||
CONTAINER_CMD=(/usr/local/cargo/bin/cargo run -p re-teamspeak)
|
||||
fi
|
||||
|
||||
quoted_cmd() {
|
||||
local quoted=()
|
||||
local part
|
||||
for part in "$@"; do
|
||||
quoted+=("$(printf '%q' "$part")")
|
||||
done
|
||||
printf '%s ' "${quoted[@]}"
|
||||
}
|
||||
|
||||
PODMAN_ARGS=(
|
||||
run
|
||||
--rm
|
||||
--network host
|
||||
-v "$REPO_ROOT:/workspace:Z"
|
||||
-w /workspace/src
|
||||
-e CARGO_TARGET_DIR=/tmp/re-teamspeak-target
|
||||
)
|
||||
|
||||
if [[ -t 0 && -t 1 ]]; then
|
||||
PODMAN_ARGS+=( -it )
|
||||
fi
|
||||
|
||||
if [[ -e /dev/snd ]]; then
|
||||
PODMAN_ARGS+=( --device /dev/snd )
|
||||
fi
|
||||
|
||||
if [[ -e /dev/dri ]]; then
|
||||
PODMAN_ARGS+=( --device /dev/dri )
|
||||
fi
|
||||
|
||||
if [[ -S "$RUNTIME_DIR/pulse/native" ]]; then
|
||||
PODMAN_ARGS+=(
|
||||
-v "$RUNTIME_DIR/pulse:$RUNTIME_DIR/pulse:Z"
|
||||
-e "PULSE_SERVER=unix:$RUNTIME_DIR/pulse/native"
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ -S "$RUNTIME_DIR/pipewire-0" ]]; then
|
||||
PODMAN_ARGS+=(
|
||||
-v "$RUNTIME_DIR/pipewire-0:$RUNTIME_DIR/pipewire-0:Z"
|
||||
-v "$RUNTIME_DIR/pipewire-0-manager:$RUNTIME_DIR/pipewire-0-manager:Z"
|
||||
-e "PIPEWIRE_REMOTE=$RUNTIME_DIR/pipewire-0"
|
||||
-e "XDG_RUNTIME_DIR=$RUNTIME_DIR"
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ -S "$RUNTIME_DIR/bus" ]]; then
|
||||
PODMAN_ARGS+=(
|
||||
-v "$RUNTIME_DIR/bus:$RUNTIME_DIR/bus:Z"
|
||||
-e "DBUS_SESSION_BUS_ADDRESS=unix:path=$RUNTIME_DIR/bus"
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ -n "${WAYLAND_DISPLAY:-}" && -S "$RUNTIME_DIR/$WAYLAND_DISPLAY" ]]; then
|
||||
PODMAN_ARGS+=(
|
||||
-v "$RUNTIME_DIR/$WAYLAND_DISPLAY:$RUNTIME_DIR/$WAYLAND_DISPLAY:Z"
|
||||
-e "WAYLAND_DISPLAY=$WAYLAND_DISPLAY"
|
||||
-e "XDG_RUNTIME_DIR=$RUNTIME_DIR"
|
||||
)
|
||||
elif [[ -n "${DISPLAY:-}" && -d /tmp/.X11-unix ]]; then
|
||||
PODMAN_ARGS+=(
|
||||
-v /tmp/.X11-unix:/tmp/.X11-unix:ro
|
||||
-e "DISPLAY=$DISPLAY"
|
||||
)
|
||||
if [[ -n "${XAUTHORITY:-}" && -f "$XAUTHORITY" ]]; then
|
||||
PODMAN_ARGS+=(
|
||||
-v "$XAUTHORITY:$XAUTHORITY:ro,Z"
|
||||
-e "XAUTHORITY=$XAUTHORITY"
|
||||
)
|
||||
fi
|
||||
elif [[ ${CONTAINER_CMD[0]} == /usr/local/cargo/bin/cargo && ${CONTAINER_CMD[1]} == run ]]; then
|
||||
printf 'No Wayland or X11 session detected in this shell.\n' >&2
|
||||
printf 'Run this from a desktop session, or pass a custom container command with --.\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
APT_PACKAGES=(
|
||||
cmake
|
||||
pkg-config
|
||||
libasound2-dev
|
||||
libopus-dev
|
||||
libxkbcommon0
|
||||
libwayland-client0
|
||||
libwayland-cursor0
|
||||
libwayland-egl1
|
||||
libx11-6
|
||||
libxrandr2
|
||||
libxi6
|
||||
libxcursor1
|
||||
libxinerama1
|
||||
libgl1
|
||||
libegl1
|
||||
libdbus-1-3
|
||||
)
|
||||
|
||||
APT_CMD="apt-get update >/dev/null && apt-get install -y --no-install-recommends $(quoted_cmd "${APT_PACKAGES[@]}") >/dev/null"
|
||||
RUN_CMD="$(quoted_cmd "${CONTAINER_CMD[@]}")"
|
||||
|
||||
exec podman "${PODMAN_ARGS[@]}" "$IMAGE" \
|
||||
bash -lc "$APT_CMD && $RUN_CMD"
|
||||
Reference in New Issue
Block a user