From d2aad3723f7f9947c255ceb83a975be8c039e17e Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sun, 5 Feb 2017 12:07:49 +0100 Subject: [PATCH] try to automatically generate license out of metadata Signed-off-by: Igor Gnatenko --- cargodeps.py | 4 ++++ rust2rpm.py | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cargodeps.py b/cargodeps.py index ac7b639..279da32 100755 --- a/cargodeps.py +++ b/cargodeps.py @@ -32,6 +32,8 @@ class Dependency(object): class Metadata(object): def __init__(self): self.name = None + self.license = None + self.license_file = None self._version = None self._provides = [] self._requires = [] @@ -47,6 +49,8 @@ class Metadata(object): md = metadata["packages"][0] self.name = md["name"] + self.license = md["license"] + self.license_file = md["license_file"] self._version = semver.SpecItem("={}".format(md["version"])) # Provides diff --git a/rust2rpm.py b/rust2rpm.py index e92d018..b2c3192 100644 --- a/rust2rpm.py +++ b/rust2rpm.py @@ -21,7 +21,7 @@ Version: {{ md.version }} Release: 1%{?dist} Summary: # FIXME -License: # FIXME +License: {{ md.license if md.license is not none else "# FIXME" }} URL: https://crates.io/crates/{{ md.name }} Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate @@ -80,7 +80,9 @@ Conflicts: {{ con }} %endif %files devel -%license # FIXME +{% if md.license_file is not none %} +%license {{ md.license_file }} +{% endif %} %{cargo_registry}/%{crate}-%{version}/ %changelog