This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
forked from uf-mil/SubjuGator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·139 lines (115 loc) · 4.33 KB
/
install.sh
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
#!/bin/bash
GOODCOLOR='\033[1;36m'
WARNCOLOR='\033[1;31m'
NOCOLOR='\033[0m'
GOODPREFIX="${GOODCOLOR}INSTALLER:"
WARNPREFIX="${WARNCOLOR}ERROR:"
# Sane installation defaults for no argument cases
CATKIN_DIR=~/sub_ws
REQUIRED_OS="trusty"
instlog() {
printf "$GOODPREFIX $@ $NOCOLOR\n"
}
instwarn() {
printf "$WARNPREFIX $@ $NOCOLOR\n"
}
DTETCTED_OS="`lsb_release -sc`"
if ([ $DTETCTED_OS != $REQUIRED_OS ]); then
instwarn "The Sub requires Ubuntu 14.04 (trusty)"
instwarn "Terminating installation due to incorrect OS (detected $DTETCTED_OS)"
exit 1
fi
#======================#
# Script Configuration #
#======================#
while [ "$#" -gt 0 ]; do
case $1 in
-h) printf "\nUsage: $0 \n
[-c] catkin_workspace (Recommend: ~/sub_ws)\n
example: ./install.sh -c ~/sub_ws
\n"; exit ;;
# TODO: Use this to check if catkin ws already set up
-c) CATKIN_DIR="$2"
shift 2;;
-?) instwarn "Option $1 is not implemented"; exit ;;
esac
done
#==================================#
# Repository and Dependancy Set Up #
#==================================#
# Make sure script dependencies are installed on bare bones installations
instlog "Installing install script dependencies"
sudo apt-get update -qq
sudo apt-get install -qq wget git
# Add software repositories for ROS and Gazebo
instlog "Adding ROS and Gazebo PPAs to software sources"
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list'
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu trusty main" > /etc/apt/sources.list.d/gazebo-latest.list'
# Get the GPG signing keys for the above repositories
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-key 0xB01FA116
# Install ROS and other project dependencies
instlog "Installing ROS and Gazebo"
sudo apt-get update -qq
if (env | grep --quiet "SUB=true"); then
sudo apt-get install -qq ros-indigo-desktop-full
else
sudo apt-get install -qq ros-indigo-desktop
fi
sudo apt-get install -qq python-catkin-pkg python-rosdep gazebo7
# Sources ROS configurations for bash on this user account
source /opt/ros/indigo/setup.bash
if !(cat ~/.bashrc | grep --quiet "source /opt/ros"); then
echo "" >> ~/.bashrc
echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
fi
# Get information about ROS versions
instlog "Initializing ROS"
if !([ -f /etc/ros/rosdep/sources.list.d/20-default.list ]); then
sudo rosdep init > /dev/null 2>&1
fi
rosdep update
#=====================================#
# Workspace and Sub Repository Set Up #
#=====================================#
# Set up catkin workspace directory
if !([ -f $CATKIN_DIR/src/CMakeLists.txt ]); then
instlog "Generating catkin workspace at $CATKIN_DIR"
mkdir -p "$CATKIN_DIR/src"
cd "$CATKIN_DIR/src"
catkin_init_workspace
catkin_make -C "$CATKIN_DIR"
else
instlog "Using existing catkin workspace at $CATKIN_DIR"
fi
# If we're in the Semaphore-ci, we should run catkin_make in the actual build thread
if (env | grep --quiet "SEMAPHORE=true"); then
mv ~/Sub8 "$CATKIN_DIR/src"
fi
# Sources the workspace's configurations for bash on this user account
source "$CATKIN_DIR/devel/setup.bash"
if !(cat ~/.bashrc | grep --quiet "source $CATKIN_DIR/devel/setup.bash"); then
echo "source $CATKIN_DIR/devel/setup.bash" >> ~/.bashrc
fi
# Check if the sub is set up; if it isn't, set it up
if !(ls "$CATKIN_DIR/src" | grep --quiet "Sub8"); then
instlog "Looks like you don't have the sub set up, let's do that"
cd "$CATKIN_DIR/src"
git clone -q https://github.com/uf-mil/Sub8.git
cd Sub8
git remote rename origin upstream
instlog "Make sure you change your git to point to your own fork! (git remote add origin your_forks_url)"
fi
# Update the hosts file if necessary
if (env | grep --quiet "SUB=true"); then
$CATKIN_DIR/src/Sub8/scripts/update-hosts.bash
fi
# Install external dependencies with another script
instlog "Running the get_dependencies.sh script to update external dependencies"
cd $CATKIN_DIR/src
$CATKIN_DIR/src/Sub8/scripts/get_dependencies.sh
# Attempt to build the sub from scratch on client machines
if !(env | grep --quiet "SEMAPHORE=true"); then
instlog "Building the sub's software stack with catkin_make"
catkin_make -C "$CATKIN_DIR" -j8
fi