You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.1 KiB
91 lines
3.1 KiB
6 years ago
|
From 2050880140d4953b9ebdc7211e30df3ccf5dd61d Mon Sep 17 00:00:00 2001
|
||
|
From: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
|
||
|
Date: Tue, 11 Sep 2018 00:06:50 +0200
|
||
|
Subject: [PATCH 3/7] do better for renamed crates
|
||
|
|
||
|
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
|
||
|
---
|
||
|
rust2rpm/__main__.py | 7 ++++---
|
||
|
rust2rpm/templates/main.spec | 13 ++++++++++++-
|
||
|
2 files changed, 16 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py
|
||
|
index 1575ce6..e993e7b 100644
|
||
|
--- a/rust2rpm/__main__.py
|
||
|
+++ b/rust2rpm/__main__.py
|
||
|
@@ -180,7 +180,7 @@ def make_diff_metadata(crate, version, patch=False, store=False):
|
||
|
diff = make_patch(toml, enabled=patch)
|
||
|
metadata = Metadata.from_file(toml)
|
||
|
if store:
|
||
|
- shutil.copy2(cratef, os.path.join(os.getcwd(), f"{crate}-{version}.crate"))
|
||
|
+ shutil.copy2(cratef, os.path.join(os.getcwd(), f"{metadata.name}-{version}.crate"))
|
||
|
return crate, diff, metadata
|
||
|
|
||
|
def main():
|
||
|
@@ -218,11 +218,12 @@ def main():
|
||
|
template = JINJA_ENV.get_template("main.spec")
|
||
|
|
||
|
if args.patch and len(diff) > 0:
|
||
|
- patch_file = "{}-fix-metadata.diff".format(metadata.name)
|
||
|
+ patch_file = f"{metadata.name}-fix-metadata.diff"
|
||
|
else:
|
||
|
patch_file = None
|
||
|
|
||
|
kwargs = {}
|
||
|
+ kwargs["crate"] = crate
|
||
|
kwargs["target"] = args.target
|
||
|
bins = [tgt for tgt in metadata.targets if tgt.kind == "bin"]
|
||
|
libs = [tgt for tgt in metadata.targets if tgt.kind in ("lib", "rlib", "proc-macro")]
|
||
|
@@ -269,7 +270,7 @@ def main():
|
||
|
kwargs["license"] = license
|
||
|
kwargs["license_comments"] = comments
|
||
|
|
||
|
- spec_file = "rust-{}.spec".format(metadata.name)
|
||
|
+ spec_file = f"rust-{metadata.name}.spec"
|
||
|
spec_contents = template.render(md=metadata, patch_file=patch_file, **kwargs)
|
||
|
if args.stdout:
|
||
|
print("# {}".format(spec_file))
|
||
|
diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec
|
||
|
index 2e9f841..7dbcc3f 100644
|
||
|
--- a/rust2rpm/templates/main.spec
|
||
|
+++ b/rust2rpm/templates/main.spec
|
||
|
@@ -6,6 +6,9 @@
|
||
|
{% endif %}
|
||
|
|
||
|
%global crate {{ md.name }}
|
||
|
+{% if md.name != crate %}
|
||
|
+%global real_crate {{ crate }}
|
||
|
+{% endif %}
|
||
|
|
||
|
Name: rust-%{crate}
|
||
|
Version: {{ md.version }}
|
||
|
@@ -27,8 +30,12 @@ License: {{ license|default("# FIXME") }}
|
||
|
{% if license_comments is not none %}
|
||
|
{{ license_comments }}
|
||
|
{% endif %}
|
||
|
-URL: https://crates.io/crates/{{ md.name }}
|
||
|
+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 %}
|
||
|
{% if patch_file is not none %}
|
||
|
{% if target == "opensuse" %}
|
||
|
# PATCH-FIX-OPENSUSE {{ patch_file }} -- Initial patched metadata
|
||
|
@@ -118,7 +125,11 @@ which use %{crate} from crates.io.
|
||
|
|
||
|
{% endif %}
|
||
|
%prep
|
||
|
+{% if md.name != crate %}
|
||
|
+%autosetup -n %{real_crate}-%{version} -p1
|
||
|
+{% else %}
|
||
|
%autosetup -n %{crate}-%{version} -p1
|
||
|
+{% endif %}
|
||
|
%cargo_prep
|
||
|
|
||
|
%build
|
||
|
--
|
||
|
2.19.1
|
||
|
|