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

Add script to rename packages from ignition to gazebo #726

Merged
merged 9 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 0 additions & 5 deletions jenkins-scripts/docker/lib/boilerplate_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ if [ -z ${ENABLE_REAPER} ]; then
ENABLE_REAPER=true
fi

# We use ignitionsrobotics or osrf. osrf by default
if [ -z ${GITHUB_ORG} ]; then
GITHUB_ORG="osrf"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need osrf for Gazebo classic?

fi

if [ -z "${NEED_C17_COMPILER}" ]; then
export INSTALL_C17_COMPILER=false
fi
Expand Down
8 changes: 4 additions & 4 deletions jenkins-scripts/docker/lib/debbuild-base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if ${NIGHTLY_MODE}; then
if ${USE_REPO_DIRECTORY_FOR_NIGHTLY}; then
mv ${WORKSPACE}/repo \$REAL_PACKAGE_NAME
else
git clone https://github.com/${GITHUB_ORG}/\$REAL_PACKAGE_NAME -b ${NIGHTLY_SRC_BRANCH}
git clone https://github.com/gazebosim/\$REAL_PACKAGE_NAME -b ${NIGHTLY_SRC_BRANCH}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need osrf for Gazebo classic

fi
PACKAGE_SRC_BUILD_DIR=\$REAL_PACKAGE_NAME
cd \$REAL_PACKAGE_NAME
Expand Down Expand Up @@ -83,7 +83,7 @@ fi

# Step 4: add debian/ subdirectory with necessary metadata files to unpacked source tarball
rm -rf /tmp/$PACKAGE-release
git clone https://github.com/ignition-release/$PACKAGE-release -b $RELEASE_REPO_BRANCH /tmp/$PACKAGE-release
git clone https://github.com/gazebo-release/$PACKAGE-release -b $RELEASE_REPO_BRANCH /tmp/$PACKAGE-release
cd /tmp/$PACKAGE-release
# In nightly get the default latest version from default changelog
if $NIGHTLY_MODE; then
Expand All @@ -109,7 +109,7 @@ fi
case \${BUILD_METHOD} in
"OVERWRITE_BASE")
# 1. Clone the base branch
git clone https://github.com/ignition-release/\${PACKAGE}-release \\
git clone https://github.com/gazebo-release/\${PACKAGE}-release \\
-b \${RELEASE_BASE_BRANCH} \\
/tmp/base_$PACKAGE-release
# 2. Overwrite the information
Expand Down Expand Up @@ -190,7 +190,7 @@ fi
timeout=0
# Help to debug race conditions in nightly generation or other problems with versions
if ${NIGHTLY_MODE}; then
apt-cache show *ignition* | ( grep 'Package\\|Version' || true)
apt-cache show *gz-* | ( grep 'Package\\|Version' || true)
# 5 minutes to give time to the uploader
timeout=300
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ SCRIPT_DIR="${SCRIPT_DIR%/*}"

export RELEASE_REPO_DIRECTORY=${DISTRO}
export ENABLE_ROS=false
export GITHUB_ORG=ignitionrobotics

. ${SCRIPT_DIR}/lib/debbuild-base.bash
24 changes: 24 additions & 0 deletions release-repo-scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,27 @@ To create `ign-rendering7-release` repository copying files in `ign-rendering6-r
cd /tmp/
./path/to/release-tools/release-repo-scripts/new_ignition_release_repos.bash ign-rendering7
```

### rename_ignition_to_gazebo.bash

Script used for renaming all ignition package names to gz. It creates
transition packages as aliases.

#### Usage

The script uses `dch` from the package `debhelper`. `grep-dctrl` from the `dctrl-tools` package.
The script will make all the changes without making any commit so a manual inspection
can be done after the run.

```bash
cd <release-repo>
./path/to/release-tools/release-repo-scripts/rename_ignition_to_gazebo.bash
```

#### Example

```bash
git clone https://github.com/gazebo-release/gz-cmake3-release
cd gz-cmake3-release
./path/to/release-tools/release-repo-scripts/rename_ignition_to_gazebo.bash
```
119 changes: 119 additions & 0 deletions release-repo-scripts/rename_ignition_to_gazebo.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/bash

set -e

# 0. Pre checks
find . -name control -type f | while IFS= read -r f; do
if grep "transitional package" "${f}" > /dev/null; then
echo "There are transitional packages declared in ${f}"
echo "Please remove them, probably not needed."
exit 1
fi
done

# we don't support buster anymore
if [[ -d debian/buster ]]; then
git rm -fr debian/buster
fi

# 1. Block: change in the control file
find . -name control -type f | while IFS= read -r f; do
if [[ $f == ./ubuntu/debian/tests/control ]]; then
continue
fi
echo "Processing control file: ${f}"
ignition_pkgs=$(grep-dctrl -sPackage -n '' ${f})
echo " - Replace ignition ocurrences"
# Rename urls and packages
sed -i -e 's:ignitionrobotics:gazebosim:g' "${f}"
sed -i -e 's:libignition:libgz:g' "${f}"
sed -i -e 's:ignition:gz:g' "${f}"
sed -i -e 's:Ignition:Gazebo:g' "${f}"
sed -i -e 's:ign-:gz-:g' "${f}"
# Inject transitional (alias) packages
echo " - Transitional packages in control file"
for pkg in ${ignition_pkgs}; do
echo " * Processing transitional package for ${pkg}"
new_pkg_name=${pkg/ignition/gz}
cat << EOF >> "${f}"

Package: ${pkg}
Depends: ${new_pkg_name}, \${misc:Depends}
Architecture: all
Priority: optional
Section: oldlibs
Description: transitional package
This is a transitional package. It can safely be removed.
EOF
done
echo
done

# 2. Copyright files
find . -name '*copyright*' -type f | while IFS= read -r f; do
echo "Procesing copyright file: ${f}"
sed -i -e 's:bitbucket.org/:github.org/:g' "${f}"
sed -i -e 's:/osrf/:/ignitionrobotics/:g' "${f}"
sed -i -e 's:ignitionrobotics:gazebosim:g' "${f}"
sed -i -e 's:ignition:gz:g' "${f}"
sed -i -e 's:ign_:gz-:g' "${f}"
echo
done

# 3. Test file if needed
if [[ -f ubuntu/debian/tests/ ]]; then
echo "Procesing copyright tests control"
sed -i -e 's:ignition:gz:g' ubuntu/debian/tests/control
echo
fi

# 4. Changelog files
find . -name 'changelog' -type f | while IFS= read -r f; do
echo "Bumping changelog file ${f}"
distro=$(dpkg-parsechangelog -l${f} -S distribution)
version=$(dpkg-parsechangelog -l${f} -S Version | sed 's:~.*::g')
version_without_rev=${version/-*}
bump_rev=$(( ${version/*-} + 1 ))
dch --changelog "${f}" \
--distribution="${distro}" \
--force-distribution \
--newversion "${version_without_rev}-${bump_rev}~${distro}" \
"Change package source name"
sed -i -e '1 s:ignition-gazebo:gz-sim:g' "${f}"
sed -i -e '1 s:ignition:gz:g' "${f}"
done

echo

# 5. Rename all ignition symlinks and destinations
find . -name '*ignition*' -type l | while IFS= read -r f; do
echo "Renaming ${f} -> ${f/ignition-/gz-}"
link=$(readlink "$f")
ln -sfT "${link//ignition-/gz-}" "${f}"
git mv "${f}" "${f/ignition-/gz-}"
done

echo

# 6. Rename all ignition filenames not symlinks
find . -name '*ignition*' -type f | while IFS= read -r f; do
echo "Renaming ${f} -> ${f/ignition-/gz-}"
git mv "${f}" "${f/ignition-/gz-}"
done

# 6. watch files
find . -name 'watch' -type f | while IFS= read -r f; do
echo "Changeing watch file ${f}"
sed -i -e 's:/osrf/:/ignitionrobotics/:g' "${f}"
sed -i -e 's:ignitionrobotics:gazebosim:g' "${f}"
sed -i -e 's:ignition:gz:g' "${f}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

echo

# 7. Revert Provides, Breaks, Replaces
find . -name control -type f | while IFS= read -r f; do
sed -i -e 's:\(Breaks\:.*\)gz-\(.*\):\1ignition-\2:' "${f}"
sed -i -e 's:\(Provides\:.*\)gz-\(.*\):\1ignition-\2:' "${f}"
sed -i -e 's:\(Replaces\:.*\)gz-\(.*\):\1ignition-\2:' "${f}"
done