-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfedora-bootstrap.sh
More file actions
executable file
·119 lines (98 loc) · 2.71 KB
/
Copy pathfedora-bootstrap.sh
File metadata and controls
executable file
·119 lines (98 loc) · 2.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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BUILD_DIR="${BUILD_DIR:-$ROOT_DIR/build}"
BUILD_TYPE="${BUILD_TYPE:-Release}"
GENERATOR="${GENERATOR:-Ninja}"
ENABLE_TESTS="${ENABLE_TESTS:-1}"
INSTALL_AFTER_BUILD="${INSTALL_AFTER_BUILD:-0}"
INSTALL_PREFIX="${INSTALL_PREFIX:-/usr/local}"
required_build_reqs=(
cmake
extra-cmake-modules
gcc-c++
ninja-build
qt6-qtbase-devel
qt6-qtbase-private-devel
qt6-qtdeclarative-devel
qt6-qttools-devel
qt6-qtwayland-devel
polkit-devel
)
runtime_tools=(
dnf
polkit
pciutils
mokutil
kmod
lm_sensors
procps-ng
)
optional_build_reqs=(
kf6-qqc2-desktop-style
)
has_dnf_package() {
local package="$1"
dnf repoquery --quiet --whatprovides "$package" >/dev/null 2>&1
}
install_packages() {
local label="$1"
shift
if (($# == 0)); then
return 0
fi
echo "$label"
sudo dnf install -y "$@"
}
collect_available_packages() {
local -n requested_packages_ref="$1"
local -n available_packages_ref="$2"
local -n missing_packages_ref="$3"
local package
for package in "${requested_packages_ref[@]}"; do
if has_dnf_package "$package"; then
available_packages_ref+=( "$package" )
else
missing_packages_ref+=( "$package" )
fi
done
}
available_optional_build_reqs=()
missing_optional_build_reqs=()
collect_available_packages optional_build_reqs available_optional_build_reqs missing_optional_build_reqs
install_packages "[1/4] Installing Fedora build dependencies..." "${required_build_reqs[@]}"
if ((${#available_optional_build_reqs[@]} > 0)); then
install_packages "[1.1/4] Installing optional Fedora desktop integration packages..." \
"${available_optional_build_reqs[@]}"
fi
if ((${#missing_optional_build_reqs[@]} > 0)); then
printf '[info] Optional Fedora packages not available in enabled repositories: %s\n' \
"${missing_optional_build_reqs[*]}"
fi
echo "[2/4] Installing runtime utilities used by diagnostics/driver workflows..."
sudo dnf install -y "${runtime_tools[@]}"
cmake_args=(
-S "$ROOT_DIR"
-B "$BUILD_DIR"
-G "$GENERATOR"
-DCMAKE_BUILD_TYPE="$BUILD_TYPE"
-DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX"
)
if [[ "$ENABLE_TESTS" == "1" ]]; then
cmake_args+=( -DBUILD_TESTS=ON )
else
cmake_args+=( -DBUILD_TESTS=OFF )
fi
echo "[3/4] Configuring and building ($BUILD_TYPE)..."
cmake "${cmake_args[@]}"
cmake --build "$BUILD_DIR" -j"$(nproc)"
if [[ "$ENABLE_TESTS" == "1" ]]; then
echo "[3.1/4] Running test suite..."
ctest --test-dir "$BUILD_DIR" --output-on-failure
fi
echo "[4/4] Done."
echo "Run from build dir: $BUILD_DIR/ro-control"
if [[ "$INSTALL_AFTER_BUILD" == "1" ]]; then
echo "Installing to $INSTALL_PREFIX..."
sudo cmake --install "$BUILD_DIR"
fi