forked from EvilSquirrelGuy/quickbar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·369 lines (334 loc) · 9.71 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·369 lines (334 loc) · 9.71 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
#!/usr/bin/env bash
# Build and install QuickBar. Detects the distro and installs missing build deps.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
prefix="${PREFIX:-/usr}"
build_dir="${BUILD_DIR:-build}"
skip_deps=false
usage() {
cat <<'EOF'
Usage: ./install.sh [OPTIONS] [PREFIX]
Build and install QuickBar (Plasma 6 applet).
Options:
--no-deps Skip automatic dependency installation
-h, --help Show this help
Environment:
PREFIX Install prefix (default: /usr)
BUILD_DIR CMake build directory (default: build)
SKIP_DEPS=1 Same as --no-deps
Examples:
./install.sh # install to /usr (uses sudo)
./install.sh ~/.local # user-local install (no sudo)
./install.sh --no-deps # build only; deps must already be installed
Requires Plasma 6.0+ (KF6 / Qt6). See README.md for supported distributions.
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--no-deps)
skip_deps=true
shift
;;
-h|--help)
usage
exit 0
;;
/*|./*|~/*)
prefix="$1"
shift
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
done
if [[ "${SKIP_DEPS:-}" == 1 ]]; then
skip_deps=true
fi
detect_distro() {
if [[ ! -f /etc/os-release ]]; then
echo "unknown"
return
fi
# shellcheck source=/dev/null
source /etc/os-release
local id="${ID,,}"
local id_like="${ID_LIKE:-}"
case "$id" in
arch|cachyos|manjaro|endeavouros|garuda|artix)
echo arch
;;
debian|ubuntu|linuxmint|pop|popos|neon|elementary|zorin|kubuntu|xubuntu|lubuntu|mint)
echo debian
;;
fedora|nobara|ultramarine|azurelinux)
echo fedora
;;
rhel|centos|rocky|almalinux|mariner)
echo fedora
;;
opensuse*|sles|sle*)
echo opensuse
;;
*)
if [[ "$id_like" == *arch* ]]; then
echo arch
elif [[ "$id_like" == *debian* || "$id_like" == *ubuntu* ]]; then
echo debian
elif [[ "$id_like" == *fedora* || "$id_like" == *rhel* ]]; then
echo fedora
elif [[ "$id_like" == *suse* ]]; then
echo opensuse
else
echo unknown
fi
;;
esac
}
run_privileged() {
if [[ "${EUID:-$(id -u)}" -eq 0 ]]; then
"$@"
elif command -v sudo >/dev/null 2>&1; then
sudo "$@"
else
echo "Need root privileges (or sudo) to install packages." >&2
exit 1
fi
}
pkg_installed_pacman() {
pacman -Q "$1" &>/dev/null
}
pkg_installed_dpkg() {
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -q 'install ok installed'
}
pkg_installed_rpm() {
rpm -q "$1" &>/dev/null
}
install_deps_arch() {
local packages=(
base-devel
cmake
extra-cmake-modules
gcc
libplasma
plasma-workspace
qt6-base
qt6-declarative
kconfig
kcoreaddons
ki18n
kitemmodels
kwindowsystem
kirigami
)
local missing=()
local pkg
for pkg in "${packages[@]}"; do
if ! pkg_installed_pacman "$pkg"; then
missing+=("$pkg")
fi
done
if ((${#missing[@]} == 0)); then
echo "All build dependencies are already installed (pacman)."
return
fi
echo "Installing missing build dependencies (${#missing[@]} packages) via pacman..."
run_privileged pacman -S --needed --noconfirm "${missing[@]}"
}
install_deps_debian() {
local packages=(
cmake
extra-cmake-modules
g++
qt6-base-dev
qt6-declarative-dev
libplasma-dev
plasma-workspace-dev
libkf6config-dev
libkf6coreaddons-dev
libkf6i18n-dev
libkf6itemmodels-dev
libkf6windowsystem-dev
libkirigami-dev
)
local missing=()
local pkg
for pkg in "${packages[@]}"; do
if ! pkg_installed_dpkg "$pkg"; then
missing+=("$pkg")
fi
done
if ((${#missing[@]} == 0)); then
echo "All build dependencies are already installed (apt)."
return
fi
echo "Installing missing build dependencies (${#missing[@]} packages) via apt..."
run_privileged apt-get update -qq
run_privileged apt-get install -y --no-install-recommends "${missing[@]}"
}
install_deps_fedora() {
local pm
if command -v dnf >/dev/null 2>&1; then
pm=dnf
elif command -v yum >/dev/null 2>&1; then
pm=yum
else
echo "dnf/yum not found." >&2
return 1
fi
local packages=(
cmake
extra-cmake-modules
gcc-c++
qt6-qtbase-devel
qt6-qtdeclarative-devel
libplasma-devel
plasma-workspace-devel
kf6-kconfig-devel
kf6-kcoreaddons-devel
kf6-ki18n-devel
kf6-kitemmodels-devel
kf6-kwindowsystem-devel
kf6-kirigami-devel
)
local missing=()
local pkg
for pkg in "${packages[@]}"; do
if ! pkg_installed_rpm "$pkg"; then
missing+=("$pkg")
fi
done
if ((${#missing[@]} == 0)); then
echo "All build dependencies are already installed (${pm})."
return
fi
echo "Installing missing build dependencies (${#missing[@]} packages) via ${pm}..."
run_privileged "$pm" install -y "${missing[@]}"
}
install_deps_opensuse() {
local spec="$ROOT/packaging/rpm/quickbar.spec"
if [[ -f "$spec" ]] && command -v zypper >/dev/null 2>&1; then
echo "Installing build dependencies from RPM spec via zypper..."
run_privileged zypper -n install -y rpm-build 2>/dev/null || true
run_privileged zypper -n build-deps-install "$spec"
return
fi
local packages=(
cmake
extra-cmake-modules
gcc-c++
libqt6-qtbase-devel
libqt6-qtdeclarative-devel
plasma6-libplasma-devel
plasma6-workspace-devel
kf6-kconfig-devel
kf6-kcoreaddons-devel
kf6-ki18n-devel
kf6-kitemmodels-devel
kf6-kwindowsystem-devel
kf6-kirigami-devel
)
local missing=()
local pkg
for pkg in "${packages[@]}"; do
if ! pkg_installed_rpm "$pkg"; then
missing+=("$pkg")
fi
done
if ((${#missing[@]} == 0)); then
echo "All build dependencies are already installed (zypper)."
return
fi
echo "Installing missing build dependencies (${#missing[@]} packages) via zypper..."
run_privileged zypper -n install -y "${missing[@]}"
}
print_manual_deps() {
cat <<'EOF' >&2
Could not detect a supported package manager, or dependency install failed.
Install Plasma 6 build dependencies manually, then re-run:
Arch / CachyOS:
sudo pacman -S --needed base-devel cmake extra-cmake-modules gcc \
libplasma plasma-workspace qt6-base qt6-declarative \
kconfig kcoreaddons ki18n kitemmodels kwindowsystem kirigami
Debian / Ubuntu (Plasma 6):
sudo apt install cmake extra-cmake-modules g++ \
qt6-base-dev qt6-declarative-dev libplasma-dev plasma-workspace-dev \
libkf6config-dev libkf6coreaddons-dev libkf6i18n-dev libkf6itemmodels-dev \
libkf6windowsystem-dev libkirigami-dev
Fedora:
sudo dnf install cmake extra-cmake-modules gcc-c++ \
qt6-qtbase-devel qt6-qtdeclarative-devel libplasma-devel \
plasma-workspace-devel kf6-kconfig-devel kf6-kcoreaddons-devel \
kf6-ki18n-devel kf6-kitemmodels-devel kf6-kwindowsystem-devel kf6-kirigami-devel
openSUSE:
sudo zypper build-deps-install packaging/rpm/quickbar.spec
See README.md and packaging/README.md for details.
EOF
}
ensure_build_dependencies() {
if $skip_deps; then
echo "Skipping dependency installation (--no-deps)."
return
fi
local distro pretty_name="unknown"
if [[ -f /etc/os-release ]]; then
# shellcheck source=/dev/null
source /etc/os-release
pretty_name="${PRETTY_NAME:-${NAME:-unknown}}"
fi
distro="$(detect_distro)"
echo "Detected distribution: ${distro} (${pretty_name})"
case "$distro" in
arch)
if ! command -v pacman >/dev/null 2>&1; then
echo "pacman not found." >&2
print_manual_deps
exit 1
fi
install_deps_arch
;;
debian)
if ! command -v apt-get >/dev/null 2>&1; then
echo "apt-get not found." >&2
print_manual_deps
exit 1
fi
install_deps_debian
;;
fedora)
if ! install_deps_fedora; then
print_manual_deps
exit 1
fi
;;
opensuse)
if ! command -v zypper >/dev/null 2>&1; then
echo "zypper not found." >&2
print_manual_deps
exit 1
fi
install_deps_opensuse
;;
*)
echo "Unsupported or unknown distribution for automatic dependency install." >&2
print_manual_deps
exit 1
;;
esac
}
ensure_build_dependencies
cd "$ROOT"
if ! command -v cmake >/dev/null 2>&1; then
echo "cmake not found after dependency install. Install build dependencies and retry." >&2
exit 1
fi
cmake -B "$build_dir" -DCMAKE_INSTALL_PREFIX="$prefix"
cmake --build "$build_dir"
if [[ "$prefix" == /usr ]]; then
run_privileged cmake --install "$build_dir"
else
cmake --install "$build_dir"
fi
echo "Installed QuickBar to $prefix. Restart plasmashell and add the QuickBar widget."