Hello community, here is the log from the commit of package rust-packaging for openSUSE:Factory checked in at 2018-11-26 10:18:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rust-packaging (Old) and /work/SRC/openSUSE:Factory/.rust-packaging.new.19453 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rust-packaging" Mon Nov 26 10:18:33 2018 rev:2 rq:648268 version:6 Changes: -------- --- /work/SRC/openSUSE:Factory/rust-packaging/rust-packaging.changes 2018-01-22 16:20:50.923394415 +0100 +++ /work/SRC/openSUSE:Factory/.rust-packaging.new.19453/rust-packaging.changes 2018-11-26 10:19:44.865772286 +0100 @@ -1,0 +2,30 @@ +Sun Nov 11 22:41:29 UTC 2018 - Neal Gompa <[email protected]> + +- Update to 6 + + Allow generating spec file from rust project checkout + + add option to copy crate to current working directory + + Filter dependencies using the cfg language +- Backport patches for updated packaging generation + + Added patches + - 0001-name-spec-patch_file-by-real-crate-name.patch + - 0002-generate-doc-statements.patch + - 0003-do-better-for-renamed-crates.patch + - 0004-remove-pre-3.6-leftovers.patch + - 0005-Remove-half-downloaded-crate-on-C.patch + - 0006-Throw-an-error-if-s-is-used-without-a-crate.patch + - 0007-split-features-into-subpackages.patch + - 0008-add-support-for-dependencies-with-same-name.patch + - 0009-add-support-for-feeding-user-configuration.patch + - 0010-trivial-use-f-strings-everywhere.patch +- Remove merged patches + + 0001-macros-remove-Cargo.lock.patch + + 0002-macros-remove-spurious-whitespace.patch +- Add proposed patch to add option to not generate default changelog entry + + 0101-Add-option-to-not-generate-a-default-changelog-entry.patch + +------------------------------------------------------------------- +Tue Nov 6 03:02:47 UTC 2018 - Neal Gompa <[email protected]> + +- Add missing runtime requirement for python3-setuptools + +------------------------------------------------------------------- --- /work/SRC/openSUSE:Factory/rust-packaging/rust-srpm-macros.changes 2018-01-22 16:20:50.955392919 +0100 +++ /work/SRC/openSUSE:Factory/.rust-packaging.new.19453/rust-srpm-macros.changes 2018-11-26 10:19:44.973772160 +0100 @@ -1,0 +2,8 @@ +Sun Nov 11 22:49:16 UTC 2018 - Neal Gompa <[email protected]> + +- Update to 6 + + pass %__cargo_common_opts to %cargo_install + + make %cargo_* macros parametric + + remove support for target-dir + +------------------------------------------------------------------- Old: ---- 0001-macros-remove-Cargo.lock.patch 0002-macros-remove-spurious-whitespace.patch rust2rpm-5.tar.xz New: ---- 0001-name-spec-patch_file-by-real-crate-name.patch 0002-generate-doc-statements.patch 0003-do-better-for-renamed-crates.patch 0004-remove-pre-3.6-leftovers.patch 0005-Remove-half-downloaded-crate-on-C.patch 0006-Throw-an-error-if-s-is-used-without-a-crate.patch 0007-split-features-into-subpackages.patch 0008-add-support-for-dependencies-with-same-name.patch 0009-add-support-for-feeding-user-configuration.patch 0010-trivial-use-f-strings-everywhere.patch 0101-Add-option-to-not-generate-a-default-changelog-entry.patch rust2rpm-6.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rust-packaging.spec ++++++ --- /var/tmp/diff_new_pack.ypXG2b/_old 2018-11-26 10:19:45.857771127 +0100 +++ /var/tmp/diff_new_pack.ypXG2b/_new 2018-11-26 10:19:45.857771127 +0100 @@ -20,15 +20,28 @@ %bcond_without check Name: rust-packaging -Version: 5 +Version: 6 Release: 0 Summary: RPM tools and macros for building Rust packages 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 -Patch0001: 0001-macros-remove-Cargo.lock.patch -Patch0002: 0002-macros-remove-spurious-whitespace.patch + +# 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 +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 + +# From: https://pagure.io/fedora-rust/rust2rpm/pull-request/62 +Patch0101: 0101-Add-option-to-not-generate-a-default-changelog-entry.patch BuildArch: noarch ExclusiveArch: %{rust_arches} noarch @@ -37,8 +50,6 @@ Requires: gawk >= 4.1.0 Requires: python3-rust2rpm = %{?epoch:%{epoch}:}%{version}-%{release} Requires: rust-srpm-macros = %{version} -# Remove in F29 -Obsoletes: rust-rpm-macros < 2-2 %description This package provides the tools and macros for building projects in Rust @@ -53,9 +64,12 @@ BuildRequires: python3-pytest BuildRequires: cargo BuildRequires: python3-semantic_version +BuildRequires: python3-rustcfg %endif Requires: cargo Requires: python3-semantic_version +Requires: python3-setuptools +Requires: python3-rustcfg %if 0%{?suse_version} Requires: python3-Jinja2 %else ++++++ rust-srpm-macros.spec ++++++ --- /var/tmp/diff_new_pack.ypXG2b/_old 2018-11-26 10:19:45.877771104 +0100 +++ /var/tmp/diff_new_pack.ypXG2b/_new 2018-11-26 10:19:45.877771104 +0100 @@ -18,7 +18,7 @@ # Name: rust-srpm-macros -Version: 5 +Version: 6 Release: 0 Summary: RPM macros for building Rust source packages Group: Development/Languages/Rust ++++++ 0001-name-spec-patch_file-by-real-crate-name.patch ++++++ >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 When renaming using patch file, we really want to change file names too. Signed-off-by: Igor Gnatenko <[email protected]> --- rust2rpm/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index dc78828..1575ce6 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -218,7 +218,7 @@ def main(): template = JINJA_ENV.get_template("main.spec") if args.patch and len(diff) > 0: - patch_file = "{}-fix-metadata.diff".format(crate) + patch_file = "{}-fix-metadata.diff".format(metadata.name) else: patch_file = None @@ -269,7 +269,7 @@ def main(): kwargs["license"] = license kwargs["license_comments"] = comments - spec_file = "rust-{}.spec".format(crate) + spec_file = "rust-{}.spec".format(metadata.name) spec_contents = template.render(md=metadata, patch_file=patch_file, **kwargs) if args.stdout: print("# {}".format(spec_file)) -- 2.19.1 ++++++ 0002-generate-doc-statements.patch ++++++ >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 Signed-off-by: Igor Gnatenko <[email protected]> --- rust2rpm/metadata.py | 2 ++ rust2rpm/templates/main.spec | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/rust2rpm/metadata.py b/rust2rpm/metadata.py index 5dae1d3..f52d968 100644 --- a/rust2rpm/metadata.py +++ b/rust2rpm/metadata.py @@ -140,6 +140,7 @@ class Metadata(object): self.name = None self.license = None self.license_file = None + self.readme = None self.description = None self.version = None self._targets = [] @@ -156,6 +157,7 @@ class Metadata(object): self.name = md["name"] self.license = md["license"] self.license_file = md["license_file"] + self.readme = md["readme"] self.description = md.get("description") self.version = md["version"] version = "={}".format(self.version) diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec index 1aeb969..2e9f841 100644 --- a/rust2rpm/templates/main.spec +++ b/rust2rpm/templates/main.spec @@ -137,6 +137,9 @@ which use %{crate} from crates.io. {% if md.license_file is not none %} %license {{ md.license_file }} {% endif %} +{% if md.readme is not none %} +%doc {{ md.readme }} +{% endif %} {% for bin in bins %} %{_bindir}/{{ bin.name }} {% endfor %} @@ -147,6 +150,9 @@ which use %{crate} from crates.io. {% if md.license_file is not none %} %license {{ md.license_file }} {% endif %} +{% if md.readme is not none %} +%doc {{ md.readme }} +{% endif %} %{cargo_registry}/%{crate}-%{version}/ {% endif %} -- 2.19.1 ++++++ 0003-do-better-for-renamed-crates.patch ++++++ >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 Signed-off-by: Igor Gnatenko <[email protected]> --- 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 ++++++ 0004-remove-pre-3.6-leftovers.patch ++++++ >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 Signed-off-by: Igor Gnatenko <[email protected]> --- rust2rpm/metadata.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rust2rpm/metadata.py b/rust2rpm/metadata.py index f52d968..5adeb65 100644 --- a/rust2rpm/metadata.py +++ b/rust2rpm/metadata.py @@ -203,8 +203,6 @@ class Metadata(object): @classmethod def from_file(cls, path): - do_decode = sys.version_info < (3, 6) metadata = subprocess.check_output(["cargo", "read-manifest", - "--manifest-path={}".format(path)], - universal_newlines=do_decode) + "--manifest-path={}".format(path)]) return cls.from_json(json.loads(metadata)) -- 2.19.1 ++++++ 0005-Remove-half-downloaded-crate-on-C.patch ++++++ >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 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 partial download results. --- rust2rpm/__main__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index e993e7b..8e6f6eb 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -83,6 +83,14 @@ def file_mtime(path): t = datetime.fromtimestamp(os.stat(path).st_mtime, timezone.utc) return t.astimezone().isoformat() [email protected] +def remove_on_error(path): + try: + yield + except: # this is supposed to include ^C + os.unlink(path) + raise + def local_toml(toml, version): if os.path.isdir(toml): toml = os.path.join(toml, "Cargo.toml") @@ -110,7 +118,8 @@ def download(crate, version): req = requests.get(url, stream=True) req.raise_for_status() total = int(req.headers["Content-Length"]) - with open(cratef, "wb") as f: + with remove_on_error(cratef), \ + open(cratef, "wb") as f: for chunk in tqdm.tqdm(req.iter_content(), "Downloading {}".format(cratef_base), total=total, unit="B", unit_scale=True): f.write(chunk) -- 2.19.1 ++++++ 0006-Throw-an-error-if-s-is-used-without-a-crate.patch ++++++ >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 In the future we might want to be smarter and find the crate, but let's at least not ignore the option completely. --- rust2rpm/__main__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index 8e6f6eb..f23ebbc 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -178,6 +178,9 @@ def make_diff_metadata(crate, version, patch=False, store=False): if crate.endswith(".crate"): cratef, crate, version = local_crate(crate, version) else: + if store: + raise ValueError('--store-crate can only be used for a crate') + toml, crate, version = local_toml(crate, version) diff = make_patch(toml, enabled=patch, tmpfile=True) metadata = Metadata.from_file(toml) -- 2.19.1 ++++++ 0007-split-features-into-subpackages.patch ++++++ ++++ 1064 lines (skipped) ++++++ 0008-add-support-for-dependencies-with-same-name.patch ++++++ >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 Reported-by: Josh Stone <[email protected]> References: https://internals.rust-lang.org/t/optional-dependencies-with-same-name/8728 Signed-off-by: Igor Gnatenko <[email protected]> --- rust2rpm/metadata.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/rust2rpm/metadata.py b/rust2rpm/metadata.py index 4929cdd..328b67a 100644 --- a/rust2rpm/metadata.py +++ b/rust2rpm/metadata.py @@ -1,5 +1,6 @@ __all__ = ["Dependency", "Metadata"] +import collections import copy import json import subprocess @@ -126,9 +127,11 @@ class Metadata: self.description = md.get("description") # dependencies + build-dependencies → runtime - deps_by_name = {dep["name"]: Dependency.from_json(dep) - for dep in md["dependencies"] - if dep["kind"] != "dev"} + deps_by_name = collections.defaultdict(list) + for dep in md["dependencies"]: + if dep["kind"] == "dev": + continue + deps_by_name[dep["name"]].append(Dependency.from_json(dep)) deps_by_feature = {} for feature, f_deps in md["features"].items(): @@ -139,18 +142,23 @@ class Metadata: features.add(dep) else: pkg, _, f = dep.partition("/") - dep = copy.deepcopy(deps_by_name[pkg]) - if f: - dep.features = {f} - deps.add(dep) + for dep in deps_by_name[pkg]: + dep = copy.deepcopy(dep) + if f: + dep.features = {f} + deps.add(dep) deps_by_feature[feature] = (features, deps) mandatory_deps = set() - for dep in deps_by_name.values(): - if dep.optional: - deps_by_feature[dep.name] = ({None}, {copy.deepcopy(dep)}) - else: - mandatory_deps.add(copy.deepcopy(dep)) + for name, deps in deps_by_name.items(): + fdeps = set() + for dep in deps: + if dep.optional: + fdeps.add(copy.deepcopy(dep)) + else: + mandatory_deps.add(copy.deepcopy(dep)) + if fdeps: + deps_by_feature[name] = ({None}, fdeps) deps_by_feature[None] = (set(), mandatory_deps) if "default" not in deps_by_feature: -- 2.19.1 ++++++ 0009-add-support-for-feeding-user-configuration.patch ++++++ >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 Signed-off-by: Igor Gnatenko <[email protected]> --- README.md | 26 ++++++++++++++++++++++++++ README.rst | 5 ----- rust2rpm/__main__.py | 13 +++++++++++++ rust2rpm/templates/main.spec | 17 ++++++++++++++++- 4 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 README.md delete mode 100644 README.rst diff --git a/README.md b/README.md new file mode 100644 index 0000000..22b4b30 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# rust2rpm + +Convert Rust crates to RPM. + +## `.rust2rpm.conf` + +You can place configuration file which is used as source for additional +information for spec generation. + +Some simple example would be better than many words ;) + +```ini +[DEFAULT] +buildrequires = + pkgconfig(foo) >= 1.2.3 +lib.requires = + pkgconfig(foo) >= 1.2.3 + +[fedora] +bin.requires = + findutils +buildrequires = +lib.requires = +lib+default.requires = + pkgconfig(bar) >= 2.0.0 +``` diff --git a/README.rst b/README.rst deleted file mode 100644 index 8866027..0000000 --- a/README.rst +++ /dev/null @@ -1,5 +0,0 @@ -======== -rust2rpm -======== - -Convert Rust crates to RPM. diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index d19cb47..c691274 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -199,6 +199,11 @@ def make_diff_metadata(crate, version, patch=False, store=False): shutil.copy2(cratef, os.path.join(os.getcwd(), f"{metadata.name}-{version}.crate")) return crate, diff, metadata +def to_list(s): + if not s: + return [] + return list(filter(None, (l.strip() for l in s.splitlines()))) + def main(): parser = argparse.ArgumentParser("rust2rpm", formatter_class=argparse.RawTextHelpFormatter) @@ -232,6 +237,7 @@ def main(): store=args.store_crate) JINJA_ENV.globals["normalize_deps"] = normalize_deps + JINJA_ENV.globals["to_list"] = to_list template = JINJA_ENV.get_template("main.spec") if args.patch and len(diff) > 0: @@ -287,6 +293,13 @@ def main(): kwargs["license"] = license kwargs["license_comments"] = comments + conf = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation()) + conf.read(".rust2rpm.conf") + if args.target not in conf: + conf.add_section(args.target) + + kwargs["distconf"] = conf[args.target] + spec_file = f"rust-{metadata.name}.spec" spec_contents = template.render(md=metadata, patch_file=patch_file, **kwargs) if args.stdout: diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec index 0d9a80b..d901e6d 100644 --- a/rust2rpm/templates/main.spec +++ b/rust2rpm/templates/main.spec @@ -65,6 +65,9 @@ BuildRequires: {{ req }} {% endfor %} %endif {% endif %} +{% for req in to_list(distconf.get("buildrequires"))|sort %} +BuildRequires: {{ req }} +{% endfor %} %global _description \ {% if md.description is none %} @@ -81,6 +84,9 @@ Summary: %{summary} {% if rust_group is defined %} Group: # FIXME {% endif %} + {% for req in to_list(distconf.get("bin.requires"))|sort %} +Requires: {{ req }} + {% endfor %} %description -n %{crate} %{summary}. @@ -106,7 +112,13 @@ Group: # FIXME {% do features.insert(0, None) %} {% do features.insert(1, "default") %} {% for feature in features %} - {% set pkg = "-n %%{name}+%s-devel"|format(feature) if feature is not none else " devel" %} + {% if feature is none %} + {% set pkg = " devel" %} + {% set conf_prefix = "lib" %} + {% else %} + {% set pkg = "-n %%{name}+%s-devel"|format(feature) %} + {% set conf_prefix = "lib+%s"|format(feature) %} + {% endif %} %package {{ pkg }} Summary: %{summary} {% if rust_group is defined %} @@ -122,6 +134,9 @@ Requires: cargo Requires: {{ req }} {% endfor %} {% endif %} + {% for req in to_list(distconf.get("%s.requires"|format(conf_prefix)))|sort %} +Requires: {{ req }} + {% endfor %} %description {{ pkg }} %{_description} -- 2.19.1 ++++++ 0010-trivial-use-f-strings-everywhere.patch ++++++ >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 Signed-off-by: Igor Gnatenko <[email protected]> --- rust2rpm/__main__.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index c691274..b60e6c4 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -79,7 +79,7 @@ def detect_packager(): if git is not None: name = subprocess.check_output([git, "config", "user.name"], universal_newlines=True).strip() email = subprocess.check_output([git, "config", "user.email"], universal_newlines=True).strip() - return "{} <{}>".format(name, email) + return f"{name} <{email}>" return None @@ -108,23 +108,23 @@ def local_crate(crate, version): def download(crate, version): if version is None: # Now we need to get latest version - url = requests.compat.urljoin(API_URL, "crates/{}/versions".format(crate)) + url = requests.compat.urljoin(API_URL, f"crates/{crate}/versions") req = requests.get(url) req.raise_for_status() versions = req.json()["versions"] version = next(version["num"] for version in versions if not version["yanked"]) os.makedirs(CACHEDIR, exist_ok=True) - cratef_base = "{}-{}.crate".format(crate, version) + cratef_base = f"{crate}-{version}.crate" cratef = os.path.join(CACHEDIR, cratef_base) if not os.path.isfile(cratef): - url = requests.compat.urljoin(API_URL, "crates/{}/{}/download#".format(crate, version)) + url = requests.compat.urljoin(API_URL, f"crates/{crate}/{version}/download#") req = requests.get(url, stream=True) req.raise_for_status() total = int(req.headers["Content-Length"]) with remove_on_error(cratef), \ open(cratef, "wb") as f: - for chunk in tqdm.tqdm(req.iter_content(), "Downloading {}".format(cratef_base), + for chunk in tqdm.tqdm(req.iter_content(), f"Downloading {cratef_base}".format(cratef_base), total=total, unit="B", unit_scale=True): f.write(chunk) return cratef, crate, version @@ -132,14 +132,14 @@ def download(crate, version): @contextlib.contextmanager def toml_from_crate(cratef, crate, version): with tempfile.TemporaryDirectory() as tmpdir: - target_dir = "{}/".format(tmpdir) + target_dir = f"{tmpdir}/" with tarfile.open(cratef, "r") as archive: for n in archive.getnames(): if not os.path.abspath(os.path.join(target_dir, n)).startswith(target_dir): raise Exception("Unsafe filenames!") archive.extractall(target_dir) - toml_relpath = "{}-{}/Cargo.toml".format(crate, version) - toml = "{}/{}".format(tmpdir, toml_relpath) + toml_relpath = f"{crate}-{version}/Cargo.toml" + toml = f"{tmpdir}/{toml_relpath}" if not os.path.isfile(toml): raise IOError("crate does not contain Cargo.toml file") yield toml @@ -270,7 +270,7 @@ def main(): kwargs["include_provides"] = True kwargs["include_requires"] = True else: - assert False, "Unknown target {!r}".format(args.target) + assert False, f"Unknown target {args.target!r}" if args.target == "mageia": kwargs["pkg_release"] = "%mkrel 1" @@ -303,10 +303,10 @@ def main(): 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)) + print(f"# {spec_file}") print(spec_contents) if patch_file is not None: - print("# {}".format(patch_file)) + print(f"# {patch_file}") print("".join(diff), end="") else: with open(spec_file, "w") as fobj: -- 2.19.1 ++++++ 0101-Add-option-to-not-generate-a-default-changelog-entry.patch ++++++ >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 For Rust packages created through the OBS source service, the changelog is managed by an external <pkg>.changes file that is transformed into an RPM changelog and appended to the spec file automatically by the Open Build Service. Having a default entry means that the changelog handling will not always work correctly and package builds may fail due to changelog entries not being in reverse chronological order. This also is a future enabler for other workflows for external changelog management in automated package builds. Signed-off-by: Neal Gompa <[email protected]> --- rust2rpm/__main__.py | 7 +++++++ rust2rpm/templates/main.spec | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index b60e6c4..747328e 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -209,6 +209,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("--no-auto-changelog-entry", action="store_true", + help="Do not generate a changelog entry") parser.add_argument("-", "--stdout", action="store_true", help="Print spec and patches into stdout") parser.add_argument("-t", "--target", action="store", @@ -261,6 +263,11 @@ def main(): raise ValueError("No bins and no libs") kwargs["include_devel"] = is_lib + if args.no_auto_changelog_entry: + kwargs["auto_changelog_entry"] = False + else: + kwargs["auto_changelog_entry"] = True + if args.target in ("fedora", "mageia", "opensuse"): kwargs["include_build_requires"] = True kwargs["include_provides"] = False diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec index d901e6d..84bd97d 100644 --- a/rust2rpm/templates/main.spec +++ b/rust2rpm/templates/main.spec @@ -179,4 +179,6 @@ which use {% if feature is not none %}"{{ feature }}" feature of {% endif %}"%{c %endif %changelog -{% include target ~ "-changelog.spec.inc" %} +{% if auto_changelog_entry %} + {% include target ~ "-changelog.spec.inc" %} +{% endif %} -- 2.17.2 ++++++ rust2rpm-5.tar.xz -> rust2rpm-6.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/MANIFEST.in new/rust2rpm-6/MANIFEST.in --- old/rust2rpm-5/MANIFEST.in 2018-01-08 20:15:07.000000000 +0100 +++ new/rust2rpm-6/MANIFEST.in 2018-09-02 18:23:55.000000000 +0200 @@ -1,3 +1,4 @@ include LICENSE include data/* +include rust2rpm/spdx_to_fedora.csv include rust2rpm/templates/* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/data/macros.cargo new/rust2rpm-6/data/macros.cargo --- old/rust2rpm-5/data/macros.cargo 2018-01-08 20:15:07.000000000 +0100 +++ new/rust2rpm-6/data/macros.cargo 2018-09-02 18:23:55.000000000 +0200 @@ -1,5 +1,5 @@ %__cargo %{_bindir}/cargo -%__cargo_common_opts --release %{?_smp_mflags} +%__cargo_common_opts %{?_smp_mflags} %__cargo_inspector %{_bindir}/cargo-inspector %cargo_registry %{_datadir}/cargo/registry @@ -28,31 +28,59 @@ registry = "https://crates.io"\ replace-with = "local-registry"\ EOF\ +%{__rm} -f Cargo.lock \ %if ! %{with check} \ # https://github.com/rust-lang/cargo/issues/3732 \ %{__awk} -i inplace -v INPLACE_SUFFIX=.orig '/^\\\[dev-dependencies/{f=1;next} /^\\\[/{f=0}; !f' Cargo.toml \ %endif \ ) -%cargo_build %__cargo build %{__cargo_common_opts} - -%cargo_test %__cargo test %{__cargo_common_opts} --no-fail-fast - -%cargo_install (\ -set -eu \ -if %__cargo_is_lib; then \ - CRATE_NAME=$(%__cargo_inspector --name Cargo.toml) \ - CRATE_VERSION=$(%__cargo_inspector --version Cargo.toml) \ - REG_DIR=%{buildroot}%{cargo_registry}/$CRATE_NAME-$CRATE_VERSION \ - %{__mkdir} -p $REG_DIR \ - %__cargo package -l | xargs %{__cp} --parents -a -t $REG_DIR \ -%if ! %{with check} \ - %{__cp} -a Cargo.toml.orig $REG_DIR/Cargo.toml \ -%endif \ - echo '{"files":{},"package":""}' > $REG_DIR/.cargo-checksum.json \ +%__cargo_parse_opts(naf:) %{shrink:\ +%{-f:%{-a:%{error:Can't specify both -f(%{-f*}) and -a}}} \ + %{-n:--no-default-features} \ + %{-a:--all-features} \ + %{-f:--features %{-f*}} \ + %{nil} +} + +%cargo_build(naf:) %{shrink:\ +%{__cargo} build \ + %{__cargo_common_opts} \ + --release \ + %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ + %* \ +} + +%cargo_test(naf:) %{shrink:\ +%{__cargo} test \ + %{__cargo_common_opts} \ + --release \ + --no-fail-fast \ + %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ + %* \ +} + +%cargo_install(t:naf:) (\ +set -eu \ +if %__cargo_is_lib; then \ + CRATE_NAME=$(%__cargo_inspector --name Cargo.toml) \ + CRATE_VERSION=$(%__cargo_inspector --version Cargo.toml) \ + REG_DIR=%{buildroot}%{cargo_registry}/$CRATE_NAME-$CRATE_VERSION \ + %{__mkdir} -p $REG_DIR \ + %{__cargo} package -l | xargs %{__cp} --parents -a -t $REG_DIR \ +%if ! %{with check} \ + %{__cp} -a Cargo.toml.orig $REG_DIR/Cargo.toml \ +%endif \ + echo '{"files":{},"package":""}' > $REG_DIR/.cargo-checksum.json \ fi \ -if %__cargo_is_bin; then \ - %__cargo install %{?_smp_mflags} --path . --root %{buildroot}%{_prefix} \ - %{__rm} %{buildroot}%{_prefix}/.crates.toml \ +if %__cargo_is_bin; then \ + %{shrink:%{__cargo} install \ + %{__cargo_common_opts} \ + --path . \ + --root %{buildroot}%{_prefix} \ + %{__cargo_parse_opts %{-n} %{-a} %{-f:-f%{-f*}}} \ + %* \ + }\ + %{__rm} %{buildroot}%{_prefix}/.crates.toml \ fi \ ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/requirements.txt new/rust2rpm-6/requirements.txt --- old/rust2rpm-5/requirements.txt 2018-01-08 20:15:07.000000000 +0100 +++ new/rust2rpm-6/requirements.txt 2018-09-02 18:23:55.000000000 +0200 @@ -2,3 +2,4 @@ requests semantic_version tqdm +rustcfg diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/rust2rpm/__init__.py new/rust2rpm-6/rust2rpm/__init__.py --- old/rust2rpm-5/rust2rpm/__init__.py 2018-01-08 20:15:07.000000000 +0100 +++ new/rust2rpm-6/rust2rpm/__init__.py 2018-09-02 18:23:55.000000000 +0200 @@ -1 +1,2 @@ from .metadata import * +from . import licensing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/rust2rpm/__main__.py new/rust2rpm-6/rust2rpm/__main__.py --- old/rust2rpm-5/rust2rpm/__main__.py 2018-01-08 20:15:07.000000000 +0100 +++ new/rust2rpm-6/rust2rpm/__main__.py 2018-09-02 18:23:55.000000000 +0200 @@ -1,11 +1,13 @@ import argparse import configparser +import contextlib from datetime import datetime, timezone import difflib import itertools import os import shlex import shutil +import sys import tarfile import tempfile import time @@ -15,15 +17,15 @@ import requests import tqdm -from . import Metadata +from . import Metadata, licensing DEFAULT_EDITOR = "vi" XDG_CACHE_HOME = os.getenv("XDG_CACHE_HOME", os.path.expanduser("~/.cache")) CACHEDIR = os.path.join(XDG_CACHE_HOME, "rust2rpm") API_URL = "https://crates.io/api/v1/" JINJA_ENV = jinja2.Environment(loader=jinja2.ChoiceLoader([ - jinja2.FileSystemLoader(['/']), - jinja2.PackageLoader('rust2rpm', 'templates'), ]), + jinja2.FileSystemLoader(["/"]), + jinja2.PackageLoader("rust2rpm", "templates"), ]), trim_blocks=True, lstrip_blocks=True) def get_default_target(): @@ -81,36 +83,30 @@ t = datetime.fromtimestamp(os.stat(path).st_mtime, timezone.utc) return t.astimezone().isoformat() -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("-", "--stdout", action="store_true", - help="Print spec and patches into stdout") - parser.add_argument("-t", "--target", action="store", - choices=("plain", "fedora", "mageia", "opensuse"), default=get_default_target(), - help="Distribution target") - parser.add_argument("-p", "--patch", action="store_true", - help="Do initial patching of Cargo.toml") - parser.add_argument("crate", help="crates.io name") - parser.add_argument("version", nargs="?", help="crates.io version") - args = parser.parse_args() - - if args.patch: - editor = detect_editor() +def local_toml(toml, version): + if os.path.isdir(toml): + toml = os.path.join(toml, "Cargo.toml") + + return toml, None, version + +def local_crate(crate, version): + cratename, version = os.path.basename(crate)[:-6].rsplit("-", 1) + return crate, cratename, version - if args.version is None: +def download(crate, version): + if version is None: # Now we need to get latest version - url = requests.compat.urljoin(API_URL, "crates/{}/versions".format(args.crate)) + url = requests.compat.urljoin(API_URL, "crates/{}/versions".format(crate)) req = requests.get(url) req.raise_for_status() versions = req.json()["versions"] - args.version = next(version["num"] for version in versions if not version["yanked"]) + version = next(version["num"] for version in versions if not version["yanked"]) - if not os.path.isdir(CACHEDIR): - os.mkdir(CACHEDIR) - cratef_base = "{}-{}.crate".format(args.crate, args.version) + os.makedirs(CACHEDIR, exist_ok=True) + cratef_base = "{}-{}.crate".format(crate, version) cratef = os.path.join(CACHEDIR, cratef_base) if not os.path.isfile(cratef): - url = requests.compat.urljoin(API_URL, "crates/{}/{}/download#".format(args.crate, args.version)) + url = requests.compat.urljoin(API_URL, "crates/{}/{}/download#".format(crate, version)) req = requests.get(url, stream=True) req.raise_for_status() total = int(req.headers["Content-Length"]) @@ -118,7 +114,10 @@ for chunk in tqdm.tqdm(req.iter_content(), "Downloading {}".format(cratef_base), total=total, unit="B", unit_scale=True): f.write(chunk) + return cratef, crate, version [email protected] +def toml_from_crate(cratef, crate, version): with tempfile.TemporaryDirectory() as tmpdir: target_dir = "{}/".format(tmpdir) with tarfile.open(cratef, "r") as archive: @@ -126,28 +125,100 @@ if not os.path.abspath(os.path.join(target_dir, n)).startswith(target_dir): raise Exception("Unsafe filenames!") archive.extractall(target_dir) - toml_relpath = "{}-{}/Cargo.toml".format(args.crate, args.version) + toml_relpath = "{}-{}/Cargo.toml".format(crate, version) toml = "{}/{}".format(tmpdir, toml_relpath) - assert os.path.isfile(toml) - - if args.patch: - mtime_before = file_mtime(toml) - with open(toml, "r") as fobj: - toml_before = fobj.readlines() - subprocess.check_call([editor, toml]) - mtime_after = file_mtime(toml) - with open(toml, "r") as fobj: - toml_after = fobj.readlines() - diff = list(difflib.unified_diff(toml_before, toml_after, - fromfile=toml_relpath, tofile=toml_relpath, - fromfiledate=mtime_before, tofiledate=mtime_after)) + if not os.path.isfile(toml): + raise IOError("crate does not contain Cargo.toml file") + yield toml + +def make_patch(toml, enabled=True, tmpfile=False): + if not enabled: + return [] + + editor = detect_editor() + + mtime_before = file_mtime(toml) + toml_before = open(toml).readlines() + + # When we are editing a git checkout, we should not modify the real file. + # When we are editing an unpacked crate, we are free to edit anything. + # Let's keep the file name as close as possible to make editing easier. + if tmpfile: + tmpfile = tempfile.NamedTemporaryFile("w+t", dir=os.path.dirname(toml), + prefix="Cargo.", suffix=".toml") + tmpfile.writelines(toml_before) + tmpfile.flush() + fname = tmpfile.name + else: + fname = toml + subprocess.check_call([editor, fname]) + mtime_after = file_mtime(toml) + toml_after = open(fname).readlines() + toml_relpath = "/".join(toml.split("/")[-2:]) + diff = list(difflib.unified_diff(toml_before, toml_after, + fromfile=toml_relpath, tofile=toml_relpath, + fromfiledate=mtime_before, tofiledate=mtime_after)) + return diff + +def _is_path(path): + return "/" in path or path in {".", ".."} + +def make_diff_metadata(crate, version, patch=False, store=False): + if _is_path(crate): + # Only things that look like a paths are considered local arguments + if crate.endswith(".crate"): + cratef, crate, version = local_crate(crate, version) + else: + toml, crate, version = local_toml(crate, version) + diff = make_patch(toml, enabled=patch, tmpfile=True) + metadata = Metadata.from_file(toml) + return metadata.name, diff, metadata + else: + cratef, crate, version = download(crate, version) + with toml_from_crate(cratef, crate, version) as toml: + 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")) + return crate, diff, metadata + +def main(): + parser = argparse.ArgumentParser("rust2rpm", + formatter_class=argparse.RawTextHelpFormatter) + parser.add_argument("--show-license-map", action="store_true", + help="Print license mappings and exit") + parser.add_argument("-", "--stdout", action="store_true", + help="Print spec and patches into stdout") + parser.add_argument("-t", "--target", action="store", + choices=("plain", "fedora", "mageia", "opensuse"), default=get_default_target(), + help="Distribution target") + parser.add_argument("-p", "--patch", action="store_true", + help="Do initial patching of Cargo.toml") + parser.add_argument("-s", "--store-crate", action="store_true", + help="Store crate in current directory") + parser.add_argument("crate", help="crates.io name\n" + "path/to/local.crate\n" + "path/to/project/", + nargs="?") + parser.add_argument("version", nargs="?", help="crates.io version") + args = parser.parse_args() + + if args.show_license_map: + licensing.dump_sdpx_to_fedora_map(sys.stdout) + return + + if args.crate is None: + parser.error('required crate/path argument missing') + + crate, diff, metadata = make_diff_metadata(args.crate, args.version, + patch=args.patch, + store=args.store_crate) template = JINJA_ENV.get_template("main.spec") if args.patch and len(diff) > 0: - patch_file = "{}-{}-fix-metadata.diff".format(args.crate, args.version) + patch_file = "{}-fix-metadata.diff".format(crate) else: patch_file = None @@ -193,7 +264,12 @@ kwargs["date"] = time.strftime("%a %b %d %Y") kwargs["packager"] = detect_packager() - spec_file = "rust-{}.spec".format(args.crate) + if metadata.license is not None: + license, comments = licensing.translate_license(args.target, metadata.license) + kwargs["license"] = license + kwargs["license_comments"] = comments + + spec_file = "rust-{}.spec".format(crate) spec_contents = template.render(md=metadata, patch_file=patch_file, **kwargs) if args.stdout: print("# {}".format(spec_file)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/rust2rpm/licensing.py new/rust2rpm-6/rust2rpm/licensing.py --- old/rust2rpm-5/rust2rpm/licensing.py 1970-01-01 01:00:00.000000000 +0100 +++ new/rust2rpm-6/rust2rpm/licensing.py 2018-09-02 18:23:55.000000000 +0200 @@ -0,0 +1,57 @@ +import os as _os +import sys as _sys +import csv as _csv +import functools as _functools + +SPDX_TO_FEDORA_CSV = _os.path.dirname(__file__) + '/spdx_to_fedora.csv' + +def translate_slashes(license): + "Replace all slashes with OR, emit warning" + split = [l.strip() for l in license.split("/")] + if len(split) > 1: + print('Upstream uses deprecated "/" syntax. Replacing with "OR"', + file=_sys.stderr) + return ' OR '.join(split) + +@_functools.lru_cache() +def spdx_to_fedora_map(): + with open(SPDX_TO_FEDORA_CSV, newline='') as f: + reader = _csv.DictReader(f) + return {line['SPDX License Identifier'] : line['Fedora Short Name'] + for line in reader + if line['SPDX License Identifier']} + +def dump_sdpx_to_fedora_map(file): + for k,v in spdx_to_fedora_map().items(): + print(f"{k} → {v}", file=file) + +def translate_license_fedora(license): + comments = '' + final = [] + for tag in license.split(): + # We accept all variant cases, but output lowercase which is what Fedora LicensingGuidelines specify + if tag.upper() == 'OR': + final.append('or') + elif tag.upper() == 'AND': + final.append('and') + else: + mapped = spdx_to_fedora_map().get(tag, None) + if mapped is None: + comments += f'# FIXME: Upstream uses unknown SPDX tag {tag}!' + final.append(tag) + elif mapped is '': + comments += f"# FIXME: Upstream SPDX tag {tag} 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}', + file=_sys.stderr) + return (' '.join(final), comments or None) + +def translate_license(target, license): + license = translate_slashes(license) + if target in {"fedora", "epel", "mageia"}: + return translate_license_fedora(license) + return license, None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/rust2rpm/metadata.py new/rust2rpm-6/rust2rpm/metadata.py --- old/rust2rpm-5/rust2rpm/metadata.py 2018-01-08 20:15:07.000000000 +0100 +++ new/rust2rpm-6/rust2rpm/metadata.py 2018-09-02 18:23:55.000000000 +0200 @@ -6,6 +6,7 @@ import sys import semantic_version as semver +import rustcfg class Target(object): def __init__(self, kind, name): @@ -15,6 +16,24 @@ def __repr__(self): return "<Target {self.kind}|{self.name}>".format(self=self) + +def _req_to_str(name, spec=None, feature=None): + f_part = "/{}".format(feature) if feature is not None else "" + basestr = "crate({}{})".format(name, f_part) + if spec is None: + return basestr + if spec.kind == spec.KIND_EQUAL: + spec.kind = spec.KIND_SHORTEQ + if spec.kind == spec.KIND_ANY: + if spec.spec == "": + # Just wildcard + return basestr + else: + # Wildcard in string + assert False, spec.spec + version = str(spec.spec).replace("-", "~") + return "{} {} {}".format(basestr, spec.kind, version) + class Dependency(object): def __init__(self, name, req, features=(), provides=False): self.name = name @@ -27,33 +46,15 @@ raise Exception("Provides can't be applied to ranged version, {!r}".format(self.spec)) def __repr__(self): - def req_to_str(name, spec=None, feature=None): - f_part = "/{}".format(feature) if feature is not None else "" - basestr = "crate({}{})".format(name, f_part) - if spec is not None: - if spec.kind == spec.KIND_EQUAL: - spec.kind = spec.KIND_SHORTEQ - if spec.kind == spec.KIND_ANY: - if spec.spec == "": - # Just wildcard - return basestr - else: - # Wildcard in string - assert False, spec.spec - version = str(spec.spec).replace('-', '~') - return "{} {} {}".format(basestr, spec.kind, version) - else: - return basestr - if self.provides: spec = self.spec.specs[0] - provs = [req_to_str(self.name, spec)] + provs = [_req_to_str(self.name, spec)] for feature in self.features: - provs.append(req_to_str(self.name, spec, feature)) + provs.append(_req_to_str(self.name, spec, feature)) return " and ".join(provs) - reqs = [req_to_str(self.name, spec=req) for req in self.spec.specs] - features = [req_to_str(self.name, feature=feature) for feature in self.features] + reqs = [_req_to_str(self.name, spec=req) for req in self.spec.specs] + features = [_req_to_str(self.name, feature=feature) for feature in self.features] use_rich = False if len(reqs) > 1: @@ -163,23 +164,37 @@ self.targets = [Target(tgt["kind"][0], tgt["name"]) for tgt in md["targets"]] # Provides - # All optional depdencies are also features + # All optional dependencies are also features # https://github.com/rust-lang/cargo/issues/4911 features = itertools.chain((x["name"] for x in md["dependencies"] if x["optional"]), md["features"]) provides = Dependency(self.name, version, features=features, provides=True) self.provides = str(provides).split(" and ") + ev = rustcfg.Evaluator.platform() + # Dependencies for dep in md["dependencies"]: - if dep["kind"] is None: + kind = dep["kind"] + if kind is None: requires = self.requires - elif dep["kind"] == "build": + elif kind == "build": requires = self.build_requires - elif dep["kind"] == "dev": + elif kind == "dev": requires = self.test_requires else: - raise ValueError("Unknown kind: {!r}, please report bug.".format(dep["kind"])) + raise ValueError("Unknown kind: {!r}, please report bug.".format(kind)) + + target = dep["target"] + if target is None: + pass + else: + cond = ev.parse_and_eval(target) + if not cond: + print(f'Dependency {dep["name"]} for target {target!r} is not needed, ignoring.', + file=sys.stderr) + continue + requires.append(Dependency(dep["name"], dep["req"], features=dep["features"])) return self diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/rust2rpm/spdx_to_fedora.csv new/rust2rpm-6/rust2rpm/spdx_to_fedora.csv --- old/rust2rpm-5/rust2rpm/spdx_to_fedora.csv 1970-01-01 01:00:00.000000000 +0100 +++ new/rust2rpm-6/rust2rpm/spdx_to_fedora.csv 2018-09-02 18:23:55.000000000 +0200 @@ -0,0 +1,372 @@ +SPDX Full name of License,SPDX License Identifier,Fedora Short Name,Fedora Fullname (if different),Notes,Other Fedora Licenses (full name) that use same short identifier and are SPDX License List equivalent (as per SPDX Matching Guidelines) +3dfx Glide License,Glide,Glide,,, +Abstyles License,Abstyles,Abstyles,,, +Academic Free License v1.1,AFL-1.1,,,not on Fedora list, +Academic Free License v1.2,AFL-1.2,,,not on Fedora list, +Academic Free License v2.0,AFL-2.0,,,not on Fedora list, +Academic Free License v2.1,AFL-2.1,,,not on Fedora list, +Academic Free License v3.0,AFL-3.0,AFL,Academic Free License,, +Academy of Motion Picture Arts and Sciences BSD,AMPAS,AMPAS BSD,,, +Adaptive Public License 1.0,APL-1.0,,,Fedora bad list, +Adobe Glyph List License,Adobe-Glyph,MIT,,, +Adobe Postscript AFM License,APAFML,APAFML,,, +Adobe Systems Incorporated Source Code License Agreement,Adobe-2006,Adobe,,, +Affero General Public License v1.0,AGPL-1.0,AGPLv1,,, +Afmparse License,Afmparse,Afmparse,,, +Aladdin Free Public License,Aladdin,,,not on Fedora list, +Amazon Digital Services License,ADSL,ADSL,,, +AMD's plpa_map.c License,AMDPLPA,AMDPLPA,,, +ANTLR Software Rights Notice,ANTLR-PD,,,not on Fedora list, +Apache License 1.0,Apache-1.0,ASL 1.0,Apache Software License 1.0,, +Apache License 1.1,Apache-1.1,ASL 1.1,Apache Software License 1.1,,"4Suite Copyright License +MX4J License +Neotonic Clearsilver License +Phorum License +Sequence Library License +QuickFix License" +Apache License 2.0,Apache-2.0,ASL 2.0,Apache Software License 2.0,, +Apple MIT License,AML,AML,,, +Apple Public Source License 1.0,APSL-1.0,,,Fedora bad list, +Apple Public Source License 1.1,APSL-1.1,,,Fedora bad list, +Apple Public Source License 1.2,APSL-1.2,,,Fedora bad list, +Apple Public Source License 2.0,APSL-2.0,APSL 2.0,,, +Artistic License 1.0,Artistic-1.0,,,not on Fedora list, +Artistic License 1.0 (Perl),Artistic-1.0-Perl,,,Fedora bad list, +Artistic License 1.0 w/clause 8,Artistic-1.0-cl8,,,not on Fedora list, +Artistic License 2.0,Artistic-2.0,Artistic 2.0,Artistic 2.0,, +Attribution Assurance License,AAL,AAL,,, +Bahyph License,Bahyph,Bahyph,,, +Barr License,Barr,Barr,,, +Beerware License,Beerware,Beerware,,, +BitTorrent Open Source License v1.0,BitTorrent-1.0,,,This specific version not on Fedora list, +BitTorrent Open Source License v1.1,BitTorrent-1.1,BitTorrent,BitTorrent License,, +Boost Software License 1.0,BSL-1.0,Boost,Boost Software License,, +Borceux license,Borceux,Borceux,,, +"BSD 2-clause ""Simplified"" License",BSD-2-Clause,BSD,BSD License (two clause),,Cryptix General License +BSD 2-clause FreeBSD License,BSD-2-Clause-FreeBSD,,,not on Fedora list, +BSD 2-clause NetBSD License,BSD-2-Clause-NetBSD,,,not on Fedora list, +"BSD 3-clause ""New"" or ""Revised"" License",BSD-3-Clause,BSD,BSD License (no advertising),,Eclipse Distribution License 1.0 +BSD 3-clause Clear License,BSD-3-Clause-Clear,,,not on Fedora list, +"BSD 4-clause ""Original"" or ""Old"" License",BSD-4-Clause,BSD with advertising,,See note re: BSD-4-Clause-UC (need to confirm w/Fedora), +BSD Protection License,BSD-Protection,BSD Protection,,, +BSD with attribution,BSD-3-Clause-Attribution,BSD with attribution,,, +BSD-4-Clause (University of California-Specific),BSD-4-Clause-UC,BSD,,"Due to U. of CA 1999 retroactive deletion of the advertising clause, this is effectively 'BSD'-3-clause. Hence, Fedora would classify as “BSD” and not “BSD with advertising”? (need to confirm with Fedora)", +bzip2 and libbzip2 License v1.0.5,bzip2-1.0.5,,,not on Fedora list, +bzip2 and libbzip2 License v1.0.6,bzip2-1.0.6,,,not on Fedora list, +Caldera License,Caldera,,,not on Fedora list, +CeCILL Free Software License Agreement v1.0,CECILL-1.0,,,This specific version not on Fedora list, +CeCILL Free Software License Agreement v1.1,CECILL-1.1,CeCILL,CeCILL License v1.1,, +CeCILL Free Software License Agreement v2.0,CECILL-2.0,CeCILL,CeCILL License v2,, +CeCILL-B Free Software License Agreement,CECILL-B,CeCILL-B,CeCILL-B License,, +CeCILL-C Free Software License Agreement,CECILL-C,CeCILL-C,CeCILL-C License,, +Clarified Artistic License,ClArtistic,Artistic clarified,Artistic (clarified),, +CMU License,MIT-CMU,MIT,CMU License (BSD like),, +CNRI Jython License,CNRI-Jython,Jpython,Jpython License (old),, +CNRI Python License,CNRI-Python,CNRI,CNRI License (Old Python),Check – may not be exact match as per SPDX Matching Guidelines, +CNRI Python Open Source GPL Compatible License Agreement,CNRI-Python-GPL-Compatible,,,not on Fedora list, +Code Project Open License 1.02,CPOL-1.02,,,Fedora bad list, +Common Development and Distribution License 1.0,CDDL-1.0,CDDL,Common Development Distribution License,, +Common Development and Distribution License 1.1,CDDL-1.1,CDDL,,"This specific version not on Fedora list. Same as 1.0, but changes name from Sun to Oracle in section 4.1 and adds patent infringement termination clause (section 6.3) – would Fedora also consider “CDDL”?", +Common Public Attribution License 1.0,CPAL-1.0,CPAL,CPAL License 1.0,, +Common Public License 1.0,CPL-1.0,CPL,Common Public License,, +Computer Associates Trusted Open Source License 1.1,CATOSL-1.1,CATOSL,,, +Condor Public License v1.1,Condor-1.1,Condor,Condor Public License,, +Creative Commons Attribution 1.0,CC-BY-1.0,,,This specific version not on Fedora list, +Creative Commons Attribution 2.0,CC-BY-2.0,,,This specific version not on Fedora list, +Creative Commons Attribution 2.5,CC-BY-2.5,,,This specific version not on Fedora list, +Creative Commons Attribution 3.0,CC-BY-3.0,CC-BY,,, +Creative Commons Attribution 4.0,CC-BY-4.0,,,This specific version not on Fedora list, +Creative Commons Attribution No Derivatives 1.0,CC-BY-ND-1.0,,,not on Fedora list, +Creative Commons Attribution No Derivatives 2.0,CC-BY-ND-2.0,,,not on Fedora list, +Creative Commons Attribution No Derivatives 2.5,CC-BY-ND-2.5,,,not on Fedora list, +Creative Commons Attribution No Derivatives 3.0,CC-BY-ND-3.0,,,not on Fedora list, +Creative Commons Attribution No Derivatives 4.0,CC-BY-ND-4.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial 1.0,CC-BY-NC-1.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial 2.0,CC-BY-NC-2.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial 2.5,CC-BY-NC-2.5,,,not on Fedora list, +Creative Commons Attribution Non Commercial 3.0,CC-BY-NC-3.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial 4.0,CC-BY-NC-4.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial No Derivatives 1.0,CC-BY-NC-ND-1.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial No Derivatives 2.0,CC-BY-NC-ND-2.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial No Derivatives 2.5,CC-BY-NC-ND-2.5,,,not on Fedora list, +Creative Commons Attribution Non Commercial No Derivatives 3.0,CC-BY-NC-ND-3.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial No Derivatives 4.0,CC-BY-NC-ND-4.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial Share Alike 1.0,CC-BY-NC-SA-1.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial Share Alike 2.0,CC-BY-NC-SA-2.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial Share Alike 2.5,CC-BY-NC-SA-2.5,,,not on Fedora list, +Creative Commons Attribution Non Commercial Share Alike 3.0,CC-BY-NC-SA-3.0,,,not on Fedora list, +Creative Commons Attribution Non Commercial Share Alike 4.0,CC-BY-NC-SA-4.0,,,not on Fedora list, +Creative Commons Attribution Share Alike 1.0,CC-BY-SA-1.0,,,This specific version not on Fedora list, +Creative Commons Attribution Share Alike 2.0,CC-BY-SA-2.0,,,This specific version not on Fedora list, +Creative Commons Attribution Share Alike 2.5,CC-BY-SA-2.5,,,This specific version not on Fedora list, +Creative Commons Attribution Share Alike 3.0,CC-BY-SA-3.0,CC-BY-SA,,, +Creative Commons Attribution Share Alike 4.0,CC-BY-SA-4.0,,,This specific version not on Fedora list, +Creative Commons Zero v1.0 Universal,CC0-1.0,CC0,,, +Crossword License,Crossword,Crossword,,, +CUA Office Public License v1.0,CUA-OPL-1.0,MPLv1.1,,, +Cube License,Cube,Cube,,, +Deutsche Freie Software Lizenz,D-FSL-1.0,,,not on Fedora list, +diffmark license,diffmark,diffmark,,, +Do What The F*ck You Want To Public License,WTFPL,WTFPL,,, +DOC License,DOC,DOC,,, +Dotseqn License,Dotseqn,Dotseqn,,, +DSDP License,DSDP,DSDP,,, +dvipdfm License,dvipdfm,dvipdfm,,, +Eclipse Public License 1.0,EPL-1.0,EPL,,, +Educational Community License v1.0,ECL-1.0,ECL 1.0,,, +Educational Community License v2.0,ECL-2.0,ECL 2.0,,, +eGenix.com Public License 1.1.0,eGenix,eGenix,,, +Eiffel Forum License v1.0,EFL-1.0,,,Fedora bad list, +Eiffel Forum License v2.0,EFL-2.0,EFL 2.0,,, +Enlightenment License (e16),MIT-advertising,MIT with advertising,,, +enna License,MIT-enna,MIT,,, +Entessa Public License v1.0,Entessa,Entessa,Entessa Public License,, +Erlang Public License v1.1,ErlPL-1.1,ERPL,,, +EU DataGrid Software License,EUDatagrid,EU Datagrid,,, +European Union Public License 1.0,EUPL-1.0,,,Fedora bad list, +European Union Public License 1.1,EUPL-1.1,EUPL 1.1,,, +Eurosym License,Eurosym,Eurosym,,, +Fair License,Fair,Fair,,, +feh License,MIT-feh,MIT,,, +Frameworx Open License 1.0,Frameworx-1.0,,,Fedora bad list, +FreeImage Public License v1.0,FreeImage,MPLv1.0,FreeImage Public License,, +Freetype Project License,FTL,FTL,Freetype License,, +FSF Unlimited License,FSFUL,FSFUL,,, +FSF Unlimited License (with License Retention),FSFULLR,FSFULLR,,, +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 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 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,,, +gnuplot License,gnuplot,gnuplot,,, +gSOAP Public License v1.3b,gSOAP-1.3b,,,not on Fedora list, +Haskell Language Report License,HaskellReport,HaskellReport,,, +Historic Permission Notice and Disclaimer,HPND,MIT,,, +IBM PowerPC Initialization and Boot Software,IBM-pibs,,,not on Fedora list, +IBM Public License v1.0,IPL-1.0,IBM,IBM Public License,, +ICU License,ICU,,,not on Fedora list, +ImageMagick License,ImageMagick,ImageMagick,,, +iMatix Standard Function Library Agreement,iMatix,iMatix,,, +Imlib2 License,Imlib2,Imlib2,,, +Independent JPEG Group License,IJG,IJG,,, +Intel ACPI Software License Agreement,Intel-ACPI,Intel ACPI,,, +Intel Open Source License,Intel,,,Fedora bad list, +IPA Font License,IPA,,,not on Fedora list, +ISC License,ISC,ISC,,, +JasPer License,JasPer-2.0,JasPer,,, +JSON License,JSON,,,Fedora bad list, +LaTeX Project Public License 1.3a,LPPL-1.3a,LPPL,,, +LaTeX Project Public License v1.0,LPPL-1.0,,,This specific version not on Fedora list, +LaTeX Project Public License v1.1,LPPL-1.1,,,This specific version not on Fedora list, +LaTeX Project Public License v1.2,LPPL-1.2,,,This specific version not on Fedora list, +LaTeX Project Public License v1.3c,LPPL-1.3c,,,This specific version not on Fedora list, +Latex2e License,Latex2e,Latex2e,,, +Lawrence Berkeley National Labs BSD variant license,BSD-3-Clause-LBNL,LBNL BSD,,, +Leptonica License,Leptonica,Leptonica,,, +Lesser General Public License For Linguistic Resources,LGPLLR,,,, +libpng License,Libpng,,,not on Fedora list, +libtiff License,libtiff,libtiff,,, +Lucent Public License v1.02,LPL-1.02,LPL,Lucent Public License (Plan9),, +Lucent Public License Version 1.0,LPL-1.0,,,This specific version not on Fedora list, +MakeIndex License,MakeIndex,MakeIndex,,, +Matrix Template Library License,MTLL,MTLL,,, +Microsoft Public License,MS-PL,MS-PL,,, +Microsoft Reciprocal License,MS-RL,MS-RL,,, +MirOS Licence,MirOS,MirOS,,, +MIT +no-false-attribs license,MITNFA,MITNFA,,, +MIT License,MIT,MIT,,, +Motosoto License,Motosoto,Motosoto,,, +Mozilla Public License 1.0,MPL-1.0,MPLv1.0,Mozilla Public License v1.0,, +Mozilla Public License 1.1,MPL-1.1,MPLv1.1,Mozilla Public License v1.1,, +Mozilla Public License 2.0,MPL-2.0,MPLv2.0,Mozilla Public License v2.0,, +Mozilla Public License 2.0 (no copyleft exception),MPL-2.0-no-copyleft-exception,,,This variant not included on Fedora list (confirm this is correct statement), +mpich2 License,mpich2,MIT,,, +Multics License,Multics,,,not on Fedora list, +Mup License,Mup,Mup,,, +NASA Open Source Agreement 1.3,NASA-1.3,,,Fedora bad list, +Naumen Public License,Naumen,Naumen,,, +Net Boolean Public License v1,NBPL-1.0,,,not on Fedora list, +NetCDF license,NetCDF,NetCDF,,, +Nethack General Public License,NGPL,NGPL,,, +Netizen Open Source License,NOSL,NOSL,,, +Netscape Public License v1.0,NPL-1.0,Netscape,Netscape Public License,, +Netscape Public License v1.1,NPL-1.1,,,This specific version not on Fedora list, +Newsletr License,Newsletr,Newsletr,,, +No Limit Public License,NLPL,NLPL,,, +Nokia Open Source License,Nokia,Nokia,,, +Non-Profit Open Software License 3.0,NPOSL-3.0,,,not on Fedora list, +Noweb License,Noweb,Noweb,,, +NRL License,NRL,BSD with advertising,,, +NTP License,NTP,,,not on Fedora list, +Nunit License,Nunit,MIT with advertising,,, +OCLC Research Public License 2.0,OCLC-2.0,,,Fedora bad list, +ODC Open Database License v1.0,ODbL-1.0,,,not on Fedora list, +ODC Public Domain Dedication & License 1.0,PDDL-1.0,,,not on Fedora list, +Open Group Test Suite License,OGTSL,,,Fedora bad list, +Open LDAP Public License 2.2.2,OLDAP-2.2.2,,,This specific version not on Fedora list, +Open LDAP Public License v1.1,OLDAP-1.1,,,This specific version not on Fedora list, +Open LDAP Public License v1.2,OLDAP-1.2,,,This specific version not on Fedora list, +Open LDAP Public License v1.3,OLDAP-1.3,,,This specific version not on Fedora list, +Open LDAP Public License v1.4,OLDAP-1.4,,,This specific version not on Fedora list, +Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B),OLDAP-2.0,,,This specific version not on Fedora list, +Open LDAP Public License v2.0.1,OLDAP-2.0.1,,,This specific version not on Fedora list, +Open LDAP Public License v2.1,OLDAP-2.1,,,This specific version not on Fedora list, +Open LDAP Public License v2.2,OLDAP-2.2,,,This specific version not on Fedora list, +Open LDAP Public License v2.2.1,OLDAP-2.2.1,,,This specific version not on Fedora list, +Open LDAP Public License v2.3,OLDAP-2.3,,,This specific version not on Fedora list, +Open LDAP Public License v2.4,OLDAP-2.4,,,This specific version not on Fedora list, +Open LDAP Public License v2.5,OLDAP-2.5,,,This specific version not on Fedora list, +Open LDAP Public License v2.6,OLDAP-2.6,,,This specific version not on Fedora list, +Open LDAP Public License v2.7,OLDAP-2.7,,,This specific version not on Fedora list, +Open LDAP Public License v2.8,OLDAP-2.8,OpenLDAP,,, +Open Market License,OML,OML,,, +Open Public License v1.0,OPL-1.0,,,Fedora bad list, +Open Software License 1.0,OSL-1.0,OSL 1.0,,, +Open Software License 1.1,OSL-1.1,OSL 1.1,,, +Open Software License 2.0,OSL-2.0,OSL 2.0,,, +Open Software License 2.1,OSL-2.1,OSL 2.1,,, +Open Software License 3.0,OSL-3.0,OSL 3.0,,, +OpenSSL License,OpenSSL,OpenSSL,,, +PHP License v3.0,PHP-3.0,PHP,,, +PHP License v3.01,PHP-3.01,,,This specific version not on Fedora list, +Plexus Classworlds License,Plexus,Plexus,,, +PostgreSQL License,PostgreSQL,PostgreSQL,,, +psfrag License,psfrag,psfrag,,, +psutils License,psutils,psutils,,, +Python License 2.0,Python-2.0,,,"Stack of 4 licenses. SPDX version matches what is on OSI site. Fedora version looks to be more current version from Python website. May match, but need to check against SPDX matching guidelines (and possibly create template). SPDX could consider breaking indivicual licenses apart.", +Q Public License 1.0,QPL-1.0,QPL,Q Public License,, +Qhull License,Qhull,Qhull,,, +Rdisc License,Rdisc,Rdisc,,, +RealNetworks Public Source License v1.0,RPSL-1.0,RPSL,,, +Reciprocal Public License 1.1,RPL-1.1,,,Fedora bad list, +Reciprocal Public License 1.5,RPL-1.5,,,Fedora bad list, +Red Hat eCos Public License v1.1,RHeCos-1.1,,,not on Fedora list, +Ricoh Source Code Public License,RSCPL,,,Fedora bad list, +RSA Message-Digest License ,RSA-MD,,,not on Fedora list, +Ruby License,Ruby,Ruby,,, +Sax Public Domain Notice,SAX-PD,,,not on Fedora list, +Saxpath License,Saxpath,Saxpath,,, +SCEA Shared Source License,SCEA,SCEA,,, +Scheme Widget Library (SWL) Software License Agreement,SWL,SWL,,, +SGI Free Software License B v1.0,SGI-B-1.0,,,This specific version not on Fedora list, +SGI Free Software License B v1.1,SGI-B-1.1,,,Fedora bad list, +SGI Free Software License B v2.0,SGI-B-2.0,MIT,SGI Free Software License B 2.0,, +SIL Open Font License 1.0,OFL-1.0,,,not on Fedora list, +SIL Open Font License 1.1,OFL-1.1,,,not on Fedora list, +Simple Public License 2.0,SimPL-2.0,,,not on Fedora list, +Sleepycat License,Sleepycat,Sleepycat,,, +SNIA Public License 1.1,SNIA,SNIA,,, +Spencer License 86,Spencer-86,HSRL,Henry Spencer Reg-Ex Library License,, +Spencer License 94,Spencer-94,HSRL,Henry Spencer Reg-Ex Library License,, +Spencer License 99,Spencer-99,,,This specific version not on Fedora list, +Standard ML of New Jersey License,SMLNJ,MIT,,, +SugarCRM Public License v1.1.3,SugarCRM-1.1.3,,,not on Fedora list, +Sun Industry Standards Source License v1.1,SISSL,SISSL,,, +Sun Industry Standards Source License v1.2,SISSL-1.2,,,This specific version not on Fedora list, +Sun Public License v1.0,SPL-1.0,SPL,,, +Sybase Open Watcom Public License 1.0,Watcom-1.0,,,Fedora bad list, +TCL/TK License,TCL,TCL,,, +The Unlicense,Unlicense,Unlicense,Unlicense,, +TMate Open Source License,TMate,TMate,,, +TORQUE v2.5+ Software License v1.1,TORQUE-1.1,TORQUEv1.1,,, +Trusster Open Source License,TOSL,TOSL,,, +Unicode Terms of Use,Unicode-TOU,,,not on Fedora list, +Universal Permissive License v1.0,UPL-1.0,,,not on Fedora list, +University of Illinois/NCSA Open Source License,NCSA,NCSA,NCSA/University of Illinois Open Source License,, +Vim License,Vim,Vim,,, +VOSTROM Public License for Open Source,VOSTROM,VOSTROM,,, +Vovida Software License v1.0,VSL-1.0,VSL,,, +W3C Software Notice and License (1998-07-20),W3C-19980720,,,not on Fedora list, +W3C Software Notice and License (2002-12-31),W3C,W3C,,, +Wsuipa License,Wsuipa,Wsuipa,,, +X.Net License,Xnet,,,not on Fedora list, +X11 License,X11,MIT,,, +Xerox License,Xerox,Xerox,,, +XFree86 License 1.1,XFree86-1.1,,,not on Fedora list, +xinetd License,xinetd,xinetd,,, +XPP License,xpp,xpp,,, +XSkat License,XSkat,XSkat,,, +Yahoo! Public License v1.0,YPL-1.0,,,Fedora bad list, +Yahoo! Public License v1.1,YPL-1.1,YPLv1.1,,, +Zed License,Zed,Zed,,, +Zend License v2.0,Zend-2.0,Zend,,, +Zimbra Public License v1.3,Zimbra-1.3,,,Fedora bad list, +Zimbra Public License v1.4,Zimbra-1.4,,,not on Fedora list, +zlib License,Zlib,"zlib +Teeworlds",,,Teeworlds License +zlib/libpng License with Acknowledgement,zlib-acknowledgement,zlib with acknowledgement,,, +Zope Public License 1.1,ZPL-1.1,,,This specific version not on Fedora list, +Zope Public License 2.0,ZPL-2.0,ZPLv2.0,,, +Zope Public License 2.1,ZPL-2.1,ZPLv2.1,,, +BSD Zero Clause License,0BSD,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list", +CeCILL Free Software License Agreement v2.1,CECILL-2.1,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list", +CrystalStacker License,CrystalStacker,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list", +Interbase Public License v1.0,Interbase-1.0,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list", +Sendmail License,Sendmail,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list", +curl License,curl,,,"added to SPDX-LLv2.3, so was not part of comparison to Fedora list", +Info-ZIP License,Info-ZIP,,,"added to SPDX-LLv2.3, so was not part of comparison to Fedora list", +Open CASCADE Technology Public License,OCCT-PL,,,"added to SPDX-LLv2.3, so was not part of comparison to Fedora list", +Open Government Licence v3.0,OGL-3.0,,,"added to SPDX-LLv2.3, so was not part of comparison to Fedora list", +Norwegian Licence for Open Government Data,NLOD-1.0,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list", +FSF All Permissive License,FSFAP,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list", +Secure Messaging Protocol Public License,SMPPL,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list", +Licence Libre du Québec – Permissive version 1.1,LiLiQ-P-1.1,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list", +Licence Libre du Québec – Réciprocité forte version 1.1,LiLiQ-Rplus-1.1,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list", +Licence Libre du Québec – Réciprocité version 1.1,LiLiQ-R-1.1,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list", +OSET Public License version 2.1,OSET-PL-2.1,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list", +Free Art License 1.3,FAL-1.3,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list", +Free Art License 1.2,FAL-1.2,,,"added to SPDX-LLv2.4, so was not part of comparison to Fedora list", +BSD 3-Clause No Nuclear License,BSD-3-Clause-No-Nuclear-License,,,"added to SPDX-LLv2.5, so was not part of comparison to Fedora list", +BSD 3-Clause No Nuclear License 2014,BSD-3-Clause-No-Nuclear-License-2014,,,"added to SPDX-LLv2.5, so was not part of comparison to Fedora list", +BSD 3-Clause No Nuclear Warranty,BSD-3-Clause-No-Nuclear-Warranty,,,"added to SPDX-LLv2.5, so was not part of comparison to Fedora list", +BSD Source Code Attribution,BSD-Source-Code,,,"added to SPDX-LLv2.5, so was not part of comparison to Fedora list", +,,,,, +,,,,, +,,,,, +,,,,, +"License Exceptions: As per SPDX specification – these exceptions would use the short identifier for the main license, the “with” operator, and then the short identifier for the exception (shown here). See SPDX spec 2.0, Appendix IV",,,,, +"389 Directory Server +Exception",389-exception,GPLv2 with exceptions,Fedora Directory Server License,, +Autoconf exception 2.0,Autoconf-exception-2.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +Autoconf exception 3.0,Autoconf-exception-3.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +Bison exception 2.2,Bison-exception-2.2,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +Classpath exception 2.0,Classpath-exception-2.0,[identifier] with exceptions,"On Fedora List as ""GNU General Public License (no version), with Classpath exception"" and ""GNU General Public License v2.0 only, with Classpath exception"" and ""GNU General Public License v2.0 or later, with Classpath exception"" and ""GNU General Public License v3.0 only, with Classpath exception"" and ""GNU General Public License v3.0 or later, with Classpath exception""","Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” ", +CLISP exception 2.0 ,CLISP-exception-2.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +eCos exception 2.0,eCos-exception-2.0,eCos,eCos License v2.0,, +FLTK exception,FLTK-exception,LGPLv2 with exceptions,FTLK License,, +Font exception 2.0,Font-exception-2.0,[identifier] with exceptions,"On Fedora list as +""GNU General Public License v2.0 only, with font embedding exception"" and +""GNU General Public License v2.0 or later, with font embedding exception"" and +""GNU General Public License v3.0 only, with font embedding exception"" and +""GNU General Public License v3.0 or later, with font embedding exception"" and +""GNU General Public License (no version), with font embedding exception"".","Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +FreeRTOS Exception 2.0,freertos-exception-2.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +GCC Runtime Library exception 2.0,GCC-exception-2.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +GCC Runtime Library exception 3.1,GCC-exception-3.1,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +GNU JavaMail exception,gnu-javamail-exception,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +i2p GPL+Java Exception,i2p-gpl-java-exception,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +Libtool Exception,Libtool-exception,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +LZMA exception,LZMA-exception,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +Macros and Inline Functions Exception,mif-exception,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +Nokia Qt LGPL exception 1.1,Nokia-Qt-exception-1.1,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +Qwt exception 1.0,Qwt-exception-1.0,LGPLv2+ with exceptions,Qwt License 1.0,, +U-Boot exception 2.0,u-boot-exception-2.0,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +WxWindows Library Exception 3.1,WxWindows-exception-3.1,[identifier] with exceptions,,"Similar to SPDX, Fedora uses the applicable license identifier and then “with exceptions” (this is not specifically on Fedora list)", +DigiRule FOSS License Exception,DigiRule-FOSS-exception,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list", +Fawkes Runtime Exception,Fawkes-Runtime-exception,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list", +OpenVPN OpenSSL Exception,openvpn-openssl-exception,,,"added to SPDX-LLv2.2, so was not part of comparison to Fedora list", +Open CASCADE Exception 1.0,OCCT-exception-1.0,,,"added to SPDX-LLv2.3, so was not part of comparison to Fedora list", \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/rust2rpm/templates/main.spec new/rust2rpm-6/rust2rpm/templates/main.spec --- old/rust2rpm-5/rust2rpm/templates/main.spec 2018-01-08 20:15:07.000000000 +0100 +++ new/rust2rpm-6/rust2rpm/templates/main.spec 2018-09-02 18:23:55.000000000 +0200 @@ -20,7 +20,13 @@ Group: {{ rust_group }} {% endif %} -License: {{ md.license|default("# FIXME") }} +{% if md.license != license %} +# Upstream license specification: {{ md.license|default("(missing)") }} +{% endif %} +License: {{ license|default("# FIXME") }} +{% if license_comments is not none %} +{{ license_comments }} +{% endif %} URL: https://crates.io/crates/{{ md.name }} Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate {% if patch_file is not none %} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/rust2rpm/templates/opensuse-changelog.spec.inc new/rust2rpm-6/rust2rpm/templates/opensuse-changelog.spec.inc --- old/rust2rpm-5/rust2rpm/templates/opensuse-changelog.spec.inc 2018-01-08 20:15:07.000000000 +0100 +++ new/rust2rpm-6/rust2rpm/templates/opensuse-changelog.spec.inc 2018-09-02 18:23:55.000000000 +0200 @@ -1,3 +1,3 @@ -* {{ date }} {{ packager|default("rust2rpm <[email protected]>") }} +* {{ date }} {{ packager|default("rust2rpm <[email protected]>") }} - Version {{ md.version }} - Initial package diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/setup.py new/rust2rpm-6/setup.py --- old/rust2rpm-5/setup.py 2018-01-08 20:15:07.000000000 +0100 +++ new/rust2rpm-6/setup.py 2018-09-02 18:23:55.000000000 +0200 @@ -2,7 +2,7 @@ ARGS = dict( name="rust2rpm", - version="5", + version="6", description="Convert Rust crates to RPM", license="MIT", keywords="rust cargo rpm", @@ -10,6 +10,7 @@ packages=["rust2rpm"], package_data={ "rust2rpm": [ + "spdx_to_fedora.csv", "templates/*.spec", "templates/*.spec.inc", ], @@ -28,6 +29,9 @@ "jinja2", "requests", "tqdm", + + # Rust cfg language parser + "rustcfg", ], author="Igor Gnatenko", @@ -39,9 +43,8 @@ "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Build Tools", "Topic :: System :: Software Distribution", "Topic :: Utilities", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/rust2rpm-5/tox.ini new/rust2rpm-6/tox.ini --- old/rust2rpm-5/tox.ini 2018-01-08 20:15:07.000000000 +0100 +++ new/rust2rpm-6/tox.ini 2018-09-02 18:23:55.000000000 +0200 @@ -1,5 +1,5 @@ [tox] -envlist = py33,py34,py35,py36 +envlist = py36,py37 skipsdist = True [testenv]
