From 39aa1bbc6ad33a3b603d2f2a16ab186c84c2342a Mon Sep 17 00:00:00 2001 From: Robert-André Mauchin Date: Oct 24 2023 16:50:21 +0000 Subject: Fix goname generation to match versioning guildelines According to the guidelines, 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 We have added a flag -L to gometa to enable the new versioning for new packages. This should be the default for every new packages. --- diff --git a/rpm/lua/srpm/go.lua b/rpm/lua/srpm/go.lua index e6ac636..b412b7a 100644 --- a/rpm/lua/srpm/go.lua +++ b/rpm/lua/srpm/go.lua @@ -69,6 +69,21 @@ 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") + if rpm.isdefined('go_use_new_versioning') then + -- 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) + end return(result) end diff --git a/rpm/macros.d/macros.go-srpm b/rpm/macros.d/macros.go-srpm index a46f81f..a8d951c 100644 --- a/rpm/macros.d/macros.go-srpm +++ b/rpm/macros.d/macros.go-srpm @@ -46,8 +46,14 @@ # from the primary package tracking the project recommended # version. For example: a (different) major version, a # specific shortened commit, etc -%gorpmname(c:) %{lua: +# -L Enable new naming scheme for versioned compat packages +# that respect Fedora Packaging Guidelines. +# All new go packages should use this option. +%gorpmname(Lc:) %{lua: local go = require "fedora.srpm.go" +if rpm.expand("%{-L}") ~= "" then + rpm.define("go_use_new_versioning 1") +end print(go.rpmname("%1", "%{-c*}")) } @@ -110,7 +116,10 @@ print(go.rpmname("%1", "%{-c*}")) # set at the end of the processing. # -f Use ExclusiveArch: %%{golang_arches_future}, which excludes the package # from %ix86. All new go packages should use this option. -%gometa(az:svif) %{lua: +# -L Enable new naming scheme for versioned compat packages that respects +# Fedora Packaging Guidelines. +# All new go packages should use this option. +%gometa(az:svifL) %{lua: if rpm.expand("%{-f}") == "" then exclusive_arches = "%{golang_arches}" else @@ -124,6 +133,9 @@ local verbose = rpm.expand("%{-v}") ~= "" local informative = rpm.expand("%{-i}") ~= "" local silent = rpm.expand("%{-s}") ~= "" local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") +if rpm.expand("%{-L}") ~= "" then + rpm.define("go_use_new_versioning 1") +end if processall then for _,s in pairs(fedora.getsuffixes("goipath")) do go.meta(s,verbose,informative,silent)