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

Refactor to reduce code duplication in SA build scripts #58

Merged
merged 3 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 48 additions & 0 deletions common_sa_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
set -xe

export SCRIPT_DIR=$(dirname ${DOCKER_BUILD_SCRIPT})

# Remove the old rosdep sources.list
rm -rf /etc/ros/rosdep/sources.list.d/*
rosdep init && rosdep update

. /opt/ros/$ROS_DISTRO/setup.sh

BUILD_DIR_NAME=`basename $TRAVIS_BUILD_DIR`

if [ -z "$WORKSPACES" ]; then
WORKSPACES="robot_ws simulation_ws"
fi

# Run ROSWS update in each workspace before creating archive
for WS in $WORKSPACES
do
WS_DIR="/${ROS_DISTRO}_ws/src/${BUILD_DIR_NAME}/${WS}"
echo "looking for ${WS}, $WS_DIR"
if [ -d "${WS_DIR}" ]; then
echo "WS ${WS_DIR} found, running rosws update"
rosws update -t "${WS_DIR}"
fi
done

# Create archive of all sources files
SOURCES_INCLUDES="${WORKSPACES} LICENSE* NOTICE* README* roboMakerSettings.json"
cd /${ROS_DISTRO}_ws/src/${BUILD_DIR_NAME}/
/usr/bin/zip -r /shared/sources.zip $SOURCES_INCLUDES
tar cvzf /shared/sources.tar.gz $SOURCES_INCLUDES

for WS in $WORKSPACES
do
# use colcon as build tool to build the workspace if it exists
WS_DIR="/${ROS_DISTRO}_ws/src/${BUILD_DIR_NAME}/${WS}"
WS_BUILD_SCRIPT="/shared/$(basename ${SCRIPT_DIR})/ws_builds/${WS}.sh"
if [ -f "${WS_BUILD_SCRIPT}" ]; then
cd "${WS_DIR}"
bash "${WS_BUILD_SCRIPT}"
mv ./bundle/output.tar /shared/"${WS}".tar
else
echo "Unable to find build script ${WS_BUILD_SCRIPT}, build failed"
exit 1
fi
done
45 changes: 2 additions & 43 deletions ros1_sa_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,5 @@ apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BAD
apt-get update && apt-get install --no-install-recommends -y python-rosdep python-rosinstall python3-colcon-common-extensions ros-$ROS_DISTRO-ros-base
pip3 install colcon-bundle colcon-ros-bundle

# Remove the old rosdep sources.list
rm -rf /etc/ros/rosdep/sources.list.d/*
rosdep init && rosdep update

. /opt/ros/$ROS_DISTRO/setup.sh

BUILD_DIR_NAME=`basename $TRAVIS_BUILD_DIR`

if [ -z "$WORKSPACES" ]; then
WORKSPACES="robot_ws simulation_ws"
fi

# Run ROSWS update in each workspace before creating archive
for WS in $WORKSPACES
do
WS_DIR="/${ROS_DISTRO}_ws/src/${BUILD_DIR_NAME}/${WS}"
echo "looking for ${WS}, $WS_DIR"
if [ -d "${WS_DIR}" ]; then
echo "WS ${WS_DIR} found, running rosws update"
rosws update -t "${WS_DIR}"
fi
done

# Create archive of all sources files
SOURCES_INCLUDES="${WORKSPACES} LICENSE* NOTICE* README* roboMakerSettings.json"
cd /${ROS_DISTRO}_ws/src/${BUILD_DIR_NAME}/
/usr/bin/zip -r /shared/sources.zip $SOURCES_INCLUDES
tar cvzf /shared/sources.tar.gz $SOURCES_INCLUDES

for WS in $WORKSPACES
do
# use colcon as build tool to build the workspace if it exists
WS_DIR="/${ROS_DISTRO}_ws/src/${BUILD_DIR_NAME}/${WS}"
WS_BUILD_SCRIPT="/shared/$(basename ${SCRIPT_DIR})/ws_builds/${WS}.sh"
if [ -f "${WS_BUILD_SCRIPT}" ]; then
cd "${WS_DIR}"
"${WS_BUILD_SCRIPT}"
mv ./bundle/output.tar /shared/"${WS}".tar
else
echo "Unable to find build script ${WS_BUILD_SCRIPT}, build failed"
exit 1
fi
done
COMMON_SA_BUILD_SCRIPT=${SCRIPT_DIR}/common_sa_build.sh
. "${COMMON_SA_BUILD_SCRIPT}"
45 changes: 2 additions & 43 deletions ros2_sa_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,5 @@ pip3 install --upgrade pip
pip install -U --editable "${COLCON_BUNDLE_INSTALL_PATH}"
pip install -U --editable "${COLCON_ROS_BUNDLE_INSTALL_PATH}"

# Remove the old rosdep sources.list
rm -rf /etc/ros/rosdep/sources.list.d/*
rosdep init && rosdep update

. /opt/ros/$ROS_DISTRO/setup.sh

BUILD_DIR_NAME=`basename $TRAVIS_BUILD_DIR`

if [ -z "$WORKSPACES" ]; then
WORKSPACES="robot_ws simulation_ws"
fi

# Run ROSWS update in each workspace before creating archive
for WS in $WORKSPACES
do
WS_DIR="/${ROS_DISTRO}_ws/src/${BUILD_DIR_NAME}/${WS}"
echo "looking for ${WS}, $WS_DIR"
if [ -d "${WS_DIR}" ]; then
echo "WS ${WS_DIR} found, running rosws update"
rosws update -t "${WS_DIR}"
fi
done

# Create archive of all sources files
SOURCES_INCLUDES="${WORKSPACES} LICENSE* NOTICE* README* roboMakerSettings.json"
cd /${ROS_DISTRO}_ws/src/${BUILD_DIR_NAME}/
/usr/bin/zip -r /shared/sources.zip $SOURCES_INCLUDES
tar cvzf /shared/sources.tar.gz $SOURCES_INCLUDES

for WS in $WORKSPACES
do
# use colcon as build tool to build the workspace if it exists
WS_DIR="/${ROS_DISTRO}_ws/src/${BUILD_DIR_NAME}/${WS}"
WS_BUILD_SCRIPT="/shared/$(basename ${SCRIPT_DIR})/ws_builds/${WS}.sh"
if [ -f "${WS_BUILD_SCRIPT}" ]; then
cd "${WS_DIR}"
bash "${WS_BUILD_SCRIPT}"
mv ./bundle/output.tar /shared/"${WS}".tar
else
echo "Unable to find build script ${WS_BUILD_SCRIPT}, build failed"
exit 1
fi
done
COMMON_SA_BUILD_SCRIPT=${SCRIPT_DIR}/common_sa_build.sh
. "${COMMON_SA_BUILD_SCRIPT}"