From c955863d134d1e93a238817708c5812ef4dcbec3 Mon Sep 17 00:00:00 2001 From: Robert-André Mauchin Date: Sep 24 2023 12:38:48 +0000 Subject: Fix goname generation to match versioning guildelines The package version, which SHOULD include the periods present in the original version. - 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 the base package name does not end with a digit, the version MUST be directly appended to the package name with no intervening separator. --- diff --git a/rpm/lua/srpm/go.lua b/rpm/lua/srpm/go.lua index e6ac636..e0c93d6 100644 --- a/rpm/lua/srpm/go.lua +++ b/rpm/lua/srpm/go.lua @@ -69,6 +69,19 @@ local function rpmname(goipath, compatid) -- numbers on top of it, keep a - prefix before version strings result = string.gsub(result, "%-v([%.%d]+)$", "-%1") result = string.gsub(result, "%-v([%.%d]+%-)", "-%1") + -- 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 = string.gsub(result, "([^-]*)(%-?)([%.%d]+)$", function(prior, hyphen, version) + if string.find(prior, "%d$") then + return prior .. "_" .. version + else + return prior .. version + end + end) return(result) end