diff --git a/macros.go-srpm b/macros.go-srpm index 3e87388..c0c6403 100644 --- a/macros.go-srpm +++ b/macros.go-srpm @@ -26,10 +26,16 @@ # Mandatory parameter: a Go import path %gorpmname() %{lua: local goname = rpm.expand("%1") +-- add a golang prefix and lowercase goname = string.lower("golang-" .. goname .. "/") +-- replace various separators rpm does not like with - +-- special-case x.y.z number-strings as that’s an exception in our naming +-- guidelines goname = string.gsub(goname, "^([^/]+)%.([^%./]+)/", "%1/") goname = string.gsub(goname, "(%d)%.(%d)", "%1|%2") goname = string.gsub(goname, "[%._/%-]+", "-") +-- Tokenize along - separators and remove duplicates to avoid +-- golang-foo-foo-bar-foo names local result = "" local tokens = {} tokens["go"] = true @@ -40,6 +46,8 @@ for token in string.gmatch(goname, "[^%-]+") do tokens[token] = true end end +-- reassemble the string, restore x.y.z runs, convert the vx.y.z +-- Go convention to x.y.z as prefered in rpm naming result = string.gsub(result, "^-", "") result = string.gsub(result, "|", ".") result = string.gsub(result, "%-v([%.%d])", "%1")