-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·75 lines (64 loc) · 2.43 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·75 lines (64 loc) · 2.43 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
#!/bin/sh
set -eu
PROJECT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
INSTALL_PREFIX=${PREFIX:-"$HOME/.local"}
BIN_DIR="$INSTALL_PREFIX/bin"
DATA_ROOT=${XDG_DATA_HOME:-"$HOME/.local/share"}
APPLICATIONS_DIR="$DATA_ROOT/applications"
LAUNCHER_PATH="$BIN_DIR/map-shift"
DESKTOP_PATH="$APPLICATIONS_DIR/map-shift.desktop"
DESKTOP_TEMP=$(mktemp "${TMPDIR:-/tmp}/map-shift.desktop.XXXXXX")
trap 'rm -f "$DESKTOP_TEMP"' EXIT HUP INT TERM
missing=""
for command_name in python3 dolphin; do
if ! command -v "$command_name" >/dev/null 2>&1; then
missing="$missing $command_name"
fi
done
if ! /usr/bin/python3 -c 'import dbus; import PyQt6' >/dev/null 2>&1; then
missing="$missing python3-dbus/python3-pyqt6"
fi
for package_name in kio-fuse kio-extras; do
if ! dpkg-query -W -f='${Status}' "$package_name" 2>/dev/null | grep -q 'install ok installed'; then
missing="$missing $package_name"
fi
done
if [ -n "$missing" ]; then
printf 'Missing dependencies:%s\n' "$missing" >&2
printf '%s\n' 'On Debian 13: sudo apt install kio-fuse kio-extras python3-dbus python3-pyqt6 dolphin' >&2
exit 1
fi
install -d -m 755 "$BIN_DIR" "$APPLICATIONS_DIR"
install -m 755 "$PROJECT_DIR/map-shift" "$LAUNCHER_PATH"
/usr/bin/python3 - "$PROJECT_DIR/map-shift.desktop.in" "$DESKTOP_TEMP" "$LAUNCHER_PATH" <<'PY'
from pathlib import Path
import sys
template = Path(sys.argv[1]).read_text(encoding="utf-8")
launcher = sys.argv[3]
escaped = launcher.replace("\\", "\\\\").replace('"', '\\"').replace("`", "\\`").replace("$", "\\$")
Path(sys.argv[2]).write_text(
template.replace("@MAP_SHIFT_EXEC@", f'"{escaped}"'),
encoding="utf-8",
)
PY
install -m 644 "$DESKTOP_TEMP" "$DESKTOP_PATH"
if command -v desktop-file-validate >/dev/null 2>&1; then
desktop-file-validate "$DESKTOP_PATH"
fi
if command -v update-desktop-database >/dev/null 2>&1; then
update-desktop-database "$APPLICATIONS_DIR"
fi
if command -v kbuildsycoca6 >/dev/null 2>&1; then
kbuildsycoca6 --noincremental >/dev/null 2>&1 || true
fi
printf 'Installed MapShift to %s\n' "$LAUNCHER_PATH"
MAPS_READY=false
if [ -d /maps ] && [ ! -L /maps ]; then
if [ "$(stat -c %u /maps)" -eq "$(id -u)" ] && [ "$(stat -c %a /maps)" = 700 ]; then
MAPS_READY=true
fi
fi
if [ "$MAPS_READY" = false ]; then
printf '%s\n' 'Optional /maps shortcuts are not configured.'
printf 'To enable them, run: sudo install -d -m 0700 -o %s -g %s /maps\n' "$(id -un)" "$(id -gn)"
fi