forked from paparazzi/paparazzi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·145 lines (110 loc) · 4.85 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·145 lines (110 loc) · 4.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
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
#!/bin/bash
# ── Color definitions ─────────────────────────────────────────────────────────
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m' # No Color
USE_VENV=true
BASHRC_SOURCE_VENV=false
# ── Helper functions ──────────────────────────────────────────────────────────
print_header() {
echo ""
echo -e "${CYAN}${BOLD}════════════════════════════════════════════════════════════════════════════════${NC}"
echo -e "${CYAN}${BOLD} $1${NC}"
echo -e "${CYAN}${BOLD}════════════════════════════════════════════════════════════════════════════════${NC}"
echo ""
}
print_success() {
echo ""
echo -e "${GREEN}${BOLD} ✔ $1${NC}"
echo ""
}
print_error() {
echo ""
echo -e "${RED}${BOLD} ✘ $1${NC}"
echo -e "${RED} Please check the error above and consult the documentation:${NC}"
echo -e "${RED} https://paparazzi-uav.readthedocs.io${NC}"
echo ""
}
run_step() {
# Usage: run_step "description" command arg1 arg2 ...
local description="$1"
shift
echo -e " ${YELLOW}▸${NC} ${description}..."
if "$@"; then
echo -e " ${GREEN}✔${NC} ${description} ${GREEN}done${NC}"
return 0
else
print_error "${description} FAILED"
return 1
fi
}
# Stop on error
set -e
# ── Parse arguments ───────────────────────────────────────────────────────────
for arg in "$@"
do
if [ "$arg" = "-h" ] || [ "$arg" = "--help" ]
then
echo "Usage: ./install.sh [-n|--no-venv] [-h|---help]"
echo " -n, --no-venv Do not use python virtual environment"
echo " -s, --source Add venv source in ~/.bashrc"
echo " -h, --help Print this help"
exit 0
fi
if [ "$arg" = "-n" ] || [ "$arg" = "--no-venv" ]
then
USE_VENV=false
echo -e "${YELLOW} ⚠ Virtual environment will NOT be installed.${NC}"
fi
if [ "$arg" = "-s" ] || [ "$arg" = "--source" ]
then
BASHRC_SOURCE_VENV=true
fi
done
if [ $VIRTUAL_ENV ]
then
echo -e "${YELLOW} ⚠ Cannot create venv from itself! Run 'deactivate' first if you want to recreate the venv.${NC}"
USE_VENV = false
BASHRC_SOURCE_VENV=false
fi
# ── Update packages list ──────────────────────────────────────────────────
print_header "Step 0/3 — Update packages list"
if run_step "APT Update" sudo apt update; then
print_success "Packages list updated successfully"
else
exit 1
fi
# ── Install Qt dependencies ──────────────────────────────────────────────────
print_header "Step 1/3 — Installing Qt platform dependencies"
# Solves: Could not load the Qt platform plugin "xcb"
if run_step "Installing Qt libraries" sudo apt install -y libxcb-xinerama0 libxcb-cursor0 libxkbcommon-x11-0 libglu1-mesa; then
print_success "Qt dependencies installed successfully"
else
exit 1
fi
# ── Set up Python environment ────────────────────────────────────────────────
print_header "Step 2/3 — Setting up Python environment"
if [ "$USE_VENV" = true ]
then
run_step "Installing python3 and python3-venv" sudo apt install -y python3 python3-venv
run_step "Creating virtual environment" python3 setup.py
source pprzEnv/bin/activate
print_success "Virtual environment created and activated"
if [ "$BASHRC_SOURCE_VENV" = true ]
then
echo "source $(pwd)/pprzEnv/bin/activate" >> ~/.bashrc
print_success "Virtual environment source added to ~/.bashrc"
fi
else
run_step "Installing python3 and PyQt5 (system-wide)" sudo apt-get install -f -y python3 python3-pyqt5
print_success "Python packages installed system-wide"
fi
# ── Launch the graphical installer ───────────────────────────────────────────
print_header "Step 3/3 — Launching Paparazzi installer GUI"
echo -e " ${YELLOW}▸${NC} Starting graphical installer..."
echo -e " ${CYAN} Follow the numbered steps in the GUI to complete the installation.${NC}"
echo ""
python3 ./sw/tools/install.py