Skip to content

Commit b802304

Browse files
committed
ros-generate-cache.sh: Fixup mistakes in distribution.yaml
The kilted sync contained a reference to a package version that no longer had a release branch. fatal: Remote branch release/kilted/py_binding_tools/2.0.2-1 not found in upstream origin This provides a mechanism to make changes to the distribution.yaml so that rosdistro_build_cache could complete successfully It uses ruamel.yaml to preserve comments, flow style, and key order. Signed-off-by: Rob Woolley <[email protected]>
1 parent e51b9a8 commit b802304

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

.github/workflows/generate_recipes.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ jobs:
5959
python3 ./setup.py install
6060
- run: mkdir -p ${ROS_HOME}
6161
- run: mkdir -p ${ROSDEP_SOURCE_PATH}
62+
- name: Add ros-generate-cache.sh dependency
63+
run: |
64+
source ${GITHUB_WORKSPACE}/superflore/venv/bin/activate
65+
python3 -m pip install ruamel.yaml
6266
- name: Initialize rosdep cache
6367
run: |
6468
source ${GITHUB_WORKSPACE}/superflore/venv/bin/activate

scripts/ros-generate-cache.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,37 @@ fi
108108
tmpdir=$(mktemp -t -d ros-generate-cache-XXXXXXXX)
109109
trap "rm -rf $tmpdir" 0
110110

111+
function set_release_version {
112+
package=$1
113+
oldversion=$2
114+
newversion=$3
115+
116+
python3 <<HEREDOC
117+
from ruamel.yaml import YAML
118+
119+
yaml = YAML()
120+
yaml.preserve_quotes = True # keep existing quotes if any
121+
122+
def set_release_version(data, repo_name, oldversion, newversion):
123+
print("set_release_version")
124+
if repo_name in data.get("repositories", {}):
125+
release_section = data["repositories"][repo_name].get("release", {})
126+
if "version" in release_section:
127+
if release_section["version"] == oldversion:
128+
release_section["version"] = newversion
129+
130+
# Load the file
131+
with open("$ROS_DISTRO/distribution.yaml", "r") as f:
132+
data = yaml.load(f)
133+
134+
set_release_version(data, '$1', '$2', '$3')
135+
136+
# Write back the file
137+
with open("$ROS_DISTRO/distribution.yaml", "w") as f:
138+
yaml.dump(data, f)
139+
HEREDOC
140+
}
141+
111142
# Create a directory tree under $tmpdir with the contents of ros/rosdistro.git at commit $ROS_ROSDISTRO_COMMIT.
112143
cd $path_to_ros_rosdistro
113144
git archive $ROS_ROSDISTRO_COMMIT | tar -C $tmpdir -xf -
@@ -116,12 +147,17 @@ cd - > /dev/null
116147
# Create $tmpdir/$ROS_DISTRO-cache.yaml.gz .
117148
cd $tmpdir
118149

150+
# Make changes to distribution.yaml
119151
if [ "$ROS_DISTRO" = "dashing" -o "$ROS_DISTRO" = "eloquent" ] ; then
120152
sed 's#boschresearch/fmilibrary_vendor-release#ros2-gbp/fmilibrary_vendor-release#g' -i $ROS_DISTRO/distribution.yaml
121153
sed 's#boschresearch/fmi_adapter_ros2-release#ros2-gbp/fmi_adapter-release#g' -i $ROS_DISTRO/distribution.yaml
122154
sed 's#fmi_adapter_ros2#fmi_adapter#g' -i $ROS_DISTRO/distribution.yaml
123155
fi
124156

157+
if [ "$ROS_DISTRO" = "kilted" ] ; then
158+
set_release_version 'py_binding_tools' '2.0.2-1' '2.1.0-1'
159+
fi
160+
125161
rosdistro_build_cache --debug --preclean --ignore-local $tmpdir/index-v4.yaml $ROS_DISTRO
126162
if [ $? -ne 0 ]; then
127163
echo "ABORT: rosdistro_build_cache returned a runtime error"

0 commit comments

Comments
 (0)