From 29040f7cacec2c9d627728574b0537ae2f17538b Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Aug 08 2022 00:11:07 +0000 Subject: [PATCH 1/8] Use %%gometa -f by default --- diff --git a/go2rpm/templates/profile2.spec b/go2rpm/templates/profile2.spec index 5f29bd3..8b8b14b 100644 --- a/go2rpm/templates/profile2.spec +++ b/go2rpm/templates/profile2.spec @@ -20,7 +20,17 @@ Version: {{ tag }} %global commit {{ commit }} {% endif %} -%gometa +# REMOVE BEFORE SUBMITTING THIS FOR REVIEW +# --- +# New Fedora packages should use %%gometa -f, which makes the package +# ExclusiveArch to %%golang_arches_future and thus excludes the package from +# %%ix86. If the new package is needed as a dependency for another pacage, +# please consider removing that package from %%ix86 in the same way, instead of +# building more go packages for i686. If your package is not a leaf package, +# you'll need to coordinate the removal of the package's dependents first. +# --- +# REMOVE BEFORE SUBMITTING THIS FOR REVIEW +%gometa -f {% if altipaths is not none %} %global goaltipaths {{ altipaths|join(' ') }} From 18ab13f595d08b259a1474d9d319d372d0895867 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Aug 08 2022 00:11:09 +0000 Subject: [PATCH 2/8] Remove old rust2rpm licensing import --- diff --git a/go2rpm/__init__.py b/go2rpm/__init__.py index 56e6478..14d9d2f 100644 --- a/go2rpm/__init__.py +++ b/go2rpm/__init__.py @@ -1,3 +1 @@ -from rust2rpm import licensing - __version__ = "1.7.0" From 7532863f7988c1331facb91b8c95649df44922a7 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Aug 08 2022 00:11:09 +0000 Subject: [PATCH 3/8] template: Remove leading newline from %description The definition of %common_description already has a leading newline, so %common_description should be on the same line as %description. --- diff --git a/go2rpm/templates/profile2.spec b/go2rpm/templates/profile2.spec index 8b8b14b..be62f90 100644 --- a/go2rpm/templates/profile2.spec +++ b/go2rpm/templates/profile2.spec @@ -80,8 +80,7 @@ BuildRequires: golang({{ req }}) {% endif %} {% endif %} -%description -%{common_description} +%description %{common_description} %gopkg From d585cbc9fad7ae2fc6ce2fdde8c365010bf0bae2 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Aug 08 2022 00:11:09 +0000 Subject: [PATCH 4/8] Format with black --- diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index 63748d6..af40fd6 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -491,7 +491,7 @@ def main(): "--rpmautospec", action="store_true", default=True, - help="Use autorelease and autochangelog features" + help="Use autorelease and autochangelog features", ) parser.add_argument( "--no-auto-changelog-entry", @@ -536,10 +536,17 @@ def main(): parser.add_argument( "-c", "--commit", action="store", nargs="?", help="Package commit" ) - parser.add_argument("--dynamic-buildrequires", action="store_true", - help="Use dynamic BuildRequires feature") - parser.add_argument("-R", "--no-dynamic-buildrequires", action="store_true", - help="Do not use dynamic BuildRequires feature") + parser.add_argument( + "--dynamic-buildrequires", + action="store_true", + help="Use dynamic BuildRequires feature", + ) + parser.add_argument( + "-R", + "--no-dynamic-buildrequires", + action="store_true", + help="Do not use dynamic BuildRequires feature", + ) parser.add_argument( "-C", "--clean", @@ -556,7 +563,13 @@ def main(): goipath = re.sub(r"^http(s?)://", r"", args.goipath) goipath = goipath.strip("/") - known_forge = ("github.com", "gitlab.com", "bitbucket.org", "pagure.io", "gitea.com") + known_forge = ( + "github.com", + "gitlab.com", + "bitbucket.org", + "pagure.io", + "gitea.com", + ) known_forge_re = r"^(" + r"|".join(re.escape(url) for url in known_forge) + r")" if not re.search(known_forge_re, goipath) and args.forge is None: print( @@ -606,7 +619,9 @@ def main(): set(buildrequires) ) ) - test_buildrequires = [ipath for ipath in test_buildrequires if goipath not in ipath] + test_buildrequires = [ + ipath for ipath in test_buildrequires if goipath not in ipath + ] else: args.dynamic_buildrequires = True buildrequires = [] From 68319e32553279e7d37d61bd4158093c443e9438 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Aug 08 2022 00:11:09 +0000 Subject: [PATCH 5/8] Make contradictory arguments mutually exclusive --- diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index af40fd6..f28a9fb 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -486,7 +486,8 @@ def main(): parser = argparse.ArgumentParser( "go2rpm", formatter_class=argparse.RawTextHelpFormatter ) - parser.add_argument( + changelog_group = parser.add_mutually_exclusive_group() + changelog_group.add_argument( "-r", "--rpmautospec", action="store_true", @@ -536,12 +537,13 @@ def main(): parser.add_argument( "-c", "--commit", action="store", nargs="?", help="Package commit" ) - parser.add_argument( + dynamic_br_group = parser.add_mutually_exclusive_group() + dynamic_br_group.add_argument( "--dynamic-buildrequires", action="store_true", help="Use dynamic BuildRequires feature", ) - parser.add_argument( + dynamic_br_group.add_argument( "-R", "--no-dynamic-buildrequires", action="store_true", From 7fe215cad826413a698df0b1351b1541158f8947 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Aug 08 2022 00:23:40 +0000 Subject: [PATCH 6/8] Add argument to disable rpmautospec --- diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index f28a9fb..c29d901 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -494,6 +494,13 @@ def main(): default=True, help="Use autorelease and autochangelog features", ) + changelog_group.add_argument( + "-n", + "--no-rpmautospec", + action="store_false", + dest="rpmautospec", + help="Use static release and changelog instead of rpmautospec.", + ) parser.add_argument( "--no-auto-changelog-entry", action="store_true", From 18f60303d61fd59337185c37f024274694af93c4 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Aug 08 2022 00:23:40 +0000 Subject: [PATCH 7/8] Fix jinja2 deprecation warning --- diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index c29d901..1cb92d3 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -53,7 +53,7 @@ def file_mtime(path): return datetime.fromtimestamp(os.stat(path).st_mtime, timezone.utc).isoformat() -@jinja2.environmentfilter +@jinja2.pass_environment def do_customwordwrap( environment, s, From 473bfbffbec70bd26fbfb39a3a2995f611e83da2 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Aug 08 2022 00:23:40 +0000 Subject: [PATCH 8/8] Add --no-spec-warnings argument --- diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index 1cb92d3..1af5e24 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -521,6 +521,14 @@ def main(): 1: legacy macros. 2: current macros. \ default: 2", ) + parser.add_argument( + "-q", + "--no-spec-warnings", + dest="spec_warnings", + action="store_false", + help="Exclude warning comments from generated specfile. " + "Currently, this only removes the %%gometa -f explanatory comment.", + ) parser.add_argument("-f", "--forge", action="store", nargs="?", help="Forge URL") parser.add_argument( "-s", @@ -687,6 +695,7 @@ def main(): kwargs["other_cmd"] = other_cmd kwargs["rpmautospec"] = args.rpmautospec + kwargs["spec_warnings"] = args.spec_warnings if args.no_auto_changelog_entry: kwargs["auto_changelog_entry"] = False else: diff --git a/go2rpm/templates/profile2.spec b/go2rpm/templates/profile2.spec index be62f90..d2696ca 100644 --- a/go2rpm/templates/profile2.spec +++ b/go2rpm/templates/profile2.spec @@ -20,6 +20,7 @@ Version: {{ tag }} %global commit {{ commit }} {% endif %} +{% if spec_warnings %} # REMOVE BEFORE SUBMITTING THIS FOR REVIEW # --- # New Fedora packages should use %%gometa -f, which makes the package @@ -30,6 +31,7 @@ Version: {{ tag }} # you'll need to coordinate the removal of the package's dependents first. # --- # REMOVE BEFORE SUBMITTING THIS FOR REVIEW +{% endif %} %gometa -f {% if altipaths is not none %}