main: bail if crate version has un-stripped "build metadata"

Versions like "0.4.60+curl-7.88.1" currently break package builds.

Stripping "build metadata" automatically and operating with
"crate version" != "rpm version" might be supported in the future,
but this will require changing the %{crate_instdir} macro, among
other things.

Coincidentally, setting the %{crate_version}" macro in cases of
"crate version" != "rpm version" would also render the lua
implementation of the %{version_no_tilde} macro obsolete.
This commit is contained in:
Fabio Valentini 2023-03-02 21:55:01 +01:00
parent 81554651be
commit 0bf11c122d
No known key found for this signature in database
GPG key ID: 5AC5F572E5D410AF

View file

@ -2,7 +2,7 @@ import os
import pathlib
import sys
from cargo2rpm.metadata import FeatureFlags
from cargo2rpm.metadata import FeatureFlags, Version
from rust2rpm import log
from rust2rpm.cli import get_parser
@ -113,7 +113,14 @@ def main():
)
if not metadata.is_workspace():
warn_if_package_uses_restrictive_dependencies(metadata.packages[0])
package = metadata.packages[0]
if build_meta := Version.parse(package.version).build:
log.error(f"Crate version {package.version!r} contains build metadata: '+{build_meta}'")
log.error(f"This is not supported by rust2rpm; remove the '+{build_meta}' suffix.")
sys.exit(1)
warn_if_package_uses_restrictive_dependencies(package)
spec_contents = spec_render_crate(
metadata=metadata,