From 25ac2a17d5bb3902d9831575487207f84cab3dc1 Mon Sep 17 00:00:00 2001 From: Robert-André Mauchin Date: Sep 24 2023 15:24:42 +0000 Subject: Fix goname generation to match versioning guildelines --- diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index 332db23..4677eea 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -129,6 +129,19 @@ def rpmname(goipath): # 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. + 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 diff --git a/setup.py b/setup.py index fff7854..355a290 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ def read_version(path): with open(path, "rt") as f: for line in f: if line.startswith("__version__"): - return line.split("\"")[1] + return line.split('"')[1] raise IOError