From f6e83032d4d5451420cd6dbb98b7241c28a0c708 Mon Sep 17 00:00:00 2001 From: Davide Cavalca Date: Jul 25 2021 23:19:06 +0000 Subject: Add support for rpmautospec --- diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index fb086c8..0c0592e 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -485,6 +485,13 @@ def main(): help="Print license mappings and exit", ) parser.add_argument( + "-r", + "--rpmautospec", + action="store_true", + default=False, + help="Use autorelease and autochangelog features" + ) + parser.add_argument( "--no-auto-changelog-entry", action="store_true", help="Do not generate a changelog entry", @@ -646,17 +653,24 @@ def main(): kwargs["main_cmd"] = main_cmd kwargs["other_cmd"] = other_cmd + kwargs["rpmautospec"] = args.rpmautospec if args.no_auto_changelog_entry: kwargs["auto_changelog_entry"] = False else: kwargs["auto_changelog_entry"] = True if version is None and tag is None: - kwargs["pkg_release"] = "0.1" + if kwargs["rpmautospec"]: + kwargs["pkg_release"] = "%autorelease -p" + else: + kwargs["pkg_release"] = "0.1%{?dist}" else: - kwargs["pkg_release"] = "1" + if kwargs["rpmautospec"]: + kwargs["pkg_release"] = "%autorelease" + else: + kwargs["pkg_release"] = "1%{?dist}" - kwargs["date"] = time.strftime("%a %b %d %T %Z %Y") + kwargs["date"] = time.strftime("%a %b %d %Y") kwargs["shortdate"] = time.strftime("%Y%m%d") if commit is not None: kwargs["shortcommit"] = commit[:7] diff --git a/go2rpm/templates/profile1.spec b/go2rpm/templates/profile1.spec index e648536..79e8b3d 100644 --- a/go2rpm/templates/profile1.spec +++ b/go2rpm/templates/profile1.spec @@ -32,7 +32,7 @@ Name: %{goname} {% if version is none and tag is none %} Version: 0 {% endif %} -Release: {{ pkg_release }}%{?dist} +Release: {{ pkg_release }} Summary: {{ summary|default("# FIXME") }} {% if licenses != license %} @@ -157,6 +157,9 @@ ln -s %{gopath}/src/%{goipath} %{buildroot}%{gopath}/src/%{altipath{{ loop.index {% endfor %} {% endif %} %changelog +{% if rpmautospec %} +%autochangelog +{%- else %} {% if auto_changelog_entry %} {% if version is none and tag is none and commit is not none %} * {{ date }} {{ packager|default("go2rpm ") }} - 0-{{ pkg_release }}.{{ shortdate }}git{{ shortcommit }} @@ -171,3 +174,4 @@ ln -s %{gopath}/src/%{goipath} %{buildroot}%{gopath}/src/%{altipath{{ loop.index {% endif %} - Initial package {% endif %} +{% endif %} diff --git a/go2rpm/templates/profile2.spec b/go2rpm/templates/profile2.spec index 73517a5..159f46f 100644 --- a/go2rpm/templates/profile2.spec +++ b/go2rpm/templates/profile2.spec @@ -37,7 +37,7 @@ Name: %{goname} {% if version is none and tag is none %} Version: 0 {% endif %} -Release: {{ pkg_release }}%{?dist} +Release: {{ pkg_release }} Summary: {{ summary|default("# FIXME") }} {% if licenses != license %} @@ -117,6 +117,9 @@ install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ %gopkgfiles %changelog +{% if rpmautospec %} +%autochangelog +{%- else %} {% if auto_changelog_entry %} {% if version is none and tag is none and commit is not none %} * {{ date }} {{ packager|default("go2rpm ") }} - 0-{{ pkg_release }}.{{ shortdate }}git{{ shortcommit }} @@ -131,3 +134,4 @@ install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ {% endif %} - Initial package {% endif %} +{% endif %}