Commit 9a048608 authored by Tomas Petricek's avatar Tomas Petricek
Browse files

Setup script refactored, adding bootstrap rosinstall param.

parent 32cfd751
......@@ -2,45 +2,85 @@
set -e
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Parse arguments.
usage="Setup robolab catkin workspace at specified directory.
Usage:
setup_catkin_workspace <workspace>
setup_catkin_workspace [<workspace>]
Options (environmental variables):
- extend: Workspace to extend.
- ros: ROS distribution (kinetic/melodic).
- extend: Workspace to extend.
- ros: ROS distribution (kinetic/melodic).
- rosinstall: Workspace rosinstall files.
"
[ "$#" -gt 1 ] && echo 'ERROR: Invalid number of arguments.' && echo && echo "$usage" && exit 1
# Parse arguments.
if [ "$#" -gt 1 ]; then
echo 'ERROR: Invalid number of arguments.'
echo
echo "${usage}"
exit 1
fi
# Workspace
if [ "$#" -eq 1 ]; then
ws="$1"
fi
if [ ! "${ws}" ]; then
ws="$(pwd)"
fi
if [ ! "${ws}" ]; then
echo 'ERROR: Workspace not specified.'
exit 2
fi
ws=$(realpath "${ws}")
echo "Workspace: ${ws}"
[ "$#" -ge 1 ] && ws="$1"
[ ! "$ws" ] && ws="$(pwd)"
[ ! "$ws" ] && echo 'ERROR: Workspace not specified.' && exit 2
ws=$(realpath "$ws")
# ROS distribution
if [ ! "${ros}" ] && [ -d /opt/ros/melodic ]; then
ros=melodic
fi
if [ ! "${ros}" ] && [ -d /opt/ros/kinetic ]; then
ros=kinetic
fi
if [ ! "${ros}" ]; then
echo 'ERROR: No ROS distribution found.'
exit 3
fi
echo "ROS distribution: ${ros}"
[ ! "$ros" ] && [ -d /opt/ros/melodic ] && ros=melodic
[ ! "$ros" ] && [ -d /opt/ros/kinetic ] && ros=kinetic
[ ! "$ros" ] && echo 'ERROR: No ROS distribution found.' && exit 3
# Extended workspace
if [ ! "${extend}" ]; then
extend=/opt/ros/$ros
fi
extend=$(realpath "${extend}")
if [ ! "${extend}" ]; then
echo 'ERROR: Extended workspace not specified.'
exit 4
fi
echo "Extended workspace: ${extend}"
[ ! "$extend" ] && extend=/opt/ros/$ros
extend=$(realpath "$extend")
[ ! "$extend" ] && echo 'ERROR: Extended workspace not specified.' && exit 3
# Workspace rosinstall files
if [ ! "${rosinstall}" ]; then
rosinstall="${dir}/../rosinstall/robolab.rosinstall ${dir}/../rosinstall/robolab_${ros}.rosinstall"
fi
if [ ! "${rosinstall}" ]; then
echo 'ERROR: Workspace configuration rosinstall files not specified.'
exit 5
fi
echo "Workspace rosinstall files: ${rosinstall}"
# Clone main repositories from rosinstall files.
mkdir -p $ws/src
cd "$ws/src"
# Configure main repositories from provided rosinstall files.
mkdir -p ${ws}/src
cd "${ws}/src"
wstool init
# Keep first entry with given key (-k).
# Make sure there are no duplicates in these curated lists.
wstool merge -k "$dir/../rosinstall/robolab.rosinstall"
wstool merge -k "$dir/../rosinstall/robolab_$ros.rosinstall"
wstool merge -k ${rosinstall}
wstool up -j 8
# Initialize, configure, and build catkin workspace.
cd $ws
cd ${ws}
catkin init
catkin config --extend "$extend"
catkin config --extend "${extend}"
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release
catkin build -c
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment