-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathros-install-this
executable file
·70 lines (53 loc) · 1.73 KB
/
ros-install-this
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
#!/bin/bash
# Directly installs a single ROS package from the package directory
# to ROS_ROOT without needing to manually create a catkin workspace.
# Example usage:
# $ source /opt/ros/kinetic/setup.bash
# $ ./ros-install-this
if [ -z $ROS_DISTRO ]; then
echo "Error: ROS_DISTRO is not set. Did you source setup.bash?"
exit;
fi
if [ -z $ROS_VERSION ]; then
echo "Error: ROS_VERSION is not set. Did you source setup.bash?"
exit;
fi
if [ ! -f 'package.xml' ]; then
echo "Error: No package.xml found. The current directory does not appear to be a ROS package."
exit;
fi
PACKAGE_NAME=`cat package.xml |grep '<name>' | sed -e 's/^.*<name>\(.*\)<\/name>.*$/\1/'`
if [ -z $PACKAGE_NAME ]; then
echo "Error: Cannot determine name from package.xml. Is package.xml properly written?"
exit;
fi
ROS_REAL_ROOT=`echo $ROS_ROOT | sed -e s/\\\\/share\\\\/ros//`
if [ -z $ROS_REAL_ROOT ]; then
echo "Error: Cannot determine real root."
exit;
fi
TEMP_DIR=$(mktemp -d /tmp/ros-install-this.XXXXXX)
if [ -z $TEMP_DIR ]; then
echo "Error: Error creating temporary dir."
exit;
fi
echo "Building ..."
mkdir -p $TEMP_DIR/src/
cp -rv . $TEMP_DIR/src/$PACKAGE_NAME
source $ROS_REAL_ROOT/setup.bash
cd $TEMP_DIR/src/
catkin_init_workspace
cd $TEMP_DIR/
if [ $ROS_DISTRO == "noetic" ]; then
catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3
else
catkin_make
fi
echo
echo "You may be now be asked for your sudo password to complete installation."
echo "Installation target is: $ROS_REAL_ROOT"
echo
sudo bash -c "source $ROS_REAL_ROOT/setup.bash; catkin_make install -DCMAKE_INSTALL_PREFIX=$ROS_REAL_ROOT"
# Done in 2 steps to avoid running the "rm -rf" part as root
sudo chmod -R 777 $TEMP_DIR/devel $TEMP_DIR/build $TEMP_DIR/src
rm -rf $TEMP_DIR