-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·54 lines (47 loc) · 1.85 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·54 lines (47 loc) · 1.85 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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_DIR="$ROOT_DIR/.venv"
LOCAL_QT_LIB_DIR="$ROOT_DIR/third_party/lib"
ensure_local_qt_xcb_cursor_link() {
local versioned_lib=""
if [[ -f "$LOCAL_QT_LIB_DIR/libxcb-cursor.so.0" ]]; then
return 0
fi
versioned_lib="$(find "$LOCAL_QT_LIB_DIR" -maxdepth 1 -type f -name 'libxcb-cursor.so.0.*' | sort | tail -n1 || true)"
if [[ -z "$versioned_lib" ]]; then
return 1
fi
ln -sfn "$(basename "$versioned_lib")" "$LOCAL_QT_LIB_DIR/libxcb-cursor.so.0"
}
if [[ ! -d "$VENV_DIR" ]]; then
python3 -m venv "$VENV_DIR"
fi
source "$VENV_DIR/bin/activate"
python -m pip install --upgrade pip
python -m pip install -r "$ROOT_DIR/requirements.txt"
mkdir -p "$LOCAL_QT_LIB_DIR"
if ! ensure_local_qt_xcb_cursor_link && command -v apt-get >/dev/null 2>&1 && command -v dpkg-deb >/dev/null 2>&1; then
download_dir="$(mktemp -d "${TMPDIR:-/tmp}/netcontrol-xcb.XXXXXX")"
chmod 1777 "$download_dir"
(
trap 'rm -rf "$download_dir"' EXIT
cd "$download_dir"
apt-get download libxcb-cursor0 >/dev/null || true
deb_file="$(ls -1t libxcb-cursor0_*_amd64.deb 2>/dev/null | head -n1 || true)"
if [[ -z "$deb_file" ]]; then
deb_file="$(ls -1t libxcb-cursor0_*.deb 2>/dev/null | head -n1 || true)"
fi
if [[ -n "$deb_file" ]]; then
rm -rf "$ROOT_DIR/third_party/extract"
mkdir -p "$ROOT_DIR/third_party/extract"
dpkg-deb -x "$deb_file" "$ROOT_DIR/third_party/extract"
mapfile -t cursor_libs < <(find "$ROOT_DIR/third_party/extract/usr/lib" \( -type f -o -type l \) -name 'libxcb-cursor.so.0*' 2>/dev/null | sort)
if [[ ${#cursor_libs[@]} -gt 0 ]]; then
cp -af "${cursor_libs[@]}" "$LOCAL_QT_LIB_DIR/" || true
ensure_local_qt_xcb_cursor_link || true
fi
fi
)
fi
echo "Local virtual environment ready: $VENV_DIR"