Skip to content

Commit e1e07cc

Browse files
committed
no need to delete python3.12, and upates
1 parent 404b893 commit e1e07cc

File tree

3 files changed

+42
-105
lines changed

3 files changed

+42
-105
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
## One-liner installation code (🍎 (Apple Silicon) + 🤖 = 🚀❤️🤩🎉🥳)
44
- Copy and paste it on terminal
55

6+
### For full installation (ROS2 Jazzy and Gazebo Harmonic, in order)
7+
68
```bash
79
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/IOES-Lab/ROS2_Jazzy_MacOS_Native_AppleSilicon/main/install.sh)"
810
```
911

12+
### Gazebo installation only
13+
14+
```bash
15+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/IOES-Lab/ROS2_Jazzy_MacOS_Native_AppleSilicon/main/gz_install.sh)"
16+
```
17+
1018
## Introduction
1119
This is the source code behind the one-line installation command to install ROS2 Jazzy and Gazebo Harmonic on Apple Silicon Macbooks.
1220

@@ -64,6 +72,9 @@ The reasons for installing ROS2 Jazzy natively on Apple Silicon Macbooks are:
6472
- It is not supported on Apple Silicon Macbooks (compile errors)
6573
- Ref : https://ros.org/reps/rep-2000.html
6674

75+
## For MAVROS
76+
- Visit https://github.com/IOES-Lab/ROS2_MAVROS_AppleSilicon
77+
6778
## References: (None of below worked for me, so I made this script)
6879
- https://github.com/pfavr2/install_ros2_rolling_on_mac_m1
6980
- Much of the code design structure is referenced from this

gz_install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ echo -e "\033[32m|\033[0m Virtual Environment Directory :" "\033[94m$HOME/$VIRT
9191
echo -e "\033[32m▣-------------------------------------------------------------------------▣\033[0m"
9292
echo -e "Source code at: "
9393
echo -e "https://github.com/IOES-Lab/ROS2_Jazzy_MacOS_Native_AppleSilicon/gz_install.sh\n"
94-
echo -e "\033[33m⚠️ WARNING: The FAN WILL BURST out and make macbook to take off. Be warned!\033[0m"
94+
echo -e "\033[33m⚠️ WARNING: The FAN WILL BURST out and make macbook to take off. Be warned!\033[0m"
9595
echo -e "\033[33m To terminate at any process, press Ctrl+C.\033[0m"
9696
# ------------------------------------------------------------------------------
9797
# Check System
@@ -102,10 +102,10 @@ printf '\033[34m%.0s=\033[0m' {1..75} && echo
102102
# Check if Installation dir already exists and warn user
103103
echo -e "\033[34m> Check Installation Directory\033[0m"
104104
if [ -d "$HOME/$GZ_INSTALL_ROOT" ]; then
105-
echo -e "\033[33m⚠️ WARNING: The directory $GZ_INSTALL_ROOT already exists at home ($HOME)."
105+
echo -e "\033[33m⚠️ WARNING: The directory $GZ_INSTALL_ROOT already exists at home ($HOME)."
106106
echo -e "\033[33m This script will merge and overwrite the existing directory.\033[0m"
107107
echo -e "\033[33mDo you want to continue? [y/n/r/c]\033[0m"
108-
read -p "(y) Merge (n) Cancel (r) Change directory, (c) Force reinstall: " -n 1 -r
108+
read -p "(y) Merge (n) Cancel (r) Change directory, (c) Clean re-install: " -n 1 -r
109109
echo
110110
if [[ $REPLY =~ ^[Yy]$ ]]; then
111111
echo -e "\033[33mMerging and overwriting existing directory...\033[0m"

install.sh

Lines changed: 28 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -154,43 +154,23 @@ echo -e "e.g. \033[33m/bin/bash -c '\$(curl -fsSL https://raw. ...install.sh)\"\
154154
echo -e "\033[0m"
155155
echo -e "Source code at: "
156156
echo -e "https://github.com/IOES-Lab/ROS2_Jazzy_MacOS_Native_AppleSilicon/install.sh\n"
157-
echo -e "\033[33m⚠️ WARNING: The FAN WILL BURST out and make macbook to take off. Be warned!\033[0m"
157+
echo -e "\033[33m⚠️ WARNING: The FAN WILL BURST out and make macbook to take off. Be warned!\033[0m"
158158
echo -e "\033[33m To terminate at any process, press Ctrl+C.\033[0m"
159159

160+
# Trap SIGINT (Ctrl+C) and exit cleanly
161+
trap 'echo -e "\033[31m\nInstallation aborted.\033[0m"; exit' SIGINT
162+
160163
# Check if the script is running in a GitHub Actions workflow
161164
if [[ -z "$GITHUB_ACTIONS" ]]; then
162-
# Type yes to continue if not auto type
163-
echo -e '\033[96m\n💡 Do you want to continue? [y/n]: \033[0m'
164-
# Start a background process for the countdown and automatic response
165-
(
166-
# Show a countdown for 10 seconds
167-
for i in {10..1}
168-
do
169-
# shellcheck disable=SC2059
170-
printf "\r Continuing in $i seconds..."
171-
sleep 1
172-
done
173-
174-
# Clear the line
175-
printf "\r"
176-
177-
# Send 'y'
178-
echo 'y'
179-
) &
180-
181-
# Save the PID of the background process and disown it
182-
bg_pid=$!
183-
disown $bg_pid
184-
185-
# Read the user's response in the foreground
186-
read -n 1 -r response
187-
188-
# If the user responded, kill the background process
189-
if [[ -n "$response" ]]; then
190-
kill "$bg_pid" >/dev/null 2>&1
191-
fi
165+
# Prompt the user and wait for a response with a timeout of 10 seconds
166+
echo -e '\033[96m\n💡 The installation will continue automatically in 10 seconds unless you respond. \033[0m'
167+
read -p $'\033[96m Do you want to proceed now? [y/n]: \033[0m' -n 1 -r -t 10 response
168+
echo # Move to a new line after the user input
169+
170+
# Default to 'y' if no response is given within the timeout
171+
response=${response:-y}
192172
else
193-
# If running in a GitHub Actions workflow, automatically set the response to 'y'
173+
# Automatically set the response to 'y' in a GitHub Actions workflow
194174
response='y'
195175
fi
196176

@@ -200,7 +180,6 @@ if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
200180
exit 1
201181
fi
202182

203-
204183
# ------------------------------------------------------------------------------
205184
# Check System
206185
printf '\n\n\033[34m'; printf '=%.0s' {1..75}; printf '\033[0m\n'
@@ -225,7 +204,7 @@ if [ "$(xcode-select -p)" != "/Applications/Xcode.app/Contents/Developer" ]; the
225204
ACCEPTED_LICENSE_VERSION=$(defaults read /Library/Preferences/com.apple.dt.Xcode 2> /dev/null | grep IDEXcodeVersionForAgreedToGMLicense | cut -d '"' -f 2)
226205
# Check if the Xcode license has been accepted
227206
if [ "$XCODE_VERSION" != "$ACCEPTED_LICENSE_VERSION" ]; then
228-
echo -e "\033[33m⚠️ WARNING: Xcode license needs to be accepted. Please follow the prompts to accept the license.\033[0m"
207+
echo -e "\033[33m⚠️ WARNING: Xcode license needs to be accepted. Please follow the prompts to accept the license.\033[0m"
229208
sudo xcodebuild -license
230209
# shellcheck disable=SC2181
231210
if [ $? -ne 0 ]; then
@@ -272,10 +251,10 @@ fi
272251
# Check if Installation dir already exists and warn user
273252
echo -e "\033[34m> Check Installation Directory\033[0m"
274253
if [ -d "$HOME/$ROS_INSTALL_ROOT" ]; then
275-
echo -e "\033[33m⚠️ WARNING: The directory $ROS_INSTALL_ROOT already exists at home ($HOME)."
254+
echo -e "\033[33m⚠️ WARNING: The directory $ROS_INSTALL_ROOT already exists at home ($HOME)."
276255
echo -e "\033[33m This script will merge and overwrite the existing directory.\033[0m"
277256
echo -e "\033[96mDo you want to continue? [y/n/r/c]\033[0m"
278-
read -p "(y) Merge (n) Cancel (r) Change directory, (c) Force reinstall: " -n 1 -r
257+
read -p "(y) Merge (n) Cancel (r) Change directory, (c) Clean re-install: " -n 1 -r
279258
echo
280259
if [[ $REPLY =~ ^[Yy]$ ]]; then
281260
echo -e "\033[33mMerging and overwriting existing directory...\033[0m"
@@ -324,41 +303,6 @@ brew install asio assimp bison bullet cmake console_bridge cppcheck \
324303
cunit eigen freetype graphviz opencv openssl orocos-kdl pcre poco \
325304
pyqt@5 python@3.11 qt@5 sip spdlog tinyxml tinyxml2
326305

327-
# Remove unnecessary packages
328-
echo -e "\033[36m\n> Removing unnecessary packages...ones that causes error, python@3.12, qt6\033[0m"
329-
if brew list --formula | grep -q "python@3.12"; then
330-
echo -e "\033[31m⚠️ WARNING: Python@3.12 installation is found. Currently this does not work with ros2 jazzy."
331-
if [[ -z "$GITHUB_ACTIONS" ]]; then
332-
echo -e "💡 Do you want to remove it? (y/n)\033[0m"
333-
read -r response
334-
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
335-
echo -e "\033[36m> Removing python@3.12 (with ignore-dependencies)...\033[0m"
336-
brew uninstall --ignore-dependencies python@3.12
337-
else
338-
echo -e "\033[31m> Aborting. Please manually correct your Python configuration.\033[0m"
339-
exit 1
340-
fi
341-
else
342-
brew uninstall --ignore-dependencies python@3.12
343-
fi
344-
fi
345-
if brew list --formula | grep -q "qt6"; then
346-
echo -e "\033[31m⚠️ WARNING: qt6 installation is found. Currently this does not work with ros2 jazzy."
347-
if [[ -z "$GITHUB_ACTIONS" ]]; then
348-
echo -e "💡 Do you want to remove it? (y/n)\033[0m"
349-
read -r response
350-
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
351-
echo -e "\033[36m> Removing qt6 (with ignore-dependencies)...\033[0m"
352-
brew uninstall --ignore-dependencies qt6
353-
else
354-
echo -e "\033[31m> Aborting. Please manually correct your Python configuration.\033[0m"
355-
exit 1
356-
fi
357-
else
358-
brew uninstall --ignore-dependencies qt6
359-
fi
360-
fi
361-
362306
# Set Environment Variables of Brew packages
363307
echo -e "\033[36m> Setting Environment Variables of Brew packages...(OPENSSL_ROOT_DIR, CMAKE_PREFIX_PATH, PATH)\033[0m"
364308
# shellcheck disable=SC2155
@@ -608,39 +552,21 @@ echo -e "\033[33mdeactivate\033[0m"
608552

609553
# Ask if user wants to install Gazebo Harmonic too (gz_install.sh)
610554
echo -e "\n\n\033[32mGazebo Harmonic is simulator that is LTS pair with ROS2 Jazzy\033[0m"
611-
# Type yes to continue or auto continue
555+
556+
# Trap SIGINT (Ctrl+C) and exit cleanly
557+
trap 'echo -e "\033[31m\nInstallation aborted.\033[0m"; exit' SIGINT
558+
559+
# Check if the script is running in a GitHub Actions workflow
612560
if [[ -z "$GITHUB_ACTIONS" ]]; then
613-
echo -e '\033[96m\n💡 Do you want to install Gazebo Harmonic too? [y/n]: \033[0m'
614-
# Start a background process for the countdown and automatic response
615-
(
616-
# Show a countdown for 10 seconds
617-
for i in {10..1}
618-
do
619-
# shellcheck disable=SC2059
620-
printf "\r Continuing in $i seconds..."
621-
sleep 1
622-
done
623-
624-
# Clear the line
625-
printf "\r"
626-
627-
# Send 'y'
628-
echo 'y'
629-
) &
630-
631-
# Save the PID of the background process and disown it
632-
bg_pid=$!
633-
disown $bg_pid
634-
635-
# Read the user's response in the foreground
636-
read -n 1 -r response
637-
638-
# If the user responded, kill the background process
639-
if [[ -n "$response" ]]; then
640-
kill "$bg_pid" >/dev/null 2>&1
641-
fi
561+
# Prompt the user and wait for a response with a timeout of 10 seconds
562+
echo -e '\033[96m\n💡 The installation will continue automatically in 10 seconds unless you respond. \033[0m'
563+
read -p $'\033[96m Do you want to proceed now? [y/n]: \033[0m' -n 1 -r -t 10 response
564+
echo # Move to a new line after the user input
565+
566+
# Default to 'y' if no response is given within the timeout
567+
response=${response:-y}
642568
else
643-
# If running in a GitHub Actions workflow, automatically set the response to 'y'
569+
# Automatically set the response to 'y' in a GitHub Actions workflow
644570
response='y'
645571
fi
646572

0 commit comments

Comments
 (0)