Skip to content

feat: fix issue #22 by adding support for rpm - #52

Open
georgbramm wants to merge 5 commits into
mainfrom
feat/rpm-support
Open

georgbramm wants to merge 5 commits into
mainfrom
feat/rpm-support

Conversation

@georgbramm

Copy link
Copy Markdown
Contributor

This PR implements full compliance with the official RPM version comparison (rpmvercmp) specification and EVR packaging rules for the rpm versioning scheme.

Key Features & Improvements
RPM Version Ordering (Ord / PartialOrd):

  • Alphanumeric & Tilde Parsing: Faithful reproduction of the C rpmvercmp algorithm, tokenizing version strings into alternating numeric and alphabetic segments.
  • Tilde () Pre-release Support: Correctly forces pre-release/patch indicators using tildes to sort older than the base version (e.g., 1.0rc1 < 1.0).
  • Segment Precedence Rules: Strict ordering enforcement where numeric segments always rank higher than alphabetic segments at the same position (e.g., 1.a < 1.1).
  • Numeric Magnitude & Padding: Correct mathematical evaluation of numeric values with leading-zero handling and standard tie-breaking rules.
  • Trailing Segment Lengths: Properly handles string exhaustion and trailing extra segments (e.g., 1.2 < 1.2.3).
  • Epoch & Release Breakdown: Robust parsing of colon-delimited epochs (e.g., 2:1.0-1) and hyphen-delimited release suffixes (e.g., 1.2.3-1.el8 < 1.2.3-2.el8).

Constraint Parsing & Native Expansion (NativeVersionConverter):

  • Support for standard relational and equality operators (==, !=, >, >=, <, <=, ===, and wildcard/any bounds).

Testing
Added a comprehensive test suite (test_rpm_comprehensive_ordering and test_rpm_intervals) validating tilde placement, segment alternation, numeric magnitudes, epochs, and release suffixes against canonical RPM behavior.

@georgbramm georgbramm linked an issue Aug 11, 2026 that may be closed by this pull request
@georgbramm
georgbramm marked this pull request as draft August 14, 2026 09:57
@georgbramm

Copy link
Copy Markdown
Contributor Author

trying to solve this pr using https://crates.io/crates/rpm-version tomorrow

@georgbramm

Copy link
Copy Markdown
Contributor Author

adopted it to use crate rpm-version = "0.5.1"

@georgbramm
georgbramm marked this pull request as ready for review November 4, 2026 14:50
@georgbramm georgbramm changed the title Feature: fixes issue #22 by adding support for rpm fixes issue #22 by adding support for rpm Nov 4, 2026
@georgbramm georgbramm changed the title fixes issue #22 by adding support for rpm feat: fix issue #22 by adding support for rpm Nov 4, 2026
@tziemek
tziemek requested a balanced review from Copilot November 9, 2026 07:26

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.

🟡 Changes recommended

RPM is unavailable through public dynamic APIs, and inconsistent equality and hashing can produce incorrect range containment and duplicate detection.

6 open issues
What changed in this PR

This PR introduces a typed RPM versioning scheme backed by rpm-version, extending the library’s version comparison and constraint support.

Changes:

  • Adds RpmVersion with EVR comparison, native constraint parsing, and string serialization.
  • Adds tests for RPM ordering, ranges, and serialization round trips.
  • Adds dependencies and switches dynamic-range tests to the assert_matches crate.
File Description
src/​schemes/​rpm.rs Implements the RPM version type, native conversion, and unit tests.
src/​schemes/​mod.rs Exports the RPM module.
src/​range/​vers.rs Adds RPM ordering and native constraint tests.
src/​range/​dynamic.rs Updates the test assertion macro import.
Cargo.toml Adds rpm-version and the assert_matches test dependency.
Cargo.lock Locks the new dependencies.

Review effort: Balanced

Comment thread src/schemes/mod.rs
pub mod cargo;
pub mod deb;
pub mod intdot;
pub mod rpm;
Comment thread src/schemes/rpm.rs
Comment on lines +53 to +55
let p1 = rpm_version::Evr::parse(&self.raw);
let p2 = rpm_version::Evr::parse(&other.raw);
p1 == p2
Comment thread src/schemes/rpm.rs

impl std::hash::Hash for RpmVersion {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.raw.hash(state);
Comment thread src/schemes/rpm.rs
pub static RPM_SCHEME: &str = "rpm";

#[derive(Clone, Debug, Eq)]
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
Comment thread src/schemes/rpm.rs
Comment on lines +147 to +149
} else {
(Comparator::Equal, raw)
};
Comment thread src/schemes/rpm.rs
Comment on lines +173 to +174
// Validate via rpm_version parsing
let _ = rpm_version::Evr::parse(s);

This branch has not been deployed

No deployments
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.

Add support for rpm

2 participants