| |
@@ -89,7 +89,7 @@
|
| |
|
| |
# Sanitize a Go import path that can then serve as rpm package name
|
| |
# Mandatory parameter: a Go import path
|
| |
- def rpmname(goipath):
|
| |
+ def rpmname(goipath, use_new_versioning=True):
|
| |
# lowercase and end with '/'
|
| |
goname = goipath.lower() + "/"
|
| |
# remove eventual protocol prefix
|
| |
@@ -129,6 +129,20 @@
|
| |
# numbers on top of it, keep a - prefix before version strings
|
| |
result = re.sub(r"\-v([\.\d])$", r"-\g<1>", result)
|
| |
result = re.sub(r"\-v([\.\d]\-)", r"-\g<1>", result)
|
| |
+ # according to the guidelines, if the base package name does not end with
|
| |
+ # a digit, the version MUST be directly appended to the package name with
|
| |
+ # no intervening separator.
|
| |
+ # If the base package name ends with a digit, a single underscore (_) MUST
|
| |
+ # be appended to the name, and the version MUST be appended to that, in
|
| |
+ # order to avoid confusion over where the name ends and the version begins.
|
| |
+ if use_new_versioning:
|
| |
+ result = re.sub(
|
| |
+ r"([^-]*)(-?)([\.0-9]+)$",
|
| |
+ lambda m: f"{m.group(1)}_{m.group(3)}"
|
| |
+ if re.search(r"\d$", m.group(1))
|
| |
+ else f"{m.group(1)}{m.group(3)}",
|
| |
+ result,
|
| |
+ )
|
| |
return result
|
| |
|
| |
|
| |
@@ -507,6 +521,24 @@
|
| |
action="store_true",
|
| |
help="Do not generate a changelog entry",
|
| |
)
|
| |
+ versioning_group = parser.add_mutually_exclusive_group()
|
| |
+ versioning_group.add_argument(
|
| |
+ "-L",
|
| |
+ "--use-new-versioning",
|
| |
+ action="store_true",
|
| |
+ default=True,
|
| |
+ help="Enable new naming scheme for versioned compat packages that\n"
|
| |
+ "respect Fedora Packaging Guidelines.\n"
|
| |
+ "All new go packages should use this option.",
|
| |
+ )
|
| |
+ versioning_group.add_argument(
|
| |
+ "--no-use-new-versioning",
|
| |
+ action="store_false",
|
| |
+ dest="use_new_versioning",
|
| |
+ help="Use older naming scheme for versioned compat packages.\n"
|
| |
+ "This does not respect Fedora Packaging Guidelines and\n"
|
| |
+ "should not be used for new packages.",
|
| |
+ )
|
| |
parser.add_argument(
|
| |
"-", "--stdout", action="store_true", help="Print spec into stdout"
|
| |
)
|
| |
@@ -667,7 +699,7 @@
|
| |
if args.name:
|
| |
name = args.name
|
| |
else:
|
| |
- name = rpmname(goipath + subdir)
|
| |
+ name = rpmname(goipath + subdir, args.use_new_versioning)
|
| |
cmd = has_cmd(git_local_path)
|
| |
other_cmd = has_other_cmd(git_local_path)
|
| |
if "." in other_cmd:
|
| |
@@ -686,6 +718,7 @@
|
| |
kwargs["generator_version"] = __version__
|
| |
kwargs["goipath"] = goipath
|
| |
kwargs["goname"] = args.name
|
| |
+ kwargs["name"] = name
|
| |
kwargs["forge"] = forge
|
| |
kwargs["subdir"] = subdir
|
| |
kwargs["altipaths"] = args.altipaths
|
| |
@@ -710,6 +743,7 @@
|
| |
|
| |
kwargs["rpmautospec"] = args.rpmautospec
|
| |
kwargs["spec_warnings"] = args.spec_warnings
|
| |
+ kwargs["use_new_versioning"] = args.use_new_versioning
|
| |
if args.no_auto_changelog_entry:
|
| |
kwargs["auto_changelog_entry"] = False
|
| |
else:
|
| |
We add a flag to use new versioning for new packages, which is enabled by default.
We now hardcode the Name field to the value of goname,