Skip to content

ext/package: emit RPM-safe Version for pre-release semver#175

Open
mobileoverlord wants to merge 1 commit into
mainfrom
jschneck/ext-package-rpm-prerelease-version
Open

ext/package: emit RPM-safe Version for pre-release semver#175
mobileoverlord wants to merge 1 commit into
mainfrom
jschneck/ext-package-rpm-prerelease-version

Conversation

@mobileoverlord

Copy link
Copy Markdown
Contributor

Problem

Packaging an extension whose version is a valid semver pre-release (e.g. 1.0.0-rc.1) fails at spec build:

Building for target noarch
error: line 5: Illegal char '-' (0x2d) in: Version: 1.0.0-rc.1

RPM forbids - in the Version: field — it's the Version/Release separator. The extension packager wrote the raw semver string straight into the spec, so any -rc.N/-alpha/-beta version is rejected. Surfaced by the 1.0.0-rc.1 release, 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.1 sorts before 1.0.0, matching semver pre-release precedence)
  • +^ (build metadata → RPM post-release)

Plain releases (1.0.0) are unchanged. New helper utils::version::to_rpm_version.

The semver form is preserved for the avocado.yaml baked 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 as 1.0.0-rc.1 while the RPM/feed sees 1.0.0~rc.1.

Test

  • New unit test test_to_rpm_version (plain / -rc.1 / -alpha.2 / +build.5).
  • cargo build clean; version::tests (31) and ext::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 after release.yml finishes uploading.

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).
Copilot AI review requested due to automatic review settings July 8, 2026 03:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_version to map semver separators into RPM-compatible separators.
  • Updated ext package RPM 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 thread src/utils/version.rs
Comment on lines +82 to +84
pub fn to_rpm_version(version: &str) -> String {
version.replace('-', "~").replace('+', "^")
}
Comment thread src/utils/version.rs
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");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants