diff --git a/0001-templates-Do-not-put-empty-line-after-changelog.patch b/0001-templates-Do-not-put-empty-line-after-changelog.patch new file mode 100644 index 0000000..00bd68f --- /dev/null +++ b/0001-templates-Do-not-put-empty-line-after-changelog.patch @@ -0,0 +1,26 @@ +From b1df4d587fb03dcaedd7e8f29fbe5b7265ea5638 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Mon, 6 May 2019 10:43:05 +0200 +Subject: [PATCH 01/14] templates: Do not put empty line after %changelog + +Signed-off-by: Igor Gnatenko +--- + rust2rpm/templates/main.spec | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec +index dcd24ca..0c84325 100644 +--- a/rust2rpm/templates/main.spec ++++ b/rust2rpm/templates/main.spec +@@ -183,6 +183,7 @@ echo {{ "%r"|format(req) }} + %endif + + %changelog +-{% if auto_changelog_entry %} ++{%- if auto_changelog_entry %} ++ + {% include target ~ "-changelog.spec.inc" %} + {% endif %} +-- +2.22.0.rc3 + diff --git a/0002-licensing-translate-GPL-123.patch b/0002-licensing-translate-GPL-123.patch new file mode 100644 index 0000000..559941f --- /dev/null +++ b/0002-licensing-translate-GPL-123.patch @@ -0,0 +1,43 @@ +From 1f64bd9564c0cc27d23f5dc5e523f0db46496644 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Mon, 6 May 2019 22:08:07 +0200 +Subject: [PATCH 02/14] licensing: translate GPL[123]+ + +The "+" variants were described in the comment, but not explicitly +listed in the table. Let's just replace the comment with +machine-readable lines. + +Fixes #79. +--- + rust2rpm/spdx_to_fedora.csv | 15 ++++++--------- + 1 file changed, 6 insertions(+), 9 deletions(-) + +diff --git a/rust2rpm/spdx_to_fedora.csv b/rust2rpm/spdx_to_fedora.csv +index c42e66e..4fc3321 100644 +--- a/rust2rpm/spdx_to_fedora.csv ++++ b/rust2rpm/spdx_to_fedora.csv +@@ -141,15 +141,12 @@ GNU Affero General Public License v3.0,AGPL-3.0,AGPLv3,Affero General Public Lic + GNU Free Documentation License v1.1,GFDL-1.1,,,This specific version not on Fedora list, + GNU Free Documentation License v1.2,GFDL-1.2,,,This specific version not on Fedora list, + GNU Free Documentation License v1.3,GFDL-1.3,GFDL,,, +-GNU General Public License v1.0 only,GPL-1.0,GPLv1,,"For “or later” add + to SPDX or Fedora short identifier: +-SPDX: GPL-1.0+ +-Fedora: GPLv1+ or GPL+", +-GNU General Public License v2.0 only,GPL-2.0,GPLv2,,"For “or later” add + to SPDX or Fedora short identifier: +-SPDX: GPL-2.0+ +-Fedora: GPLv2+", +-GNU General Public License v3.0 only,GPL-3.0,GPLv3,,"For “or later” add + to SPDX or Fedora short identifier: +-SPDX: GPL-3.0+ +-Fedora: GPLv3+", ++GNU General Public License v1.0 only,GPL-1.0,GPLv1,,, ++GNU General Public License v1.0 or later,GPL-1.0+,GPLv1+,,, ++GNU General Public License v2.0 only,GPL-2.0,GPLv2,,, ++GNU General Public License v2.0 or later,GPL-2.0+,GPLv2+,,, ++GNU General Public License v3.0 only,GPL-3.0,GPLv3,,, ++GNU General Public License v3.0 or later,GPL-3.0+,GPLv3+,,, + GNU Lesser General Public License v2.1 only,LGPL-2.1,LGPLv2,,, + GNU Lesser General Public License v3.0 only,LGPL-3.0,LGPLv3,,, + GNU Library General Public License v2 only,LGPL-2.0,LGPLv2,,, +-- +2.22.0.rc3 + diff --git a/0003-licensing-add-or-later-variants-for-GPL-licenses.patch b/0003-licensing-add-or-later-variants-for-GPL-licenses.patch new file mode 100644 index 0000000..6ac4be3 --- /dev/null +++ b/0003-licensing-add-or-later-variants-for-GPL-licenses.patch @@ -0,0 +1,32 @@ +From 8d21ef1ee4152294c3e9df451404db7c732fb415 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 7 May 2019 08:32:25 +0200 +Subject: [PATCH 03/14] licensing: add "-or-later" variants for GPL licenses + +SPDX actually deprecated the variants with "+" and "-or-later" is now +recommneded. They both map to the same identiefiers on Fedora side. +--- + rust2rpm/spdx_to_fedora.csv | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/rust2rpm/spdx_to_fedora.csv b/rust2rpm/spdx_to_fedora.csv +index 4fc3321..a3f9604 100644 +--- a/rust2rpm/spdx_to_fedora.csv ++++ b/rust2rpm/spdx_to_fedora.csv +@@ -143,10 +143,13 @@ GNU Free Documentation License v1.2,GFDL-1.2,,,This specific version not on Fedo + GNU Free Documentation License v1.3,GFDL-1.3,GFDL,,, + GNU General Public License v1.0 only,GPL-1.0,GPLv1,,, + GNU General Public License v1.0 or later,GPL-1.0+,GPLv1+,,, ++GNU General Public License v1.0 or later,GPL-1.0-or-later,GPLv1+,,, + GNU General Public License v2.0 only,GPL-2.0,GPLv2,,, + GNU General Public License v2.0 or later,GPL-2.0+,GPLv2+,,, ++GNU General Public License v2.0 or later,GPL-2.0-or-later,GPLv2+,,, + GNU General Public License v3.0 only,GPL-3.0,GPLv3,,, + GNU General Public License v3.0 or later,GPL-3.0+,GPLv3+,,, ++GNU General Public License v3.0 or later,GPL-3.0-or-later,GPLv3+,,, + GNU Lesser General Public License v2.1 only,LGPL-2.1,LGPLv2,,, + GNU Lesser General Public License v3.0 only,LGPL-3.0,LGPLv3,,, + GNU Library General Public License v2 only,LGPL-2.0,LGPLv2,,, +-- +2.22.0.rc3 + diff --git a/0004-Move-version-string-to-the-python-code.patch b/0004-Move-version-string-to-the-python-code.patch new file mode 100644 index 0000000..9f04d6c --- /dev/null +++ b/0004-Move-version-string-to-the-python-code.patch @@ -0,0 +1,48 @@ +From aa9fc8646a4bcf43bba544d37c2f6e6e59b1bebb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Mon, 6 May 2019 22:34:02 +0200 +Subject: [PATCH 04/14] Move version string to the python code + +This way the python module "knows" its own version. To avoid duplication, +read the value back from setup.py. The reader function only needs to +support the specific format used in the code, so it can be very simplistic. +--- + rust2rpm/__init__.py | 2 ++ + setup.py | 11 ++++++++++- + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/rust2rpm/__init__.py b/rust2rpm/__init__.py +index 6aba575..4a0db7b 100644 +--- a/rust2rpm/__init__.py ++++ b/rust2rpm/__init__.py +@@ -1,2 +1,4 @@ + from .metadata import * + from . import licensing ++ ++__version__ = '9' +diff --git a/setup.py b/setup.py +index 3eb2a77..79367da 100644 +--- a/setup.py ++++ b/setup.py +@@ -1,8 +1,17 @@ + from setuptools import setup + ++def read_version(path): ++ with open(path, 'rt') as f: ++ for line in f: ++ if line.startswith('__version__'): ++ return line.split("'")[1] ++ raise IOError ++ ++version = read_version('rust2rpm/__init__.py') ++ + ARGS = dict( + name="rust2rpm", +- version="9", ++ version=version, + description="Convert Rust crates to RPM", + license="MIT", + keywords="rust cargo rpm", +-- +2.22.0.rc3 + diff --git a/0005-Check-usr-lib-os-release-in-addition-to-etc-os-relea.patch b/0005-Check-usr-lib-os-release-in-addition-to-etc-os-relea.patch new file mode 100644 index 0000000..ed5472f --- /dev/null +++ b/0005-Check-usr-lib-os-release-in-addition-to-etc-os-relea.patch @@ -0,0 +1,31 @@ +From 253d1f6021765051c26d4427967786040d215853 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Mon, 6 May 2019 22:36:43 +0200 +Subject: [PATCH 05/14] Check /usr/lib/os-release in addition to + /etc/os-release + +--- + rust2rpm/__main__.py | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py +index b307505..b8d3772 100644 +--- a/rust2rpm/__main__.py ++++ b/rust2rpm/__main__.py +@@ -34,8 +34,11 @@ JINJA_ENV = jinja2.Environment( + lstrip_blocks=True) + + def get_default_target(): +- # TODO: add fallback for /usr/lib/os-release +- with open("/etc/os-release") as os_release_file: ++ try: ++ os_release_file = open('/etc/os-release') ++ except FileNotFoundError: ++ os_release_file = open('/usr/lib/os-release') ++ with os_release_file: + conf = configparser.ConfigParser() + conf.read_file(itertools.chain(["[os-release]"], os_release_file)) + os_release = conf["os-release"] +-- +2.22.0.rc3 + diff --git a/0006-Include-rust2rpm-version-info-in-the-generated-spec-.patch b/0006-Include-rust2rpm-version-info-in-the-generated-spec-.patch new file mode 100644 index 0000000..7f332f9 --- /dev/null +++ b/0006-Include-rust2rpm-version-info-in-the-generated-spec-.patch @@ -0,0 +1,47 @@ +From 6de75b87af4bd86d87dfee038f5b6cdf99437a7c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Mon, 6 May 2019 22:44:55 +0200 +Subject: [PATCH 06/14] Include rust2rpm version info in the generated spec + file + +Fixes #77. +--- + rust2rpm/__main__.py | 3 ++- + rust2rpm/templates/main.spec | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py +index b8d3772..a7674fd 100644 +--- a/rust2rpm/__main__.py ++++ b/rust2rpm/__main__.py +@@ -17,7 +17,7 @@ import jinja2 + import requests + import tqdm + +-from . import Metadata, licensing ++from . import Metadata, licensing, __version__ + from .metadata import normalize_deps + + DEFAULT_EDITOR = "vi" +@@ -265,6 +265,7 @@ def main(): + patch_file = None + + kwargs = {} ++ kwargs["generator_version"] = __version__ + kwargs["crate"] = crate + kwargs["target"] = args.target + kwargs["all_features"] = args.all_features +diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec +index 0c84325..0ef0b10 100644 +--- a/rust2rpm/templates/main.spec ++++ b/rust2rpm/templates/main.spec +@@ -1,5 +1,5 @@ + {% include target ~ "-header.spec.inc" ignore missing %} +-# Generated by rust2rpm ++# Generated by rust2rpm {{ generator_version }} + %bcond_without check + {% if not include_main %} + %global debug_package %{nil} +-- +2.22.0.rc3 + diff --git a/0007-Bump-classifiers.patch b/0007-Bump-classifiers.patch new file mode 100644 index 0000000..6967f8d --- /dev/null +++ b/0007-Bump-classifiers.patch @@ -0,0 +1,34 @@ +From 36663449594b33ec4b0c0ae9ea568cad819bb920 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Mon, 6 May 2019 22:47:06 +0200 +Subject: [PATCH 07/14] Bump classifiers + +This software is used, so let's at least it's beta. +Seems to work fine with python3.8, let's say that. +--- + setup.py | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/setup.py b/setup.py +index 79367da..b5b1157 100644 +--- a/setup.py ++++ b/setup.py +@@ -44,13 +44,14 @@ ARGS = dict( + author_email="ignatenkobrain@fedoraproject.org", + url="https://pagure.io/fedora-rust/rust2rpm", + classifiers=[ +- "Development Status :: 3 - Alpha", ++ "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", ++ "Programming Language :: Python :: 3.8", + "Topic :: Software Development :: Build Tools", + "Topic :: System :: Software Distribution", + "Topic :: Utilities", +-- +2.22.0.rc3 + diff --git a/0008-Mangle-summary-automagically.patch b/0008-Mangle-summary-automagically.patch new file mode 100644 index 0000000..9f6fbcc --- /dev/null +++ b/0008-Mangle-summary-automagically.patch @@ -0,0 +1,85 @@ +From 216de8e4271f9dbca1f009e8c0e046a7f5a198fd Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Wed, 15 May 2019 08:01:46 +0200 +Subject: [PATCH 08/14] Mangle summary automagically + +Signed-off-by: Igor Gnatenko +--- + rust2rpm/metadata.py | 35 ++++++++++++++++++++++++++++++++++- + rust2rpm/templates/main.spec | 3 +-- + 2 files changed, 35 insertions(+), 3 deletions(-) + +diff --git a/rust2rpm/metadata.py b/rust2rpm/metadata.py +index 77c2932..e41902d 100644 +--- a/rust2rpm/metadata.py ++++ b/rust2rpm/metadata.py +@@ -3,6 +3,7 @@ __all__ = ["Dependency", "Metadata"] + import collections + import copy + import json ++import re + import subprocess + + import semantic_version as semver +@@ -116,11 +117,43 @@ class Metadata: + self.license = None + self.license_file = None + self.readme = None +- self.description = None ++ self._description = None ++ self._summary = None + self.targets = set() + self.dependencies = {} + self.dev_dependencies = set() + ++ @property ++ def description(self): ++ return self._description ++ ++ @property ++ def summary(self): ++ return self._summary ++ ++ @description.setter ++ def description(self, description): ++ # https://salsa.debian.org/rust-team/debcargo/blob/master/src/crates.rs ++ # get_summary_description() ++ if description is None: ++ self._description = self._summary = None ++ return ++ description = description.replace('\n\n', '\r').replace('\n', ' ').replace('\r', '\n').strip() ++ description = re.sub(r'^(?:a|an|the)\s+', '', description, flags=re.I) ++ description = f'{description[0].upper()}{description[1:]}' ++ if description[-1] != '.': ++ description = f'{description}.' ++ ++ p1 = description.find('.') ++ p2 = description.find('\n') ++ if p2 != -1: ++ p = min(p1, p2) ++ else: ++ p = p1 ++ ++ self._description = description ++ self._summary = description[:p] ++ + @classmethod + def from_json(cls, metadata): + md = metadata +diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec +index 0ef0b10..803b74e 100644 +--- a/rust2rpm/templates/main.spec ++++ b/rust2rpm/templates/main.spec +@@ -16,8 +16,7 @@ Release: {{ pkg_release }} + {% if md.description is none %} + Summary: # FIXME + {% else %} +-{% set description_lines = md.description.split("\n") %} +-Summary: {{ description_lines|join(" ")|trim }} ++Summary: {{ md.summary }} + {% endif %} + {% if rust_group is defined %} + Group: {{ rust_group }} +-- +2.22.0.rc3 + diff --git a/0009-Use-expand-for-description.patch b/0009-Use-expand-for-description.patch new file mode 100644 index 0000000..c2ecfdf --- /dev/null +++ b/0009-Use-expand-for-description.patch @@ -0,0 +1,41 @@ +From 16085843c800827526ab78354bacdd6bd388993f Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Wed, 15 May 2019 08:07:18 +0200 +Subject: [PATCH 09/14] =?UTF-8?q?Use=20%{expand:=E2=80=A6}=20for=20descrip?= + =?UTF-8?q?tion?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +So that we stop playing with escaping. + +Signed-off-by: Igor Gnatenko +--- + rust2rpm/templates/main.spec | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec +index 803b74e..660bb60 100644 +--- a/rust2rpm/templates/main.spec ++++ b/rust2rpm/templates/main.spec +@@ -64,12 +64,13 @@ BuildRequires: {{ req }} + {% endfor %} + {% endif %} + +-%global _description \ ++%global _description %{expand: + {% if md.description is none %} + %{summary}. +-{% else %} +-{{ md.description|wordwrap(wrapstring="\\\n")|trim }} +-{% endif %} ++{%- else %} ++{{ md.description|wordwrap }} ++{%- endif %} ++} + + %description %{_description} + +-- +2.22.0.rc3 + diff --git a/0010-Remove-more-common-prefixes.patch b/0010-Remove-more-common-prefixes.patch new file mode 100644 index 0000000..c22444a --- /dev/null +++ b/0010-Remove-more-common-prefixes.patch @@ -0,0 +1,25 @@ +From e1cfff321693432f19a9a1303431b2ce4ec4edc9 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Wed, 15 May 2019 20:00:59 +0200 +Subject: [PATCH 10/14] Remove more common prefixes + +Signed-off-by: Igor Gnatenko +--- + rust2rpm/metadata.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/rust2rpm/metadata.py b/rust2rpm/metadata.py +index e41902d..1b4faad 100644 +--- a/rust2rpm/metadata.py ++++ b/rust2rpm/metadata.py +@@ -139,6 +139,7 @@ class Metadata: + self._description = self._summary = None + return + description = description.replace('\n\n', '\r').replace('\n', ' ').replace('\r', '\n').strip() ++ description = re.sub(rf'^(?:{self.name}|This(?:\s+\w+)?)(?:\s*,|\s+is|\s+provides)\s+', '', description, flags=re.I) + description = re.sub(r'^(?:a|an|the)\s+', '', description, flags=re.I) + description = f'{description[0].upper()}{description[1:]}' + if description[-1] != '.': +-- +2.22.0.rc3 + diff --git a/0011-Add-AGPL-3.0-or-later-and-automatically-translate-su.patch b/0011-Add-AGPL-3.0-or-later-and-automatically-translate-su.patch new file mode 100644 index 0000000..6679e3a --- /dev/null +++ b/0011-Add-AGPL-3.0-or-later-and-automatically-translate-su.patch @@ -0,0 +1,73 @@ +From 04f63e0f20d6b517119053c6bc00aa8be3c3a19f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Sun, 2 Jun 2019 15:48:45 +0200 +Subject: [PATCH 11/14] Add AGPL-3.0-or-later and automatically translate "+" + suffix into "-or-later" + +This way we don't need to add all the deprecated variants with "+" suffix. + +Fixes #84. +--- + rust2rpm/licensing.py | 14 ++++++++++---- + rust2rpm/spdx_to_fedora.csv | 4 +--- + 2 files changed, 11 insertions(+), 7 deletions(-) + +diff --git a/rust2rpm/licensing.py b/rust2rpm/licensing.py +index 233903e..6ca4e45 100644 +--- a/rust2rpm/licensing.py ++++ b/rust2rpm/licensing.py +@@ -35,18 +35,24 @@ def translate_license_fedora(license): + elif tag.upper() == 'AND': + final.append('and') + else: +- mapped = spdx_to_fedora_map().get(tag, None) ++ if tag.endswith('+'): ++ key = tag[:-1] + '-or-later' ++ fulltag = f'{tag} ({key})' ++ else: ++ key = fulltag = tag ++ ++ mapped = spdx_to_fedora_map().get(key, None) + if mapped is None: +- comments += f'# FIXME: Upstream uses unknown SPDX tag {tag}!' ++ comments += f'# FIXME: Upstream uses unknown SPDX tag {fulltag}!' + final.append(tag) + elif mapped == '': +- comments += f"# FIXME: Upstream SPDX tag {tag} not listed in Fedora's good licenses list.\n" ++ comments += f"# FIXME: Upstream SPDX tag {fulltag} not listed in Fedora's good licenses list.\n" + comments += "# FIXME: This package might not be allowed in Fedora!\n" + final.append(tag) + else: + final.append(mapped) + if mapped != tag: +- print(f'Upstream license tag {tag} translated to {mapped}', ++ print(f'Upstream license tag {fulltag} translated to {mapped}', + file=_sys.stderr) + return (' '.join(final), comments or None) + +diff --git a/rust2rpm/spdx_to_fedora.csv b/rust2rpm/spdx_to_fedora.csv +index a3f9604..006d80c 100644 +--- a/rust2rpm/spdx_to_fedora.csv ++++ b/rust2rpm/spdx_to_fedora.csv +@@ -138,17 +138,15 @@ Giftware License,Giftware,Giftware,,, + GL2PS License,GL2PS,GL2PS,,, + Glulxe License,Glulxe,Glulxe,,, + GNU Affero General Public License v3.0,AGPL-3.0,AGPLv3,Affero General Public License 3.0,, ++GNU Affero General Public License v3.0 or later,AGPL-3.0-or-later,AGPLv3+,Affero General Public License 3.0 or later,, + GNU Free Documentation License v1.1,GFDL-1.1,,,This specific version not on Fedora list, + GNU Free Documentation License v1.2,GFDL-1.2,,,This specific version not on Fedora list, + GNU Free Documentation License v1.3,GFDL-1.3,GFDL,,, + GNU General Public License v1.0 only,GPL-1.0,GPLv1,,, +-GNU General Public License v1.0 or later,GPL-1.0+,GPLv1+,,, + GNU General Public License v1.0 or later,GPL-1.0-or-later,GPLv1+,,, + GNU General Public License v2.0 only,GPL-2.0,GPLv2,,, +-GNU General Public License v2.0 or later,GPL-2.0+,GPLv2+,,, + GNU General Public License v2.0 or later,GPL-2.0-or-later,GPLv2+,,, + GNU General Public License v3.0 only,GPL-3.0,GPLv3,,, +-GNU General Public License v3.0 or later,GPL-3.0+,GPLv3+,,, + GNU General Public License v3.0 or later,GPL-3.0-or-later,GPLv3+,,, + GNU Lesser General Public License v2.1 only,LGPL-2.1,LGPLv2,,, + GNU Lesser General Public License v3.0 only,LGPL-3.0,LGPLv3,,, +-- +2.22.0.rc3 + diff --git a/0012-Add-translate-license-to-translate-a-specific-licens.patch b/0012-Add-translate-license-to-translate-a-specific-licens.patch new file mode 100644 index 0000000..18e32a2 --- /dev/null +++ b/0012-Add-translate-license-to-translate-a-specific-licens.patch @@ -0,0 +1,50 @@ +From d9b2cef72e129963ac082ec3737a877785232123 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Sun, 2 Jun 2019 15:45:13 +0200 +Subject: [PATCH 12/14] Add --translate-license to translate a specific license + +Before, all known licenses would be listed by --show-license-map, so +grepping the list was enough to find a license. But now we support +alternative syntaxes, so this is not enough. Add a call to translate a +specific license: + +$ python3 -m rust2rpm --translate-license GPL-3.0+ +Upstream license tag GPL-3.0+ (GPL-3.0-or-later) translated to GPLv3+ +GPLv3+ + +$ python3 -m rust2rpm --show-license-map | grep -F GPL-3.0+ +(nada) +--- + rust2rpm/__main__.py | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py +index a7674fd..c55dacc 100644 +--- a/rust2rpm/__main__.py ++++ b/rust2rpm/__main__.py +@@ -222,6 +222,8 @@ def main(): + formatter_class=argparse.RawTextHelpFormatter) + parser.add_argument("--show-license-map", action="store_true", + help="Print license mappings and exit") ++ parser.add_argument("--translate-license", action="store_true", ++ help="Print mapping for specified license and exit") + parser.add_argument("--no-auto-changelog-entry", action="store_true", + help="Do not generate a changelog entry") + parser.add_argument("-", "--stdout", action="store_true", +@@ -248,6 +250,13 @@ def main(): + licensing.dump_sdpx_to_fedora_map(sys.stdout) + return + ++ if args.translate_license: ++ license, comments = licensing.translate_license(args.target, args.crate) ++ if comments: ++ print(comments) ++ print(license) ++ return ++ + if args.crate is None: + parser.error("required crate/path argument missing") + +-- +2.22.0.rc3 + diff --git a/0013-Implement-__cargo_skip_build.patch b/0013-Implement-__cargo_skip_build.patch new file mode 100644 index 0000000..b4942f3 --- /dev/null +++ b/0013-Implement-__cargo_skip_build.patch @@ -0,0 +1,189 @@ +From 7b06496a5c1ded5e3cf59d6af0e757974c6ff704 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Sat, 8 Jun 2019 19:35:38 +0200 +Subject: [PATCH 13/14] Implement %__cargo_skip_build + +We need to have an easy way how to skip doing 'cargo build' to speedup a +module builds. + +Signed-off-by: Igor Gnatenko +--- + data/macros.cargo | 80 ++++++++++++++++++++++++------------ + rust2rpm/templates/main.spec | 34 ++++++++------- + 2 files changed, 72 insertions(+), 42 deletions(-) + +diff --git a/data/macros.cargo b/data/macros.cargo +index a60289a..961732d 100644 +--- a/data/macros.cargo ++++ b/data/macros.cargo +@@ -10,6 +10,21 @@ + + %cargo_registry %{_datadir}/cargo/registry + ++# If crate not in _build_crates and _module_build is set, we should skip the build ++%__cargo_skip_build %{lua: ++local crate = rpm.expand('%{crate}') ++local build_crate = false ++for w in rpm.expand('%{?_build_crates}'):gmatch('%S+') do ++ if w == crate then ++ build_crate = true ++ break ++ end ++end ++if (rpm.expand('%{defined _module_build}') ~= '0' and not build_crate) then ++ print(1) ++else ++ print(0) ++end} + %__cargo_is_lib() %__cargo_inspector --target-kinds Cargo.toml | grep -q -F -x "$(printf 'lib\\\nrlib\\\nproc-macro')" + %__cargo_is_bin() %__cargo_inspector --target-kinds Cargo.toml | grep -q -F -x bin + +@@ -49,27 +64,35 @@ EOF\ + } + + %cargo_generate_buildrequires(af:) \ +-%{__cargo_inspector} -BR %{__cargo_parse_opts %{-a} %{-f:-f%{-f*}}} Cargo.toml \ +-%if %{with check} \ +-%{__cargo_inspector} -TR Cargo.toml \ ++%if ! 0%{?__cargo_skip_build} \ ++ %{__cargo_inspector} -BR %{__cargo_parse_opts %{-a} %{-f:-f%{-f*}}} Cargo.toml \ ++ %if %{with check} \ ++ %{__cargo_inspector} -TR Cargo.toml \ ++ %endif \ + %endif + +-%cargo_build(naf:) %{shrink:\ +-%{__cargo} build \ +- %{__cargo_common_opts} \ +- --release \ +- %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ +- %* \ +-} ++%cargo_build(naf:) \ ++%if ! 0%{?__cargo_skip_build} \ ++ %{shrink:\ ++ %{__cargo} build \ ++ %{__cargo_common_opts} \ ++ --release \ ++ %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ ++ %* \ ++ } \ ++%endif + +-%cargo_test(naf:) %{shrink:\ +-%{__cargo} test \ +- %{__cargo_common_opts} \ +- --release \ +- --no-fail-fast \ +- %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ +- %* \ +-} ++%cargo_test(naf:) \ ++%if ! 0%{?__cargo_skip_build} \ ++ %{shrink:\ ++ %{__cargo} test \ ++ %{__cargo_common_opts} \ ++ --release \ ++ --no-fail-fast \ ++ %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ ++ %* \ ++ } \ ++%endif + + %cargo_install(t:naf:) (\ + set -eu \ +@@ -88,15 +111,18 @@ if %__cargo_is_lib; then \ + %{__rm} -f $REG_DIR/Cargo.toml.{orig,deps} \ + echo '{"files":{},"package":""}' > $REG_DIR/.cargo-checksum.json \ + fi \ +-if %__cargo_is_bin; then \ +- %{shrink:%{__cargo} install \ +- %{__cargo_common_opts} \ +- --path . \ +- %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ +- %* \ +- }\ +- %{__rm} %{buildroot}%{_prefix}/.crates.toml \ +-fi \ ++%if ! %__cargo_skip_build \ ++ if %__cargo_is_bin; then \ ++ %{shrink:\ ++ %{__cargo} install \ ++ %{__cargo_common_opts} \ ++ --path . \ ++ %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ ++ %* \ ++ } \ ++ %{__rm} %{buildroot}%{_prefix}/.crates.toml \ ++ fi \ ++%endif \ + ) + + %__cargo_feature_from_name(n:) %{lua: +diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec +index 660bb60..69d23d7 100644 +--- a/rust2rpm/templates/main.spec ++++ b/rust2rpm/templates/main.spec +@@ -42,26 +42,28 @@ ExclusiveArch: %{rust_arches} + + BuildRequires: rust-packaging + {% if not generate_buildrequires %} +-{% if not all_features %} +-{% set buildrequires = normalize_deps(md.requires("default", resolve=True))|sort %} +-{% else %} +-{% set buildrequires = normalize_deps(md.all_dependencies)|sort %} +-{% set cargo_args = " -a" %} +-{% endif %} +-{% for req in buildrequires %} ++%if ! %{__cargo_skip_build} ++ {% if not all_features %} ++ {% set buildrequires = normalize_deps(md.requires("default", resolve=True))|sort %} ++ {% else %} ++ {% set buildrequires = normalize_deps(md.all_dependencies)|sort %} ++ {% set cargo_args = " -a" %} ++ {% endif %} ++ {% for req in buildrequires %} + BuildRequires: {{ req }} +-{% endfor %} +-{% set testrequires = normalize_deps(md.dev_dependencies)|sort %} +-{% if testrequires|length > 0 %} ++ {% endfor %} ++ {% set testrequires = normalize_deps(md.dev_dependencies)|sort %} ++ {% if testrequires|length > 0 %} + %if %{with check} +- {% for req in testrequires %} ++ {% for req in testrequires %} + BuildRequires: {{ req }} +- {% endfor %} ++ {% endfor %} + %endif +-{% endif %} +-{% for req in to_list(distconf.get("buildrequires"))|sort %} ++ {% endif %} ++ {% for req in to_list(distconf.get("buildrequires"))|sort %} + BuildRequires: {{ req }} +-{% endfor %} ++ {% endfor %} ++%endif + {% endif %} + + %global _description %{expand: +@@ -75,6 +77,7 @@ BuildRequires: {{ req }} + %description %{_description} + + {% if include_main %} ++%if ! %{__cargo_skip_build} + %package -n %{crate} + Summary: %{summary} + {% if rust_group is defined %} +@@ -96,6 +99,7 @@ Requires: {{ req }} + {% for bin in bins %} + %{_bindir}/{{ bin.name }} + {% endfor %} ++%endif + + {% endif -%} + +-- +2.22.0.rc3 + diff --git a/0014-Set-BuildArch-noarch-with-__cargo_skip_build.patch b/0014-Set-BuildArch-noarch-with-__cargo_skip_build.patch new file mode 100644 index 0000000..63a2895 --- /dev/null +++ b/0014-Set-BuildArch-noarch-with-__cargo_skip_build.patch @@ -0,0 +1,30 @@ +From b345d23e7a11357d828751e4db47a0685cfe207b Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Sat, 8 Jun 2019 20:01:12 +0200 +Subject: [PATCH 14/14] Set BuildArch: noarch with %__cargo_skip_build + +We do not need to spawn 7 tasks for each architecture to copy same files +over and over. + +Signed-off-by: Igor Gnatenko +--- + rust2rpm/templates/main.spec | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec +index 69d23d7..b4734b7 100644 +--- a/rust2rpm/templates/main.spec ++++ b/rust2rpm/templates/main.spec +@@ -39,6 +39,9 @@ Patch0: {{ patch_file }} + {% endif %} + + ExclusiveArch: %{rust_arches} ++%if ! %{__cargo_skip_build} ++BuildArch: noarch ++%endif + + BuildRequires: rust-packaging + {% if not generate_buildrequires %} +-- +2.22.0.rc3 + diff --git a/rust-packaging.spec b/rust-packaging.spec index 8019a55..1dd8d19 100644 --- a/rust-packaging.spec +++ b/rust-packaging.spec @@ -5,12 +5,26 @@ Name: rust-packaging Version: 9 -Release: 1%{?dist} +Release: 2%{?dist} Summary: RPM macros for building Rust packages on various architectures License: MIT URL: https://pagure.io/fedora-rust/rust2rpm Source0: https://releases.pagure.org/fedora-rust/rust2rpm/rust2rpm-%{version}.tar.xz +Patch0001: 0001-templates-Do-not-put-empty-line-after-changelog.patch +Patch0002: 0002-licensing-translate-GPL-123.patch +Patch0003: 0003-licensing-add-or-later-variants-for-GPL-licenses.patch +Patch0004: 0004-Move-version-string-to-the-python-code.patch +Patch0005: 0005-Check-usr-lib-os-release-in-addition-to-etc-os-relea.patch +Patch0006: 0006-Include-rust2rpm-version-info-in-the-generated-spec-.patch +Patch0007: 0007-Bump-classifiers.patch +Patch0008: 0008-Mangle-summary-automagically.patch +Patch0009: 0009-Use-expand-for-description.patch +Patch0010: 0010-Remove-more-common-prefixes.patch +Patch0011: 0011-Add-AGPL-3.0-or-later-and-automatically-translate-su.patch +Patch0012: 0012-Add-translate-license-to-translate-a-specific-licens.patch +Patch0013: 0013-Implement-__cargo_skip_build.patch +Patch0014: 0014-Set-BuildArch-noarch-with-__cargo_skip_build.patch ExclusiveArch: %{rust_arches} @@ -43,7 +57,6 @@ Provides: rust2rpm = %{version}-%{release} %prep %autosetup -n rust2rpm-%{version} -p1 -sed -i -e '/# Generated by/s/$/-%{version}-%{release}/' rust2rpm/templates/main.spec %build %py3_build @@ -72,6 +85,9 @@ py.test-%{python3_version} -vv test.py %{python3_sitelib}/rust2rpm/ %changelog +* Sat Jun 08 2019 Igor Gnatenko - 9-2 +- Backport patches from upstream + * Sun May 05 09:18:19 CEST 2019 Igor Gnatenko - 9-1 - Update to 9