From a09caca7e31d5034597a04e095e6818d8bcbe29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 8 Jul 2022 12:42:49 +0200 Subject: [PATCH] templates: rename "md" to "metadata" We also use "md" as short for "markdown", and this abbrevation can be confusing. It's also weird to use 'md' as the parameter name in an exported entry point. --- rust2rpm/__main__.py | 5 ++- rust2rpm/templates/fedora-changelog.spec.inc | 2 +- rust2rpm/templates/mageia-changelog.spec.inc | 2 +- rust2rpm/templates/main.spec | 32 +++++++++---------- .../templates/opensuse-changelog.spec.inc | 2 +- rust2rpm/templates/opensuse-header.spec.inc | 2 +- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index 72ecc37..2bb25cb 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -606,7 +606,10 @@ def main(): print("WARNING: Conflicting settings for enabling all features: The setting is \"false\"") print(" in rust2rpm.conf but it was enabled with the \"--all-features\" CLI flag.") - spec_contents = template.render(md=metadata, patch_file=patch_file, **kwargs) + spec_contents = template.render( + metadata=metadata, + patch_file=patch_file, + **kwargs) if args.stdout: print(f"# {spec_file}") print(spec_contents) diff --git a/rust2rpm/templates/fedora-changelog.spec.inc b/rust2rpm/templates/fedora-changelog.spec.inc index 5200a90..74994d2 100644 --- a/rust2rpm/templates/fedora-changelog.spec.inc +++ b/rust2rpm/templates/fedora-changelog.spec.inc @@ -1,2 +1,2 @@ -* {{ date }} {{ packager|default("rust2rpm ") }} - {{ md.version }}-1 +* {{ date }} {{ packager|default("rust2rpm ") }} - {{ metadata.version }}-1 - Initial package diff --git a/rust2rpm/templates/mageia-changelog.spec.inc b/rust2rpm/templates/mageia-changelog.spec.inc index 222813b..c803363 100644 --- a/rust2rpm/templates/mageia-changelog.spec.inc +++ b/rust2rpm/templates/mageia-changelog.spec.inc @@ -1,2 +1,2 @@ -* {{ date }} {{ packager|default("rust2rpm ") }} - {{ md.version }}-1 +* {{ date }} {{ packager|default("rust2rpm ") }} - {{ metadata.version }}-1 - Initial package diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec index 27fec02..4f0c09b 100644 --- a/rust2rpm/templates/main.spec +++ b/rust2rpm/templates/main.spec @@ -8,25 +8,25 @@ {% set only_main = True %} {% endif %} -%global crate {{ md.name }} -{% if md.name != crate %} +%global crate {{ metadata.name }} +{% if metadata.name != crate %} %global real_crate {{ crate }} {% endif %} Name: {{ pkg_name }} -Version: {{ md.version }} +Version: {{ metadata.version }} Release: {{ pkg_release }} -{% if md.description is none %} +{% if metadata.description is none %} Summary: # FIXME {% else %} -Summary: {{ md.summary }} +Summary: {{ metadata.summary }} {% endif %} {% if rust_group is defined %} Group: {{ rust_group }} {% endif %} -{% if md.license != license %} -# Upstream license specification: {{ md.license|default("(missing)") }} +{% if metadata.license != license %} +# Upstream license specification: {{ metadata.license|default("(missing)") }} {% endif %} License: {{ license|default("# FIXME") }} {% if license_comments is not none %} @@ -51,11 +51,11 @@ BuildRequires: rust-packaging >= 21 {% endif %} {% if not generate_buildrequires %} {% if not all_features %} - {% set buildrequires = normalize_deps(md.requires("default", resolve=True))|sort %} + {% set buildrequires = normalize_deps(metadata.requires("default", resolve=True))|sort %} {% else %} - {% set buildrequires = normalize_deps(md.all_dependencies)|sort %} + {% set buildrequires = normalize_deps(metadata.all_dependencies)|sort %} {% endif %} - {% set testrequires = normalize_deps(md.dev_dependencies)|sort %} + {% set testrequires = normalize_deps(metadata.dev_dependencies)|sort %} {% set has_buildrequires = (buildrequires + testrequires)|length > 0 %} {% if has_buildrequires and not only_main %} {% endif %} @@ -77,10 +77,10 @@ BuildRequires: {{ req }} {% endif %} %global _description %{expand: -{% if md.description is none %} +{% if metadata.description is none %} %{summary}. {%- else %} -{{ md.description|wordwrap }} +{{ metadata.description|wordwrap }} {%- endif %} } @@ -120,7 +120,7 @@ Requires: {{ req }} {% endif -%} {% if include_devel %} - {% set features = md.dependencies.keys()|list %} + {% set features = metadata.dependencies.keys()|list %} {% do features.remove(None) %} {% do features.remove("default") %} {% set features = features|sort %} @@ -144,11 +144,11 @@ Group: {{ rust_group }} {% endif %} BuildArch: noarch {% if include_provides %} -Provides: {{ md.provides(feature) }} +Provides: {{ metadata.provides(feature) }} {% endif %} {% if include_requires %} Requires: cargo - {% for req in normalize_deps(md.requires(feature))|map("string")|sort %} + {% for req in normalize_deps(metadata.requires(feature))|map("string")|sort %} Requires: {{ req }} {% endfor %} {% endif %} @@ -186,7 +186,7 @@ use {% if feature is not none %}the "{{ feature }}" feature of {% endif %}the "% {% endif -%} %prep -{% if md.name != crate %} +{% if metadata.name != crate %} %autosetup -n %{real_crate}-%{version_no_tilde} -p1 {% else %} %autosetup -n %{crate}-%{version_no_tilde} -p1 diff --git a/rust2rpm/templates/opensuse-changelog.spec.inc b/rust2rpm/templates/opensuse-changelog.spec.inc index 8849edd..5b8b310 100644 --- a/rust2rpm/templates/opensuse-changelog.spec.inc +++ b/rust2rpm/templates/opensuse-changelog.spec.inc @@ -1,3 +1,3 @@ * {{ date }} {{ packager|default("rust2rpm ") }} -- Version {{ md.version }} +- Version {{ metadata.version }} - Initial package diff --git a/rust2rpm/templates/opensuse-header.spec.inc b/rust2rpm/templates/opensuse-header.spec.inc index b1e98be..87592dd 100644 --- a/rust2rpm/templates/opensuse-header.spec.inc +++ b/rust2rpm/templates/opensuse-header.spec.inc @@ -1,5 +1,5 @@ # -# spec file for package rust-{{ md.name }} +# spec file for package rust-{{ metadata.name }} # # Copyright (c) {{ spec_copyright_year }} {{ packager|default("SUSE LINUX GmbH, Nuernberg, Germany") }}. #