diff --git a/0001-name-spec-patch_file-by-real-crate-name.patch b/0001-name-spec-patch_file-by-real-crate-name.patch index 1f65e7f..4d55717 100644 --- a/0001-name-spec-patch_file-by-real-crate-name.patch +++ b/0001-name-spec-patch_file-by-real-crate-name.patch @@ -1,7 +1,7 @@ From 0dc9fc182edf0791ca697f587e48dd39948d63c1 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Mon, 10 Sep 2018 23:37:40 +0200 -Subject: [PATCH 01/13] name spec/patch_file by real crate name +Subject: [PATCH 01/14] name spec/patch_file by real crate name When renaming using patch file, we really want to change file names too. @@ -33,5 +33,5 @@ index dc78828..1575ce6 100644 if args.stdout: print("# {}".format(spec_file)) -- -2.20.0.rc2 +2.20.1 diff --git a/0002-generate-doc-statements.patch b/0002-generate-doc-statements.patch index 581990d..42ca40d 100644 --- a/0002-generate-doc-statements.patch +++ b/0002-generate-doc-statements.patch @@ -1,7 +1,7 @@ From 561280a0ea35f226ef243526be2bbb656db44af6 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Mon, 10 Sep 2018 23:40:18 +0200 -Subject: [PATCH 02/13] generate %doc statements +Subject: [PATCH 02/14] generate %doc statements Signed-off-by: Igor Gnatenko --- @@ -54,5 +54,5 @@ index 1aeb969..2e9f841 100644 {% endif %} -- -2.20.0.rc2 +2.20.1 diff --git a/0003-do-better-for-renamed-crates.patch b/0003-do-better-for-renamed-crates.patch index 1640604..3f1bc98 100644 --- a/0003-do-better-for-renamed-crates.patch +++ b/0003-do-better-for-renamed-crates.patch @@ -1,7 +1,7 @@ From 2050880140d4953b9ebdc7211e30df3ccf5dd61d Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Tue, 11 Sep 2018 00:06:50 +0200 -Subject: [PATCH 03/13] do better for renamed crates +Subject: [PATCH 03/14] do better for renamed crates Signed-off-by: Igor Gnatenko --- @@ -86,5 +86,5 @@ index 2e9f841..7dbcc3f 100644 %build -- -2.20.0.rc2 +2.20.1 diff --git a/0004-remove-pre-3.6-leftovers.patch b/0004-remove-pre-3.6-leftovers.patch index 0ba106c..7133f4e 100644 --- a/0004-remove-pre-3.6-leftovers.patch +++ b/0004-remove-pre-3.6-leftovers.patch @@ -1,7 +1,7 @@ From e6e9cbbb71199c2773b47fa21f1c917a167c1743 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Tue, 11 Sep 2018 10:43:53 +0200 -Subject: [PATCH 04/13] remove pre-3.6 leftovers +Subject: [PATCH 04/14] remove pre-3.6 leftovers Signed-off-by: Igor Gnatenko --- @@ -23,5 +23,5 @@ index f52d968..5adeb65 100644 + "--manifest-path={}".format(path)]) return cls.from_json(json.loads(metadata)) -- -2.20.0.rc2 +2.20.1 diff --git a/0005-Remove-half-downloaded-crate-on-C.patch b/0005-Remove-half-downloaded-crate-on-C.patch index 6f67bb9..8ae52e4 100644 --- a/0005-Remove-half-downloaded-crate-on-C.patch +++ b/0005-Remove-half-downloaded-crate-on-C.patch @@ -1,7 +1,7 @@ From 2f12c83d14afe71e9efed2d1be62e1e610e602e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 17 Aug 2018 10:03:48 +0200 -Subject: [PATCH 05/13] Remove half-downloaded crate on ^C +Subject: [PATCH 05/14] Remove half-downloaded crate on ^C Subsequent invocations would fail with an error about a corrupted file. We don't have support for resuming a failed download, so let's remove the @@ -40,5 +40,5 @@ index e993e7b..8e6f6eb 100644 total=total, unit="B", unit_scale=True): f.write(chunk) -- -2.20.0.rc2 +2.20.1 diff --git a/0006-Throw-an-error-if-s-is-used-without-a-crate.patch b/0006-Throw-an-error-if-s-is-used-without-a-crate.patch index cc09ce2..8684175 100644 --- a/0006-Throw-an-error-if-s-is-used-without-a-crate.patch +++ b/0006-Throw-an-error-if-s-is-used-without-a-crate.patch @@ -1,7 +1,7 @@ From 5a1cde5b8dcaea74ebb2050879036bf46df63adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 17 Aug 2018 10:18:59 +0200 -Subject: [PATCH 06/13] Throw an error if -s is used without a crate +Subject: [PATCH 06/14] Throw an error if -s is used without a crate In the future we might want to be smarter and find the crate, but let's at least not ignore the option completely. @@ -24,5 +24,5 @@ index 8e6f6eb..f23ebbc 100644 diff = make_patch(toml, enabled=patch, tmpfile=True) metadata = Metadata.from_file(toml) -- -2.20.0.rc2 +2.20.1 diff --git a/0007-split-features-into-subpackages.patch b/0007-split-features-into-subpackages.patch index 52d253e..19fd5e5 100644 --- a/0007-split-features-into-subpackages.patch +++ b/0007-split-features-into-subpackages.patch @@ -1,7 +1,7 @@ From 2cac5e5ad5ff5472923ce333bef59679612bbaa2 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Fri, 26 Oct 2018 11:20:13 +0200 -Subject: [PATCH 07/13] split features into subpackages +Subject: [PATCH 07/14] split features into subpackages References: https://discussion.fedoraproject.org/t/rfc-new-crates-packaging-design-features-have-their-own-subpackages/563?u=ignatenkobrain Signed-off-by: Igor Gnatenko @@ -1060,5 +1060,5 @@ index b856fdd..30263b4 100644 - assert [str(x) for x in md.provides] == provides - assert [str(x) for x in md.requires] == requires -- -2.20.0.rc2 +2.20.1 diff --git a/0008-add-support-for-dependencies-with-same-name.patch b/0008-add-support-for-dependencies-with-same-name.patch index 378edfc..f6f2743 100644 --- a/0008-add-support-for-dependencies-with-same-name.patch +++ b/0008-add-support-for-dependencies-with-same-name.patch @@ -1,7 +1,7 @@ From a1d3a84645aa7bbe5ca07b60bead1ddf90a21cc1 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Tue, 30 Oct 2018 20:37:38 +0100 -Subject: [PATCH 08/13] add support for dependencies with same name +Subject: [PATCH 08/14] add support for dependencies with same name Reported-by: Josh Stone References: https://internals.rust-lang.org/t/optional-dependencies-with-same-name/8728 @@ -70,5 +70,5 @@ index 4929cdd..328b67a 100644 if "default" not in deps_by_feature: -- -2.20.0.rc2 +2.20.1 diff --git a/0009-add-support-for-feeding-user-configuration.patch b/0009-add-support-for-feeding-user-configuration.patch index b130ebe..5078943 100644 --- a/0009-add-support-for-feeding-user-configuration.patch +++ b/0009-add-support-for-feeding-user-configuration.patch @@ -1,7 +1,7 @@ From 197150ee2e862edcd46f7ab02c9e4d17e49ca75d Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 31 Oct 2018 18:03:21 +0100 -Subject: [PATCH 09/13] add support for feeding user configuration +Subject: [PATCH 09/14] add support for feeding user configuration Signed-off-by: Igor Gnatenko --- @@ -144,5 +144,5 @@ index 0d9a80b..d901e6d 100644 %description {{ pkg }} %{_description} -- -2.20.0.rc2 +2.20.1 diff --git a/0010-trivial-use-f-strings-everywhere.patch b/0010-trivial-use-f-strings-everywhere.patch index f6ff2f4..72c5828 100644 --- a/0010-trivial-use-f-strings-everywhere.patch +++ b/0010-trivial-use-f-strings-everywhere.patch @@ -1,7 +1,7 @@ From 83ea3796cd28ec7689b39e7dc7a70bd11af1abf1 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 31 Oct 2018 17:00:58 +0100 -Subject: [PATCH 10/13] trivial: use f-strings everywhere +Subject: [PATCH 10/14] trivial: use f-strings everywhere Signed-off-by: Igor Gnatenko --- @@ -90,5 +90,5 @@ index c691274..b60e6c4 100644 else: with open(spec_file, "w") as fobj: -- -2.20.0.rc2 +2.20.1 diff --git a/0011-Add-option-to-not-generate-a-default-changelog-entry.patch b/0011-Add-option-to-not-generate-a-default-changelog-entry.patch index ccad736..4345add 100644 --- a/0011-Add-option-to-not-generate-a-default-changelog-entry.patch +++ b/0011-Add-option-to-not-generate-a-default-changelog-entry.patch @@ -1,7 +1,7 @@ From 294c6f571c0f4f7ed5a4fcb34142b0d332c55f29 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Sun, 11 Nov 2018 11:06:27 -0500 -Subject: [PATCH 11/13] Add option to not generate a default changelog entry +Subject: [PATCH 11/14] Add option to not generate a default changelog entry For Rust packages created through the OBS source service, the changelog is managed by an external .changes file that is @@ -59,5 +59,5 @@ index d901e6d..84bd97d 100644 + {% include target ~ "-changelog.spec.inc" %} +{% endif %} -- -2.20.0.rc2 +2.20.1 diff --git a/0012-Set-CARGO_HOME-to-the-local-.config.patch b/0012-Set-CARGO_HOME-to-the-local-.config.patch index 9f81757..ddf86d1 100644 --- a/0012-Set-CARGO_HOME-to-the-local-.config.patch +++ b/0012-Set-CARGO_HOME-to-the-local-.config.patch @@ -1,7 +1,7 @@ From b4e25038296cd57eba639a059e8baaf139a5d287 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Dec 2018 13:58:41 -0800 -Subject: [PATCH 12/13] Set CARGO_HOME to the local .config +Subject: [PATCH 12/14] Set CARGO_HOME to the local .config --- data/macros.cargo | 6 +++++- @@ -22,5 +22,5 @@ index 7fb025b..e760721 100644 %__cargo_inspector %{_bindir}/cargo-inspector -- -2.20.0.rc2 +2.20.1 diff --git a/0013-Set-the-install-root-in-.cargo-config.patch b/0013-Set-the-install-root-in-.cargo-config.patch index cb106e8..baa5e3a 100644 --- a/0013-Set-the-install-root-in-.cargo-config.patch +++ b/0013-Set-the-install-root-in-.cargo-config.patch @@ -1,7 +1,7 @@ From a04e95bc4f807139bd3c4b75f46fd9a60ec1db8f Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 7 Dec 2018 13:59:03 -0800 -Subject: [PATCH 13/13] Set the install root in .cargo/config +Subject: [PATCH 13/14] Set the install root in .cargo/config --- data/macros.cargo | 4 +++- @@ -30,5 +30,5 @@ index e760721..9a9ce6a 100644 %* \ }\ -- -2.20.0.rc2 +2.20.1 diff --git a/0014-Add-support-for-prerelease-versions.patch b/0014-Add-support-for-prerelease-versions.patch new file mode 100644 index 0000000..cf16439 --- /dev/null +++ b/0014-Add-support-for-prerelease-versions.patch @@ -0,0 +1,85 @@ +From 29a3c1b84e0971fc0c2edf483ae3b04139c19b32 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Sat, 26 Jan 2019 08:33:37 +0100 +Subject: [PATCH 14/14] Add support for prerelease versions + +Signed-off-by: Igor Gnatenko +--- + rust2rpm/metadata.py | 18 ++++++++++++------ + test.py | 8 ++++++++ + 2 files changed, 20 insertions(+), 6 deletions(-) + +diff --git a/rust2rpm/metadata.py b/rust2rpm/metadata.py +index 328b67a..f0718d5 100644 +--- a/rust2rpm/metadata.py ++++ b/rust2rpm/metadata.py +@@ -45,11 +45,13 @@ class Dependency: + # Any means any + continue + ver = req.spec +- if ver.prerelease: +- raise NotImplementedError(f"Pre-release requirement is not supported: {ver}") + if req.kind in (req.KIND_NEQ, req.KIND_EMPTY): + raise NotImplementedError(f"'!=' and empty kinds are not supported: {req}") +- coerced = semver.Version.coerce(str(ver)) ++ coerced = str(semver.Version.coerce(str(ver))) ++ if ver.prerelease: ++ coerced = coerced.replace("-", "~") ++ # This will advance us to closest stable version (2.0.0-beta.6 → 2.0.0) ++ ver = ver.next_patch() + if req.kind == req.KIND_EQUAL: + req.kind = req.KIND_SHORTEQ + if req.kind in (req.KIND_CARET, req.KIND_COMPATIBLE): +@@ -107,7 +109,11 @@ class Dependency: + class Metadata: + def __init__(self, name, version): + self.name = name +- self.version = version ++ self._version = version ++ version_normalized = Dependency._normalize_req(f"={self._version}") ++ if len(version_normalized) != 1: ++ raise Exception(f"Incorrect version: {self._version}") ++ self.version = version_normalized[0][1] + self.license = None + self.license_file = None + self.readme = None +@@ -187,7 +193,7 @@ class Metadata: + def provides(self, feature=None): + if feature not in self.dependencies: + raise KeyError(f"Feature {feature!r} doesn't exist") +- return Dependency(self.name, f"={self.version}", features={feature}) ++ return Dependency(self.name, f"={self._version}", features={feature}) + + @classmethod + def _resolve(cls, deps_by_feature, feature): +@@ -207,7 +213,7 @@ class Metadata: + return self._resolve(self.dependencies, feature)[1] + else: + features, deps = self.dependencies[feature] +- fdeps = set(Dependency(self.name, f"={self.version}", features={feature}) ++ fdeps = set(Dependency(self.name, f"={self._version}", features={feature}) + for feature in features) + return fdeps | deps + +diff --git a/test.py b/test.py +index 30263b4..035df79 100644 +--- a/test.py ++++ b/test.py +@@ -37,6 +37,14 @@ import rust2rpm + "crate(test) = 1.2.3"), + (">= 1.2, < 1.5", + "(crate(test) >= 1.2.0 with crate(test) < 1.5.0)"), ++ ("^2.0.0-alpha.6", ++ "(crate(test) >= 2.0.0~alpha.6 with crate(test) < 3.0.0)"), ++ ("^0.1.0-alpha.6", ++ "(crate(test) >= 0.1.0~alpha.6 with crate(test) < 0.2.0)"), ++ ("^0.0.1-alpha.6", ++ "(crate(test) >= 0.0.1~alpha.6 with crate(test) < 0.0.2)"), ++ ("^0.0.0-alpha.6", ++ "(crate(test) >= 0.0.0~alpha.6 with crate(test) < 0.0.1)"), + ]) + def test_dependency(req, rpmdep): + dep = rust2rpm.Dependency("test", req) +-- +2.20.1 + diff --git a/rust-packaging.spec b/rust-packaging.spec index 5b5682d..0d97e56 100644 --- a/rust-packaging.spec +++ b/rust-packaging.spec @@ -5,7 +5,7 @@ Name: rust-packaging Version: 6 -Release: 18%{?dist} +Release: 19%{?dist} Summary: RPM macros for building Rust packages on various architectures License: MIT @@ -24,6 +24,7 @@ Patch0010: 0010-trivial-use-f-strings-everywhere.patch Patch0011: 0011-Add-option-to-not-generate-a-default-changelog-entry.patch Patch0012: 0012-Set-CARGO_HOME-to-the-local-.config.patch Patch0013: 0013-Set-the-install-root-in-.cargo-config.patch +Patch0014: 0014-Add-support-for-prerelease-versions.patch ExclusiveArch: %{rust_arches} @@ -84,6 +85,9 @@ py.test-%{python3_version} -vv test.py %{python3_sitelib}/rust2rpm/ %changelog +* Sat Jan 26 2019 Igor Gnatenko - 6-19 +- Add support for pre-release versions + * Fri Dec 07 2018 Igor Gnatenko - 6-18 - Set CARGO_HOME