ext/package: emit RPM-safe Version for pre-release semver#175
Open
mobileoverlord wants to merge 1 commit into
Open
ext/package: emit RPM-safe Version for pre-release semver#175mobileoverlord wants to merge 1 commit into
mobileoverlord wants to merge 1 commit into
Conversation
rpmbuild rejects a '-' in the Version field (it is the Version/Release
separator), so packaging an extension whose version is a valid semver
pre-release like 1.0.0-rc.1 failed with:
error: line 5: Illegal char '-' (0x2d) in: Version: 1.0.0-rc.1
Map the semver version to its RPM form for the spec Version and the built
RPM's filename: '-' -> '~' and '+' -> '^'. RPM's '~' sorts before the
release (1.0.0~rc.1 < 1.0.0), matching semver pre-release precedence. The
semver form is preserved for the avocado.yaml baked into the payload, which
consumers validate as semver ('~' is not valid semver).
There was a problem hiding this comment.
Pull request overview
This PR fixes RPM extension packaging failures for semver pre-release versions (e.g. 1.0.0-rc.1) by emitting an RPM-safe version string in the generated spec Version: field and in the resulting RPM filename, while keeping the original semver in the packaged avocado.yaml.
Changes:
- Added
utils::version::to_rpm_versionto map semver separators into RPM-compatible separators. - Updated
ext packageRPM spec templating and RPM filename generation to use the RPM-safe version. - Added unit coverage for
to_rpm_version.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/utils/version.rs | Adds to_rpm_version helper and unit tests for semver → RPM version mapping. |
| src/commands/ext/package.rs | Uses RPM-safe version for spec Version: and the produced RPM filename. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+82
to
+84
| pub fn to_rpm_version(version: &str) -> String { | ||
| version.replace('-', "~").replace('+', "^") | ||
| } |
Comment on lines
+143
to
+152
| fn test_to_rpm_version() { | ||
| // Plain release versions are unchanged. | ||
| assert_eq!(to_rpm_version("1.0.0"), "1.0.0"); | ||
| assert_eq!(to_rpm_version("2.1.3"), "2.1.3"); | ||
| // Pre-release `-` becomes `~` (sorts before the release in RPM). | ||
| assert_eq!(to_rpm_version("1.0.0-rc.1"), "1.0.0~rc.1"); | ||
| assert_eq!(to_rpm_version("1.0.0-alpha.2"), "1.0.0~alpha.2"); | ||
| // Build metadata `+` becomes `^`. | ||
| assert_eq!(to_rpm_version("1.0.0+build.5"), "1.0.0^build.5"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Packaging an extension whose version is a valid semver pre-release (e.g.
1.0.0-rc.1) fails at spec build:RPM forbids
-in theVersion:field — it's the Version/Release separator. The extension packager wrote the raw semver string straight into the spec, so any-rc.N/-alpha/-betaversion is rejected. Surfaced by the1.0.0-rc.1release, but it applies to any pre-release ext version.Fix
Map the semver version to an RPM-compatible form for the spec
Version:and the built RPM's filename:-→~(RPM pre-release:1.0.0~rc.1sorts before1.0.0, matching semver pre-release precedence)+→^(build metadata → RPM post-release)Plain releases (
1.0.0) are unchanged. New helperutils::version::to_rpm_version.The semver form is preserved for the
avocado.yamlbaked into the package payload — consumers validate that field as semver, and~is not valid semver — so only the RPM artifacts (Version + filename) get the transformed value. This keeps the human/avocado-facing version as1.0.0-rc.1while the RPM/feed sees1.0.0~rc.1.Test
test_to_rpm_version(plain /-rc.1/-alpha.2/+build.5).cargo buildclean;version::tests(31) andext::package(13) suites pass.Release note
The packaging is done by the installed avocado CLI, so this fix only takes effect once it ships in a CLI release.
1.0.0-rc.1(already tagged) still packages with the bug — the fix will land in the next tag (rc.2). That release will also want the ext-release/release asset-upload race fix discussed on the prior PR, or its Extension Release run must be re-run afterrelease.ymlfinishes uploading.