1
1
#! /bin/bash
2
2
3
- mkdir -p " /opt/ardupilot_dave" && cd " /opt/ardupilot_dave" || exit
3
+ mkdir -p " /opt/ardupilot_dave" 2> /dev/null
4
+ if [ $? -ne 0 ]; then
5
+ echo " Insufficient privileges to create directory in /opt."
6
+ sudo mkdir -p " /opt/ardupilot_dave" && cd " /opt/ardupilot_dave" || exit
7
+ else
8
+ mkdir -p " /opt/ardupilot_dave" && cd " /opt/ardupilot_dave" || exit
9
+ fi
10
+
4
11
# Really should do version pinning but Sub-4.5 is waaaay behind master
5
12
# (e.g. it doesn't know about "noble" yet)
6
13
export ARDUPILOT_RELEASE=master
7
- git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules
14
+ mkdir -p " /opt/ardupilot_dave/ardupilot" 2> /dev/null
15
+ if [ $? -ne 0 ]; then
16
+ sudo git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules
17
+ else
18
+ git clone -b $ARDUPILOT_RELEASE https://github.com/ArduPilot/ardupilot.git --recurse-submodules
19
+ fi
8
20
9
21
# Install ArduSub dependencies
10
22
cd " /opt/ardupilot_dave/ardupilot" || exit
@@ -18,18 +30,36 @@ Tools/environment_install/install-prereqs-ubuntu.sh -y
18
30
# Build ArduSub
19
31
cd " /opt/ardupilot_dave/ardupilot" || exit
20
32
# needs python binary (e.g. sudo apt install python-is-python3)
21
- apt-get install -y python-is-python3 python3-future
22
- modules/waf/waf-light configure --board still \
33
+ mkdir -p " /opt/ardupilot_dave/ardupilot/mktest" 2> /dev/null
34
+ if [ $? -ne 0 ]; then
35
+ sudo modules/waf/waf-light configure --board still \
36
+ && sudo modules/waf/waf-light build --target bin/ardusub
37
+ else
38
+ modules/waf/waf-light configure --board still \
23
39
&& modules/waf/waf-light build --target bin/ardusub
40
+ fi
24
41
25
42
# Clone ardupilot_gazebo code
26
43
cd " /opt/ardupilot_dave" || exit
27
- git clone https://github.com/ArduPilot/ardupilot_gazebo.git
44
+ mkdir -p " /opt/ardupilot_dave/ardupilot_gazebo" 2> /dev/null
45
+ if [ $? -ne 0 ]; then
46
+ sudo git clone https://github.com/ArduPilot/ardupilot_gazebo.git
47
+ else
48
+ git clone https://github.com/ArduPilot/ardupilot_gazebo.git
49
+ fi
28
50
29
51
# Install ardupilot_gazebo plugin
30
- mkdir -p " /opt/ardupilot_dave/ardupilot_gazebo/build" \
31
- && cd " /opt/ardupilot_dave/ardupilot_gazebo/build" || exit
32
- cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j2
52
+ # Check if the directory creation was successful
53
+ mkdir -p " /opt/ardupilot_dave/ardupilot_gazebo/build" 2> /dev/null
54
+ if [ $? -ne 0 ]; then
55
+ echo " Insufficient privileges to create directory in /opt. Using sudo for cmake and make."
56
+ sudo mkdir -p " /opt/ardupilot_dave/ardupilot_gazebo/build" \
57
+ && cd " /opt/ardupilot_dave/ardupilot_gazebo/build" || exit
58
+ sudo cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && sudo make -j2
59
+ else
60
+ cd " /opt/ardupilot_dave/ardupilot_gazebo/build" || exit
61
+ cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j2
62
+ fi
33
63
34
64
# Add results of ArduSub build
35
65
export PATH=/opt/ardupilot_dave/ardupilot/build/still/bin:\$ PATH
0 commit comments