Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merge after #1630] [jsk_robot_startup] Add dryrun option of update_workspace.sh #1817

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
47229cc
[jsk_fetch_startup] catkin clean libcmt before build in daily update_…
708yamaguchi Jan 6, 2022
3b1ece3
[jsk_fetch_startup] update workspace script
sktometometo Apr 15, 2022
d3e71f4
[jsk_fetch_startup] remove redundant section
sktometometo Apr 16, 2022
76902ec
[jsk_fetch_startup] parameterize workspace path and make it as argument
sktometometo Apr 18, 2022
d29bdcc
[jsk_fetch_startup] update update_workspace.sh
sktometometo Apr 18, 2022
8895df7
[jsk_fetch_startup] update workspace script
sktometometo Apr 19, 2022
2e1ae63
[jsk_fetch_startup] fix default workspace path
sktometometo Apr 20, 2022
4dc8e6f
[jsk_fetch_startup] rename update_workspace.sh to update_workspace_ma…
sktometometo Apr 27, 2022
fd99ccb
[jsk_fetch_startup] remove /tmp/update_workspace.sh after updating
sktometometo Jul 4, 2022
6c3868a
[jsk_fetch_startup] fix mailbody in update_workspace script
sktometometo Sep 15, 2022
df50343
[jsk_fetch_startup] fix mailbody in update_workspace script
sktometometo Sep 15, 2022
3d1bc2d
[jsk_fetch_startup] Fix email body topic by jsk_robot_startup/EmailBody
tkmtnt7000 Sep 15, 2022
0dc833f
[jsk_fetch_startup] add comment to update_workspace_main.sh
sktometometo Sep 18, 2022
92110dd
[jsk_fetch_startup, jsk_robot_startup] move update_workspace_main.sh …
knorth55 Sep 30, 2022
30718a4
[jsk_pr2_startup] add update_workspace.sh for pr2
knorth55 Sep 30, 2022
2af223e
[jsk_robot_startup] add option to disable rosdep install
knorth55 Sep 30, 2022
8072f78
[jsk_pr2_startup] do not run rosdep in pr2
knorth55 Sep 30, 2022
814e79e
Apply suggestions from code review
knorth55 Sep 30, 2022
830e408
[jsk_robot_startup] fix typo in update_workspace_main.sh
knorth55 Sep 30, 2022
4860e90
[jsk_robot_startup] Change order of git stash and git fetch
tkmtnt7000 Jun 15, 2023
594fab5
[jsk_robot_startup] Add dry run option not to update forcefully
tkmtnt7000 Jun 15, 2023
5bd2922
[jsk_robot_startup] Show wstool status to mail body
tkmtnt7000 Jun 15, 2023
c3bafb6
[jsk_robot_startup] Escape single quote, double quote, and comma, whi…
tkmtnt7000 Jun 19, 2023
f41cebf
[jsk_robot_startup] Use html to change line at mail body
tkmtnt7000 Jun 19, 2023
f22c5c8
[jsk_robot_startup] Use bold to easy to read mail text
tkmtnt7000 Jun 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 7 additions & 41 deletions jsk_fetch_robot/jsk_fetch_startup/scripts/update_workspace.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,9 @@
#!/usr/bin/env bash

. $HOME/ros/melodic/devel/setup.bash
# Filename should end with .txt to preview the contents in a web browser
LOGFILE=$HOME/ros/melodic/update_workspace.txt

{
set -x
# Update workspace
cd $HOME/ros/melodic/src
ln -sf $(rospack find jsk_fetch_startup)/../jsk_fetch.rosinstall.$ROS_DISTRO $HOME/ros/melodic/src/.rosinstall
wstool foreach --git 'git stash'
wstool update --delete-changed-uris
WSTOOL_UPDATE_RESULT=$?
cd $HOME/ros/melodic
catkin clean aques_talk collada_urdf_jsk_patch -y
catkin init
catkin config -DCMAKE_BUILD_TYPE=Release
catkin build
CATKIN_BUILD_RESULT=$?
# Send mail
MAIL_BODY=""
if [ $WSTOOL_UPDATE_RESULT -ne 0 ]; then
MAIL_BODY=$MAIL_BODY"Please wstool update workspace manually. "
fi
if [ $CATKIN_BUILD_RESULT -ne 0 ]; then
MAIL_BODY=$MAIL_BODY"Please catkin build workspace manually."
fi
set +x
} > $LOGFILE 2>&1
if [ -n "$MAIL_BODY" ]; then
rostopic pub -1 /email jsk_robot_startup/Email "header:
seq: 0
stamp: {secs: 0, nsecs: 0}
frame_id: ''
subject: 'Daily workspace update fails'
body: '$MAIL_BODY'
sender_address: '$(hostname)@jsk.imi.i.u-tokyo.ac.jp'
receiver_address: 'fetch@jsk.imi.i.u-tokyo.ac.jp'
smtp_server: ''
smtp_port: ''
attached_files: ['$LOGFILE']"
fi
cp $(rospack find jsk_robot_startup)/scripts/update_workspace_main.sh /tmp/update_workspace.sh
# jsk_footstep_planner is not released for melodic
# jsk_footstep_controller is not released for melodic
# librealsense2 should not be installed from ROS repository
# realsense-ros should not be installed from ROS repository
/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"
rm /tmp/update_workspace.sh
5 changes: 5 additions & 0 deletions jsk_pr2_robot/jsk_pr2_startup/scripts/update_workspace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

cp $(rospack find jsk_robot_startup)/scripts/update_workspace_main.sh /tmp/update_workspace.sh
/tmp/update_workspace.sh -w $HOME/ros/indigo -r $(rospack find jsk_pr2_startup)/jsk_pr2.rosinstall -t pr2 -u
rm /tmp/update_workspace.sh
157 changes: 157 additions & 0 deletions jsk_robot_common/jsk_robot_startup/scripts/update_workspace_main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#!/usr/bin/env bash

function usage()
{
echo "Usage: $0 [-w workspace_directory] [-r rosinstall_path] [-t robot_type] [-s skip keys] [-h] [-u] [-l] [-n]

optional arguments:
-h show this help
-w WORKSPACE_PATH specify target workspace
-r ROSINTALL_PATH rosinstall path
-t ROBOT robot type
-s SKIP_KEYS rosdep install skip keys
-u do not run apt-get upgrade and rosdep install
-l do not send a mail
-n do not update workspace, only show wstool status
"
}

function get_full_path()
{
echo "$(cd $(dirname $1) && pwd)/$(basename $1)"
}

ROSDEP_INSTALL=true
SEND_MAIL=true
UPDATE_WORKSPACE=true
WORKSPACE=$(get_full_path $HOME/ros/$ROS_DISTRO)

while getopts w:r:t:s:ulnh OPT
do
case $OPT in
w)
WORKSPACE=$(get_full_path $OPTARG)
;;
r)
ROSINSTALL=$(get_full_path $OPTARG)
;;
t)
ROBOT_TYPE=$OPTARG
;;
s)
SKIP_KEYS=$OPTARG
;;
u)
ROSDEP_INSTALL=false
;;
l)
SEND_MAIL=false
;;
n)
UPDATE_WORKSPACE=false
;;
h)
usage
exit 1
;;
*)
usage
exit 1
;;
esac
done

if [ "$WORKSPACE" = "" ]; then
echo "Please set valid workspace -w $WORKSPACE<br>"
exit 1
fi
if [ "$ROSINSTALL" = "" ]; then
echo "Please set valid rosinstall -r $ROSINSTALL<br>"
exit 1
fi
if [ "$ROBOT_TYPE" = "" ]; then
echo "Please set valid robot type -t $ROBOT_TYPE<br>"
exit 1
fi


. $WORKSPACE/devel/setup.bash
# Filename should end with .txt to preview the contents in a web browser
LOGFILE=$WORKSPACE/update_workspace.txt

TMP_MAIL_BODY_FILE=/tmp/update_workspace_mailbody.txt

{
set -x
# Update workspace
echo "" > $TMP_MAIL_BODY_FILE
wstool foreach -t $WORKSPACE/src --git 'git fetch origin --prune'
WSTOOL_STATUS=$(wstool status -t $WORKSPACE/src)
if [ -n "$WSTOOL_STATUS" ]; then
echo -e "<b>Please commit robot internal change and send pull request.</b><br><br>" >> $TMP_MAIL_BODY_FILE
echo -e $WSTOOL_STATUS >> $TMP_MAIL_BODY_FILE
# escape " ' , -- and add change line code to end of line
wstool diff -t $WORKSPACE/src | sed -e "s/'/ /g" -e "s/^--/ /g" -e 's/"/ /g' -e "s/<br>/\\\n/" -e 's/$/<br>/g' -e "s/,/ /g" | tee -a $TMP_MAIL_BODY_FILE
fi
if [ "${UPDATE_WORKSPACE}" == "true" ]; then
wstool foreach -t $WORKSPACE/src --git 'git stash'
wstool update -t $WORKSPACE/src jsk-ros-pkg/jsk_robot --delete-changed-uris
ln -sf $ROSINSTALL $WORKSPACE/src/.rosinstall
wstool update -t $WORKSPACE/src --delete-changed-uris
# Forcefully checkout specified branch
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'
wstool update -t $WORKSPACE/src
WSTOOL_UPDATE_RESULT=$?
else
WSTOOL_UPDATE_RESULT=0
fi
# Rosdep Install
if [ "${ROSDEP_INSTALL}" == "true" ]; then
sudo apt-get update -y;
rosdep update;
rosdep install --from-paths $WORKSPACE/src --ignore-src -y -r --skip-keys "$SKIP_KEYS";
ROSDEP_INSTALL_RESULT=$?;
else
ROSDEP_INSTALL_RESULT=0;
fi
# Build workspace
cd $WORKSPACE
catkin clean aques_talk collada_urdf_jsk_patch libcmt -y
catkin init
catkin config -DCMAKE_BUILD_TYPE=Release
catkin build --continue-on-failure
CATKIN_BUILD_RESULT=$?
# Send mail
if [ $WSTOOL_UPDATE_RESULT -ne 0 ]; then
echo "<b>Please wstool update workspace manually.</b><br>" >> $TMP_MAIL_BODY_FILE
fi
if [ $ROSDEP_INSTALL_RESULT -ne 0 ]; then
echo "<b>Please install dependencies manually.</b><br>" >> $TMP_MAIL_BODY_FILE
fi
if [ $CATKIN_BUILD_RESULT -ne 0 ]; then
echo "<b>Please catkin build workspace manually.</b><br>" >> $TMP_MAIL_BODY_FILE
fi
set +x
} 2>&1 | tee $LOGFILE

# MAIL_BODY variable cannot be set directly in a subshell. So it is set from temporary mail body text file.
# The mail body text is put as $TMP_MAIL_BODY_FILE.
# See https://github.com/jsk-ros-pkg/jsk_robot/issues/1569
MAIL_BODY=$(cat $TMP_MAIL_BODY_FILE)
echo "MAIL_BODY: $MAIL_BODY"

if [ -n "$MAIL_BODY" ] && [ "${SEND_MAIL}" == "true" ]; then
echo "Sent a mail"
rostopic pub -1 /email jsk_robot_startup/Email "header:
seq: 0
stamp: {secs: 0, nsecs: 0}
frame_id: ''
subject: 'Daily workspace update fails'
body:
- {type: 'html', message: '${MAIL_BODY}', file_path: '', img_data: '', img_size: 0}
sender_address: '$(hostname)@jsk.imi.i.u-tokyo.ac.jp'
receiver_address: '$ROBOT_TYPE@jsk.imi.i.u-tokyo.ac.jp'
smtp_server: ''
smtp_port: ''
attached_files: ['$LOGFILE']"
fi
Loading