Skip to content

Commit

Permalink
feat(template_ws): Perform apt-get update and rosdep update in `.…
Browse files Browse the repository at this point in the history
…bashrc`, Remove redundant `postCreateCommand.sh`
  • Loading branch information
j3soon committed Aug 20, 2024
1 parent 2b509a7 commit afdb58c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 1 addition & 3 deletions template_ws/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,5 @@
"ms-iot.vscode-ros"
]
}
},
// Lifecycle scripts
"postCreateCommand": "${containerWorkspaceFolder}/.devcontainer/postCreateCommand.sh"
}
}
6 changes: 0 additions & 6 deletions template_ws/.devcontainer/postCreateCommand.sh

This file was deleted.

15 changes: 14 additions & 1 deletion template_ws/docker/.bashrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# Source global ROS2 environment
source /opt/ros/$ROS_DISTRO/setup.bash
# Check if the workspace has been built by check install/setup.bash
# Optionally perform apt update if it has not been executed yet
if [ -z "$( ls -A '/var/lib/apt/lists' )" ]; then
echo "apt-get update has not been executed yet. Running sudo apt-get update..."
sudo apt-get update
fi
# Optionally perform rosdep update if it has not been executed yet
if [ ! -d $HOME/.ros/rosdep/sources.cache ]; then
echo "rosdep update has not been executed yet. Running rosdep update..."
rosdep update
fi
# Optionally build the workspace if it has not been built yet
if [ ! -f $ROS2_WS/install/setup.bash ]; then
echo "Workspace has not been built yet. Building workspace..."
cd $ROS2_WS
# Ref: https://docs.ros.org/en/humble/Tutorials/Intermediate/Rosdep.html
rosdep install --from-paths src --ignore-src -y
# TODO: If command `arch` outputs `aarch64`, consider adding `--packages-ignore <package>` to ignore x86 packages
# Ref: https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html
if [ $(arch) == "aarch64" ]; then
colcon build --symlink-install
else
Expand Down

0 comments on commit afdb58c

Please sign in to comment.