Skip to content

Commit 7a33ddb

Browse files
authored
Merge pull request #1630 from knorth55/common-update-workspace
[jsk_robot_startup] use update_workspace.sh for nightly workspace build in both PR2 and Fetch
2 parents 1acfa89 + 7ada0eb commit 7a33ddb

3 files changed

Lines changed: 154 additions & 41 deletions

File tree

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,9 @@
11
#!/usr/bin/env bash
22

3-
. $HOME/ros/melodic/devel/setup.bash
4-
# Filename should end with .txt to preview the contents in a web browser
5-
LOGFILE=$HOME/ros/melodic/update_workspace.txt
6-
7-
{
8-
set -x
9-
# Update workspace
10-
cd $HOME/ros/melodic/src
11-
ln -sf $(rospack find jsk_fetch_startup)/../jsk_fetch.rosinstall.$ROS_DISTRO $HOME/ros/melodic/src/.rosinstall
12-
wstool foreach --git 'git stash'
13-
wstool update --delete-changed-uris
14-
WSTOOL_UPDATE_RESULT=$?
15-
cd $HOME/ros/melodic
16-
catkin clean aques_talk collada_urdf_jsk_patch -y
17-
catkin init
18-
catkin config -DCMAKE_BUILD_TYPE=Release
19-
catkin build
20-
CATKIN_BUILD_RESULT=$?
21-
# Send mail
22-
MAIL_BODY=""
23-
if [ $WSTOOL_UPDATE_RESULT -ne 0 ]; then
24-
MAIL_BODY=$MAIL_BODY"Please wstool update workspace manually. "
25-
fi
26-
if [ $CATKIN_BUILD_RESULT -ne 0 ]; then
27-
MAIL_BODY=$MAIL_BODY"Please catkin build workspace manually."
28-
fi
29-
set +x
30-
} > $LOGFILE 2>&1
31-
if [ -n "$MAIL_BODY" ]; then
32-
rostopic pub -1 /email jsk_robot_startup/Email "header:
33-
seq: 0
34-
stamp: {secs: 0, nsecs: 0}
35-
frame_id: ''
36-
subject: 'Daily workspace update fails'
37-
body: '$MAIL_BODY'
38-
sender_address: '$(hostname)@jsk.imi.i.u-tokyo.ac.jp'
39-
receiver_address: 'fetch@jsk.imi.i.u-tokyo.ac.jp'
40-
smtp_server: ''
41-
smtp_port: ''
42-
attached_files: ['$LOGFILE']"
43-
fi
3+
cp $(rospack find jsk_robot_startup)/scripts/update_workspace_main.sh /tmp/update_workspace.sh
4+
# jsk_footstep_planner is not released for melodic
5+
# jsk_footstep_controller is not released for melodic
6+
# librealsense2 should not be installed from ROS repository
7+
# realsense-ros should not be installed from ROS repository
8+
/tmp/update_workspace.sh -r $(rospack find jsk_fetch_startup)/../jsk_fetch.rosinstall.$ROS_DISTRO -t fetch -s "jsk_footstep_controller jsk_footstep_planner librealsense2 realsense2_camera realsense2_description"
9+
rm /tmp/update_workspace.sh
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
cp $(rospack find jsk_robot_startup)/scripts/update_workspace_main.sh /tmp/update_workspace.sh
4+
/tmp/update_workspace.sh -w $HOME/ros/indigo -r $(rospack find jsk_pr2_startup)/jsk_pr2.rosinstall -t pr2 -u
5+
rm /tmp/update_workspace.sh
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#!/usr/bin/env bash
2+
3+
function usage()
4+
{
5+
echo "Usage: $0 [-w workspace_directory] [-r rosinstall_path] [-t robot_type] [-s skip keys] [-h] [-u] [-l]
6+
7+
optional arguments:
8+
-h show this help
9+
-w WORKSPACE_PATH specify target workspace
10+
-r ROSINTALL_PATH rosinstall path
11+
-t ROBOT robot type
12+
-s SKIP_KEYS rosdep install skip keys
13+
-u do not run apt-get upgrade and rosdep install
14+
-l do not send a mail
15+
"
16+
}
17+
18+
function get_full_path()
19+
{
20+
echo "$(cd $(dirname $1) && pwd)/$(basename $1)"
21+
}
22+
23+
ROSDEP_INSTALL=true
24+
SEND_MAIL=true
25+
WORKSPACE=$(get_full_path $HOME/ros/$ROS_DISTRO)
26+
27+
while getopts w:r:t:s:ulh OPT
28+
do
29+
case $OPT in
30+
w)
31+
WORKSPACE=$(get_full_path $OPTARG)
32+
;;
33+
r)
34+
ROSINSTALL=$(get_full_path $OPTARG)
35+
;;
36+
t)
37+
ROBOT_TYPE=$OPTARG
38+
;;
39+
s)
40+
SKIP_KEYS=$OPTARG
41+
;;
42+
u)
43+
ROSDEP_INSTALL=false
44+
;;
45+
l)
46+
SEND_MAIL=false
47+
;;
48+
h)
49+
usage
50+
exit 1
51+
;;
52+
*)
53+
usage
54+
exit 1
55+
;;
56+
esac
57+
done
58+
59+
if [ "$WORKSPACE" = "" ]; then
60+
echo "Please set valid workspace -w $WORKSPACE"
61+
exit 1
62+
fi
63+
if [ "$ROSINSTALL" = "" ]; then
64+
echo "Please set valid rosinstall -r $ROSINSTALL"
65+
exit 1
66+
fi
67+
if [ "$ROBOT_TYPE" = "" ]; then
68+
echo "Please set valid robot type -t $ROBOT_TYPE"
69+
exit 1
70+
fi
71+
72+
73+
. $WORKSPACE/devel/setup.bash
74+
# Filename should end with .txt to preview the contents in a web browser
75+
LOGFILE=$WORKSPACE/update_workspace.txt
76+
77+
TMP_MAIL_BODY_FILE=/tmp/update_workspace_mailbody.txt
78+
79+
{
80+
set -x
81+
# Update workspace
82+
83+
wstool foreach -t $WORKSPACE/src --git 'git stash'
84+
wstool foreach -t $WORKSPACE/src --git 'git fetch origin --prune'
85+
wstool update -t $WORKSPACE/src jsk-ros-pkg/jsk_robot --delete-changed-uris
86+
ln -sf $ROSINSTALL $WORKSPACE/src/.rosinstall
87+
wstool update -t $WORKSPACE/src --delete-changed-uris
88+
# Forcefully checkout specified branch
89+
wstool foreach -t $WORKSPACE/src --git --shell 'branchname=$(git rev-parse --abbrev-ref HEAD); if [ $branchname != "HEAD" ]; then git reset --hard HEAD; git checkout origin/$branchname; git branch -D $branchname; git checkout -b $branchname --track origin/$branchname; fi'
90+
wstool update -t $WORKSPACE/src
91+
WSTOOL_UPDATE_RESULT=$?
92+
# Rosdep Install
93+
if [ "${ROSDEP_INSTALL}" == "true" ]; then
94+
sudo apt-get update -y;
95+
rosdep update;
96+
rosdep install --from-paths $WORKSPACE/src --ignore-src -y -r --skip-keys "$SKIP_KEYS";
97+
ROSDEP_INSTALL_RESULT=$?;
98+
else
99+
ROSDEP_INSTALL_RESULT=0;
100+
fi
101+
# Build workspace
102+
cd $WORKSPACE
103+
catkin clean aques_talk collada_urdf_jsk_patch libcmt -y
104+
catkin init
105+
catkin config -DCMAKE_BUILD_TYPE=Release
106+
catkin build --continue-on-failure
107+
CATKIN_BUILD_RESULT=$?
108+
# Send mail
109+
echo "" > $TMP_MAIL_BODY_FILE
110+
if [ $WSTOOL_UPDATE_RESULT -ne 0 ]; then
111+
echo "Please wstool update workspace manually.\n" >> $TMP_MAIL_BODY_FILE
112+
fi
113+
if [ $ROSDEP_INSTALL_RESULT -ne 0 ]; then
114+
echo "Please install dependencies manually.\n" >> $TMP_MAIL_BODY_FILE
115+
fi
116+
if [ $CATKIN_BUILD_RESULT -ne 0 ]; then
117+
echo "Please catkin build workspace manually.\n" >> $TMP_MAIL_BODY_FILE
118+
fi
119+
set +x
120+
} 2>&1 | tee $LOGFILE
121+
122+
# MAIL_BODY variable cannot be set directly in a subshell. So it is set from temporary mail body text file.
123+
# The mail body text is put as $TMP_MAIL_BODY_FILE.
124+
# See https://github.com/jsk-ros-pkg/jsk_robot/issues/1569
125+
MAIL_BODY=$(cat $TMP_MAIL_BODY_FILE)
126+
echo "MAIL_BODY: $MAIL_BODY"
127+
128+
if [ -n "$MAIL_BODY" ] && [ "${SEND_MAIL}" == "true" ]; then
129+
echo "Sent a mail"
130+
rostopic pub -1 /email jsk_robot_startup/Email "header:
131+
seq: 0
132+
stamp: {secs: 0, nsecs: 0}
133+
frame_id: ''
134+
subject: 'Daily workspace update fails'
135+
body:
136+
- {type: 'text', message: '${MAIL_BODY}', file_path: '', img_data: '', img_size: 0}
137+
sender_address: '$(hostname)@jsk.imi.i.u-tokyo.ac.jp'
138+
receiver_address: '$ROBOT_TYPE@jsk.imi.i.u-tokyo.ac.jp'
139+
smtp_server: ''
140+
smtp_port: ''
141+
attached_files: ['$LOGFILE']"
142+
fi

0 commit comments

Comments
 (0)