Skip to content

Instantly share code, notes, and snippets.

@dhood
Created September 14, 2016 23:48
Show Gist options
  • Save dhood/fed558e40977f971c8dea03dbc0d1168 to your computer and use it in GitHub Desktop.
Save dhood/fed558e40977f971c8dea03dbc0d1168 to your computer and use it in GitHub Desktop.
# Maintaining a Source Checkout
If you have installed ROS 2 from source, there may have been changes made to the source code since the time that you checked it out.
To keep your source checkout up to date, you will have to periodically update your `ros2.repos` file, download the latest sources, and rebuild your workspace.
## Update your `ros2.repos` file
To download the `ros2.repos` file from the latest ROS 2 release, run:
```
cd ~/ros2_ws
mv -i ros2.repos ros2.repos.old
wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
```
If you wish to checkout a particular release, you can get its repos file by specifying the name of the release in the url of the previous step, e.g. for alpha 7:
```
wget https://raw.githubusercontent.com/ros2/ros2/release-alpha7/ros2.repos
```
The format of the name of the release comes from the name of the tag associated with the release [here](https://github.com/ros2/ros2/tags).
If you wish to checkout the bleeding-edge development code, you can get the relevant repos file by specifying `master` in place of the release name, i.e.:
```
wget https://raw.githubusercontent.com/ros2/ros2/master/ros2.repos
```
## Update your repositories
You will notice that in the [`ros2.repos` file](https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos), each repository has a `version` associated with it that points to a particular commit hash, tag, or branch name.
It is possible that these versions refer to new tags/branches that your local copy of the repositories will not recognize as they are out-of-date.
Because of this, you should update the repositories that you have already checked out with the following command:
```
vcs custom --args remote update
```
## Download the new source code
You should now be able to download the sources associated with the new `ros2.repos` file with:
```
vcs import src < repos
```
## Rebuild your workspace
Now that the workspace is up to date with the latest sources, rebuild it:
```
src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install
```
## Inspecting your source checkout
During your development you may have been deviated from the original state of your workspace from when you originally imported the `ros2.repos` file.
If you wish to know or share the versions of the set of repositories in your workspace, you can export the information using the following command:
```
cd ~/ros2_ws
vcs export src > my_ros2.repos
```
This file can then be shared with others so that they can reproduce the files in your workspace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment