#19 cargo2rpm doesn't handle ~ in versions
Closed by decathorpe. Opened by pbrobinson.

When dealing with RC releases it's possible they may have ~ in the version string and cargo2rpm errors out when dealing with them

+ /usr/bin/cargo2rpm --path Cargo.toml buildrequires
error: unexpected character '~' after patch version number
 --> Cargo.toml:3:11
  |
3 | version = "25.3.0~rc1"
  |           ^^^^^^^^^^^^
  |
Command '['cargo', 'metadata', '--quiet', '--format-version', '1', '--offline', '--no-deps', '--manifest-path', 'Cargo.toml']' returned non-zero exit status 101.
error: unexpected character '~' after patch version number
 --> Cargo.toml:3:11
  |
3 | version = "25.3.0~rc1"
  |           ^^^^^^^^^^^^
  |

That is the correct behaviour, the ~ character is not valid SemVer. It should be a dash / hyphen - instead. The error you've posted above is not from cargo2rpm, it's from cargo itself.

Metadata Update from @decathorpe:
- Issue status updated to: Closed (was: Open)

@decathorpe how does that work with Fedora packaging for pre-release naming which says to use ~rc1 for pre releases?

Metadata Update from @pbrobinson:
- Issue status updated to: Open (was: Closed)

When using rust2rpm, that's handled automatically by the tool (by setting crate_version to the one with the - character and the Version tag in the spec to a string where that - is replaced by a tilde ~ character).

If you're working on a non-crate package that doesn't use rust2rpm, you can set the Version tag to a string where the - from the upstream version is replaced by a ~.

Here's an example of what that looks like for a rust2rpm-generated package:
https://src.fedoraproject.org/rpms/rust-blazesym/blob/rawhide/f/rust-blazesym.spec

Metadata Update from @decathorpe:
- Issue status updated to: Closed (was: Open)

(To make it explicit, the Cargo.toml version string must be valid SemVer, i.e. pre-release separator is supposed to be a hyphen. This will be handled correctly by our tooling.)

Thanks, that last comment gave me the bit of knowledge I needed.

Log in to comment on this ticket.

Metadata