Skip to content

Commit

Permalink
Modify update_version.sh to support rc version strings
Browse files Browse the repository at this point in the history
Preserving the SecureDrop Core scheme, this will allow us to support release canadidates for the workstation provisioning code.

Pre-release separators for RPMs[1] are `~`, while not supported in Python (per PEP440)[2], and overwriting them to `-`. We should modify the RPM spec to specify the source folder and tarballs to take into account this path change.

Thanks to @kushaldas for recommending the use of `%prep` and `%setup -n <path>` here.

[1]: https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_versioning_prereleases_with_tilde
[2]: https://www.python.org/dev/peps/pep-0440/#pre-release-separators
  • Loading branch information
emkll committed May 11, 2020
1 parent 91c8eb5 commit 294f58a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rpm-build/SPECS/securedrop-workstation-dom0-config.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ configuration over time.
%undefine py_auto_byte_compile

%prep
%setup -q
%setup -n securedrop-workstation-dom0-config-0.2.4

%build
%{__python3} setup.py build
Expand Down
14 changes: 12 additions & 2 deletions update_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,26 @@ if [ -z "$OLD_VERSION" ]; then
exit 1
fi

if [[ $NEW_VERSION == *-rc* ]]; then
echo "Release candidates should use the versioning 0.x.y~rcZ!"
exit 1
fi

NEW_SDIST_VERSION=$(echo "$NEW_VERSION" | sed -r -e 's/~/-/')
OLD_SDIST_VERSION=$(echo "$OLD_VERSION" | sed -r -e 's/~/-/')

# Update the version in rpm-build/SPECS/securedrop-workstation-dom0-config.spec and setup.py
# We just change Source0 and Version fields in the rpm spec. The spec file also contains the changelog entries,
# and we don't want to increment those versions.
if [[ "$OSTYPE" == "darwin"* ]]; then
# The empty '' after sed -i is required on macOS to indicate no backup file should be saved.
sed -i '' "s@$(echo "${OLD_VERSION}" | sed 's/\./\\./g')@$NEW_VERSION@g" VERSION
sed -i '' -e "/Source0/s/$OLD_VERSION/$NEW_VERSION/" rpm-build/SPECS/securedrop-workstation-dom0-config.spec
sed -i '' -e "/Source0/s/$OLD_SDIST_VERSION/$NEW_SDIST_VERSION/" rpm-build/SPECS/securedrop-workstation-dom0-config.spec
sed -i '' -e "/Version/s/$OLD_VERSION/$NEW_VERSION/" rpm-build/SPECS/securedrop-workstation-dom0-config.spec
sed -i '' -e "/\%setup -n securedrop-workstation-dom0-config-/s/$OLD_SDIST_VERSION/$NEW_SDIST_VERSION/" rpm-build/SPECS/securedrop-workstation-dom0-config.spec
else
sed -i "s@$(echo "${OLD_VERSION}" | sed 's/\./\\./g')@$NEW_VERSION@g" VERSION
sed -i -e "/Source0/s/$OLD_VERSION/$NEW_VERSION/" rpm-build/SPECS/securedrop-workstation-dom0-config.spec
sed -i -e "/Source0/s/$OLD_SDIST_VERSION/$NEW_SDIST_VERSION/" rpm-build/SPECS/securedrop-workstation-dom0-config.spec
sed -i -e "/Version/s/$OLD_VERSION/$NEW_VERSION/" rpm-build/SPECS/securedrop-workstation-dom0-config.spec
sed -i -e "/\%setup -n securedrop-workstation-dom0-config-/s/$OLD_SDIST_VERSION/$NEW_SDIST_VERSION/" rpm-build/SPECS/securedrop-workstation-dom0-config.spec
fi

0 comments on commit 294f58a

Please sign in to comment.