Hello community, here is the log from the commit of package rust-packaging for openSUSE:Factory checked in at 2019-03-06 15:50:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rust-packaging (Old) and /work/SRC/openSUSE:Factory/.rust-packaging.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rust-packaging" Wed Mar 6 15:50:58 2019 rev:3 rq:681978 version:6 Changes: -------- --- /work/SRC/openSUSE:Factory/rust-packaging/rust-packaging.changes 2018-11-26 10:19:44.865772286 +0100 +++ /work/SRC/openSUSE:Factory/.rust-packaging.new.28833/rust-packaging.changes 2019-03-06 15:51:07.988438989 +0100 @@ -1,0 +2,14 @@ +Tue Mar 5 22:40:21 UTC 2019 - Igor Gnatenko <[email protected]> + +- Backport more upstream patches + + Added patches + - 0012-Set-CARGO_HOME-to-the-local-.config.patch + - 0013-Set-the-install-root-in-.cargo-config.patch + - 0014-Add-support-for-prerelease-versions.patch +- Replaced patch with upstream version + + Removed patches + - 0101-Add-option-to-not-generate-a-default-changelog-entry.patch + + Added patches + - 0011-Add-option-to-not-generate-a-default-changelog-entry.patch + +------------------------------------------------------------------- --- /work/SRC/openSUSE:Factory/rust-packaging/rust-srpm-macros.changes 2018-11-26 10:19:44.973772160 +0100 +++ /work/SRC/openSUSE:Factory/.rust-packaging.new.28833/rust-srpm-macros.changes 2019-03-06 15:51:08.896438826 +0100 @@ -1,0 +2,5 @@ +Tue Mar 5 22:48:39 UTC 2019 - Igor Gnatenko <[email protected]> + +- Backport upstream patch for tilde handling + +------------------------------------------------------------------- Old: ---- 0101-Add-option-to-not-generate-a-default-changelog-entry.patch New: ---- 0011-Add-option-to-not-generate-a-default-changelog-entry.patch 0012-Set-CARGO_HOME-to-the-local-.config.patch 0013-Set-the-install-root-in-.cargo-config.patch 0014-Add-support-for-prerelease-versions.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rust-packaging.spec ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.664438331 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.664438331 +0100 @@ -2,7 +2,7 @@ # spec file for package rust-packaging # # Copyright (c) 2017 Red Hat, Inc., Raleigh, North Carolina, United States of America. -# Copyright (c) 2017 Igor Gnatenko <[email protected]>. +# Copyright (c) 2017, 2019 Igor Gnatenko <[email protected]>. # Copyright (c) 2018 Neal Gompa <[email protected]>. # # All modifications and additions to the file contributed by third parties @@ -22,13 +22,11 @@ Name: rust-packaging Version: 6 Release: 0 -Summary: RPM tools and macros for building Rust packages +Summary: RPM macros for building Rust packages on various architectures Group: Development/Languages/Rust License: MIT URL: https://pagure.io/fedora-rust/rust2rpm Source0: https://releases.pagure.org/fedora-rust/rust2rpm/rust2rpm-%{version}.tar.xz - -# Patches from upstream Patch0001: 0001-name-spec-patch_file-by-real-crate-name.patch Patch0002: 0002-generate-doc-statements.patch Patch0003: 0003-do-better-for-renamed-crates.patch @@ -39,9 +37,10 @@ Patch0008: 0008-add-support-for-dependencies-with-same-name.patch Patch0009: 0009-add-support-for-feeding-user-configuration.patch Patch0010: 0010-trivial-use-f-strings-everywhere.patch - -# From: https://pagure.io/fedora-rust/rust2rpm/pull-request/62 -Patch0101: 0101-Add-option-to-not-generate-a-default-changelog-entry.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 BuildArch: noarch ExclusiveArch: %{rust_arches} noarch @@ -50,9 +49,11 @@ Requires: gawk >= 4.1.0 Requires: python3-rust2rpm = %{?epoch:%{epoch}:}%{version}-%{release} Requires: rust-srpm-macros = %{version} +Requires: rust +Requires: cargo %description -This package provides the tools and macros for building projects in Rust +The package provides macros for building projects in Rust on various architectures. %package -n python3-rust2rpm @@ -70,17 +71,9 @@ Requires: python3-semantic_version Requires: python3-setuptools Requires: python3-rustcfg -%if 0%{?suse_version} Requires: python3-Jinja2 -%else -Requires: python3-jinja2 -%endif Requires: python3-requests Requires: python3-tqdm -%if 0%{?mageia} -Requires: locales-en -%endif -Obsoletes: rust2rpm < 1-8 Provides: rust2rpm = %{version}-%{release} %{?python_provide:%python_provide python3-rust2rpm} @@ -90,18 +83,9 @@ creates packages that comply with the Fedora Packaging Guidelines, Mageia packaging policy, and the openSUSE Packaging Guidelines. - %prep %autosetup -n rust2rpm-%{version} -p1 -lang= -%if (0%{?fedora} && 0%{?fedora} <= 25) || (0%{?rhel} && 0%{?rhel} <= 7) || 0%{?suse_version} -lang=C.UTF-8 -%else -%if 0%{?mageia} -lang=en_US.UTF-8 -%endif -%endif -[ -z "$lang" ] || sed -r -i -e "s|(%\{_bindir\}/cargo-inspector)|env LANG=$lang \1|" data/cargo.attr data/macros.cargo +sed -r -i -e "s|(%\{_bindir\}/cargo-inspector)|env LANG=C.UTF-8 \1|" data/cargo.attr data/macros.cargo %build %py3_build ++++++ rust-srpm-macros.spec ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.676438328 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.680438328 +0100 @@ -2,7 +2,7 @@ # spec file for package rust-srpm-macros # # Copyright (c) 2017 Red Hat, Inc., Raleigh, North Carolina, United States of America. -# Copyright (c) 2017 Igor Gnatenko <[email protected]>. +# Copyright (c) 2017, 2019 Igor Gnatenko <[email protected]>. # Copyright (c) 2018 Neal Gompa <[email protected]>. # # All modifications and additions to the file contributed by third parties @@ -25,6 +25,20 @@ License: MIT URL: https://pagure.io/fedora-rust/rust2rpm Source0: https://releases.pagure.org/fedora-rust/rust2rpm/rust2rpm-%{version}.tar.xz +Patch0001: 0001-name-spec-patch_file-by-real-crate-name.patch +Patch0002: 0002-generate-doc-statements.patch +Patch0003: 0003-do-better-for-renamed-crates.patch +Patch0004: 0004-remove-pre-3.6-leftovers.patch +Patch0005: 0005-Remove-half-downloaded-crate-on-C.patch +Patch0006: 0006-Throw-an-error-if-s-is-used-without-a-crate.patch +Patch0007: 0007-split-features-into-subpackages.patch +Patch0008: 0008-add-support-for-dependencies-with-same-name.patch +Patch0009: 0009-add-support-for-feeding-user-configuration.patch +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 BuildArch: noarch @@ -33,19 +47,14 @@ of Rust packages. %prep -%autosetup -n rust2rpm-%{version} +%autosetup -n rust2rpm-%{version} -p1 -%if 0%{?mageia} || 0%{?suse_version} # Target arch is i586 on these distributions sed -e "s/i686/i586 i686/" -i data/macros.rust-srpm -%endif - -%if 0%{?suse_version} # Work around bugs in ppc64* arch setup in SUSE rpm sed -e "s/ppc64 ppc64le/ppc64 powerpc64 ppc64le powerpc64le/" -i data/macros.rust-srpm # Add armv6hl to supported arches sed -e "s/armv7hl/armv6hl armv7hl/" -i data/macros.rust-srpm -%endif %install install -D -p -m 0644 -t %{buildroot}%{_rpmconfigdir}/macros.d data/macros.rust-srpm ++++++ 0001-name-spec-patch_file-by-real-crate-name.patch ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.696438325 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.696438325 +0100 @@ -1,7 +1,7 @@ From 0dc9fc182edf0791ca697f587e48dd39948d63c1 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko <[email protected]> Date: Mon, 10 Sep 2018 23:37:40 +0200 -Subject: [PATCH 01/10] 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 @@ if args.stdout: print("# {}".format(spec_file)) -- -2.19.1 +2.20.1 ++++++ 0002-generate-doc-statements.patch ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.700438324 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.704438324 +0100 @@ -1,7 +1,7 @@ From 561280a0ea35f226ef243526be2bbb656db44af6 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko <[email protected]> Date: Mon, 10 Sep 2018 23:40:18 +0200 -Subject: [PATCH 02/10] generate %doc statements +Subject: [PATCH 02/14] generate %doc statements Signed-off-by: Igor Gnatenko <[email protected]> --- @@ -54,5 +54,5 @@ {% endif %} -- -2.19.1 +2.20.1 ++++++ 0003-do-better-for-renamed-crates.patch ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.708438323 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.708438323 +0100 @@ -1,7 +1,7 @@ From 2050880140d4953b9ebdc7211e30df3ccf5dd61d Mon Sep 17 00:00:00 2001 From: Igor Gnatenko <[email protected]> Date: Tue, 11 Sep 2018 00:06:50 +0200 -Subject: [PATCH 03/10] do better for renamed crates +Subject: [PATCH 03/14] do better for renamed crates Signed-off-by: Igor Gnatenko <[email protected]> --- @@ -86,5 +86,5 @@ %build -- -2.19.1 +2.20.1 ++++++ 0004-remove-pre-3.6-leftovers.patch ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.720438321 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.720438321 +0100 @@ -1,7 +1,7 @@ From e6e9cbbb71199c2773b47fa21f1c917a167c1743 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko <[email protected]> Date: Tue, 11 Sep 2018 10:43:53 +0200 -Subject: [PATCH 04/10] remove pre-3.6 leftovers +Subject: [PATCH 04/14] remove pre-3.6 leftovers Signed-off-by: Igor Gnatenko <[email protected]> --- @@ -23,5 +23,5 @@ + "--manifest-path={}".format(path)]) return cls.from_json(json.loads(metadata)) -- -2.19.1 +2.20.1 ++++++ 0005-Remove-half-downloaded-crate-on-C.patch ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.728438320 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.728438320 +0100 @@ -1,7 +1,7 @@ From 2f12c83d14afe71e9efed2d1be62e1e610e602e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <[email protected]> Date: Fri, 17 Aug 2018 10:03:48 +0200 -Subject: [PATCH 05/10] 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 @@ total=total, unit="B", unit_scale=True): f.write(chunk) -- -2.19.1 +2.20.1 ++++++ 0006-Throw-an-error-if-s-is-used-without-a-crate.patch ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.736438318 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.736438318 +0100 @@ -1,7 +1,7 @@ From 5a1cde5b8dcaea74ebb2050879036bf46df63adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <[email protected]> Date: Fri, 17 Aug 2018 10:18:59 +0200 -Subject: [PATCH 06/10] 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 @@ diff = make_patch(toml, enabled=patch, tmpfile=True) metadata = Metadata.from_file(toml) -- -2.19.1 +2.20.1 ++++++ 0007-split-features-into-subpackages.patch ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.744438317 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.748438316 +0100 @@ -1,7 +1,7 @@ From 2cac5e5ad5ff5472923ce333bef59679612bbaa2 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko <[email protected]> Date: Fri, 26 Oct 2018 11:20:13 +0200 -Subject: [PATCH 07/10] 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 <[email protected]> @@ -1060,5 +1060,5 @@ - assert [str(x) for x in md.provides] == provides - assert [str(x) for x in md.requires] == requires -- -2.19.1 +2.20.1 ++++++ 0008-add-support-for-dependencies-with-same-name.patch ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.752438315 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.756438314 +0100 @@ -1,7 +1,7 @@ From a1d3a84645aa7bbe5ca07b60bead1ddf90a21cc1 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko <[email protected]> Date: Tue, 30 Oct 2018 20:37:38 +0100 -Subject: [PATCH 08/10] add support for dependencies with same name +Subject: [PATCH 08/14] add support for dependencies with same name Reported-by: Josh Stone <[email protected]> References: https://internals.rust-lang.org/t/optional-dependencies-with-same-name/8728 @@ -70,5 +70,5 @@ if "default" not in deps_by_feature: -- -2.19.1 +2.20.1 ++++++ 0009-add-support-for-feeding-user-configuration.patch ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.764438313 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.764438313 +0100 @@ -1,7 +1,7 @@ From 197150ee2e862edcd46f7ab02c9e4d17e49ca75d Mon Sep 17 00:00:00 2001 From: Igor Gnatenko <[email protected]> Date: Wed, 31 Oct 2018 18:03:21 +0100 -Subject: [PATCH 09/10] add support for feeding user configuration +Subject: [PATCH 09/14] add support for feeding user configuration Signed-off-by: Igor Gnatenko <[email protected]> --- @@ -144,5 +144,5 @@ %description {{ pkg }} %{_description} -- -2.19.1 +2.20.1 ++++++ 0010-trivial-use-f-strings-everywhere.patch ++++++ --- /var/tmp/diff_new_pack.l5MXDI/_old 2019-03-06 15:51:11.772438311 +0100 +++ /var/tmp/diff_new_pack.l5MXDI/_new 2019-03-06 15:51:11.772438311 +0100 @@ -1,7 +1,7 @@ From 83ea3796cd28ec7689b39e7dc7a70bd11af1abf1 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko <[email protected]> Date: Wed, 31 Oct 2018 17:00:58 +0100 -Subject: [PATCH 10/10] trivial: use f-strings everywhere +Subject: [PATCH 10/14] trivial: use f-strings everywhere Signed-off-by: Igor Gnatenko <[email protected]> --- @@ -90,5 +90,5 @@ else: with open(spec_file, "w") as fobj: -- -2.19.1 +2.20.1 ++++++ 0101-Add-option-to-not-generate-a-default-changelog-entry.patch -> 0011-Add-option-to-not-generate-a-default-changelog-entry.patch ++++++ --- /work/SRC/openSUSE:Factory/rust-packaging/0101-Add-option-to-not-generate-a-default-changelog-entry.patch 2018-11-26 10:19:44.509772702 +0100 +++ /work/SRC/openSUSE:Factory/.rust-packaging.new.28833/0011-Add-option-to-not-generate-a-default-changelog-entry.patch 2019-03-06 15:51:07.872439009 +0100 @@ -1,7 +1,7 @@ From 294c6f571c0f4f7ed5a4fcb34142b0d332c55f29 Mon Sep 17 00:00:00 2001 From: Neal Gompa <[email protected]> Date: Sun, 11 Nov 2018 11:06:27 -0500 -Subject: [PATCH] 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 <pkg>.changes file that is @@ -59,5 +59,5 @@ + {% include target ~ "-changelog.spec.inc" %} +{% endif %} -- -2.17.2 +2.20.1 ++++++ 0012-Set-CARGO_HOME-to-the-local-.config.patch ++++++ >From b4e25038296cd57eba639a059e8baaf139a5d287 Mon Sep 17 00:00:00 2001 From: Josh Stone <[email protected]> Date: Fri, 7 Dec 2018 13:58:41 -0800 Subject: [PATCH 12/14] Set CARGO_HOME to the local .config --- data/macros.cargo | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data/macros.cargo b/data/macros.cargo index 7fb025b..e760721 100644 --- a/data/macros.cargo +++ b/data/macros.cargo @@ -1,4 +1,8 @@ -%__cargo %{_bindir}/cargo +# Since cargo 1.31, install only uses $CARGO_HOME/config, ignoring $PWD. +# https://github.com/rust-lang/cargo/issues/6397 +# But we can set CARGO_HOME locally, which is a good idea anyway to make sure +# it never writes to ~/.cargo during rpmbuild. +%__cargo %{_bindir}/env CARGO_HOME=.cargo %{_bindir}/cargo %__cargo_common_opts %{?_smp_mflags} %__cargo_inspector %{_bindir}/cargo-inspector -- 2.20.1 ++++++ 0013-Set-the-install-root-in-.cargo-config.patch ++++++ >From a04e95bc4f807139bd3c4b75f46fd9a60ec1db8f Mon Sep 17 00:00:00 2001 From: Josh Stone <[email protected]> Date: Fri, 7 Dec 2018 13:59:03 -0800 Subject: [PATCH 13/14] Set the install root in .cargo/config --- data/macros.cargo | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/data/macros.cargo b/data/macros.cargo index e760721..9a9ce6a 100644 --- a/data/macros.cargo +++ b/data/macros.cargo @@ -20,6 +20,9 @@ rustc = "%{__rustc}"\ rustdoc = "%{__rustdoc}"\ rustflags = %{__global_rustflags_toml}\ \ +[install]\ +root = "%{buildroot}%{_prefix}"\ +\ [term]\ verbose = true\ \ @@ -81,7 +84,6 @@ if %__cargo_is_bin; then \ %{shrink:%{__cargo} install \ %{__cargo_common_opts} \ --path . \ - --root %{buildroot}%{_prefix} \ %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ %* \ }\ -- 2.20.1 ++++++ 0014-Add-support-for-prerelease-versions.patch ++++++ >From cfe4e77674ccb6e25e54a3749f4ef91b377e808f Mon Sep 17 00:00:00 2001 From: Igor Gnatenko <[email protected]> Date: Sat, 26 Jan 2019 08:33:37 +0100 Subject: [PATCH 14/14] Add support for prerelease versions Signed-off-by: Igor Gnatenko <[email protected]> --- data/macros.rust-srpm | 38 ++++++++++++++++++++++++++++++++++++ rust2rpm/metadata.py | 18 +++++++++++------ rust2rpm/templates/main.spec | 10 +++------- test.py | 8 ++++++++ 4 files changed, 61 insertions(+), 13 deletions(-) diff --git a/data/macros.rust-srpm b/data/macros.rust-srpm index f2bae9d..872b87f 100644 --- a/data/macros.rust-srpm +++ b/data/macros.rust-srpm @@ -1 +1,39 @@ %rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x +%version_no_tilde() %{lua: + local sep = rpm.expand('%1') + local ver = rpm.expand('%2') +\ + if sep == '%1' then + sep = '-' + end +\ + if ver == '%2' then + ver = rpm.expand('%version') + end + ver = ver:gsub('~', sep) +\ + print(ver) +} +%__crates_url https://crates.io/api/v1/crates/ +%crates_source() %{lua: + local crate = rpm.expand('%1') + local version = rpm.expand('%2') + local url = rpm.expand('%__crates_url') +\ + if crate == '%1' then + crate = rpm.expand('%real_crate') + end + if crate == '%real_crate' then + crate = rpm.expand('%crate') + end + if crate == '%crate' then + crate = rpm.expand('%name') + end +\ + if version == '%2' then + version = rpm.expand('%version') + end + version = version:gsub('~', '-') +\ + print(url .. crate .. '/' .. version .. '/download#/' .. crate .. '-' .. version .. '.crate') +} 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/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec index 84bd97d..1ebef7b 100644 --- a/rust2rpm/templates/main.spec +++ b/rust2rpm/templates/main.spec @@ -31,11 +31,7 @@ License: {{ license|default("# FIXME") }} {{ license_comments }} {% endif %} URL: https://crates.io/crates/{{ crate }} -{% if md.name != crate %} -Source0: https://crates.io/api/v1/crates/%{real_crate}/%{version}/download#/%{crate}-%{version}.crate -{% else %} -Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate -{% endif %} +Source: %{crates_source} {% if patch_file is not none %} {% if target == "opensuse" %} # PATCH-FIX-OPENSUSE {{ patch_file }} -- Initial patched metadata @@ -161,9 +157,9 @@ which use {% if feature is not none %}"{{ feature }}" feature of {% endif %}"%{c %prep {% if md.name != crate %} -%autosetup -n %{real_crate}-%{version} -p1 +%autosetup -n %{real_crate}-%{version_no_tilde} -p1 {% else %} -%autosetup -n %{crate}-%{version} -p1 +%autosetup -n %{crate}-%{version_no_tilde} -p1 {% endif %} %cargo_prep 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
