#10 Move a lot of code unrelated to srpm creation to srpm macros
Merged 9 months ago by nim. Opened 9 months ago by nim.
nim/go-rpm-macros move-headers-to-srpm  into  master

file modified
+12 -209

@@ -1,4 +1,4 @@ 

- -- Copyright © 2017-2018 Nicolas Mailhot <nim@fedoraproject.org>

+ -- Copyright © 2017-2019 Nicolas Mailhot <nim@fedoraproject.org>

  --

  -- This program is free software: you can redistribute it and/or modify

  -- it under the terms of the GNU General Public License as published by

@@ -19,30 +19,6 @@ 

  -- The sister file gosrpm.lua deals with srpm and buildroot setup and is more

  -- restricted.

  

- -- Pivot variable definitions for each kind of Go package

- local pivot = {devel = "goipaths", alt = "goaltipaths"}

- 

- -- Default argument flag for each kind of list

- local listflags = {goipaths = "-i", goipathsex = "-t", goextensions = "-e"}

- 

- -- Convert a space-separated list of import paths to a table indexed by their

- -- rpmname version, to handle upstreams that play naming games

- local function indexedgoipaths(goipaths, gocid)

-   local       go = require "fedora.srpm.go"

-   local giptable = {}

-   for goipath in string.gmatch(rpm.expand(goipaths), "[^%s,]+") do

-     local key = go.rpmname(goipath, gocid)

-     if (not string.match(key, "^compat-")) then

-       key = "compat-" .. key

-     end

-     if (giptable[key] == nil) then

-       giptable[key] = {}

-     end

-     table.insert(giptable[key], goipath)

-   end

-   return giptable

- end

- 

  -- The goenv macro main processing function

  -- See the documentation in the macros.go-rpm file for argument description

  local function env(suffix, goipath, verbose, usermetadata)

@@ -94,140 +70,11 @@ 

    fedora.explicitset(  "currentgoldflags", ldflags,                 verbose)

  end

  

- -- Create fallbacks to goipath variables if godevelipath variables are missing

- local function develenvinit()

-   local  fedora = require "fedora.common"

-   if (next(fedora.getsuffixes("goipaths")) == nil) then

-     for _, suffix in pairs(fedora.getsuffixes("goipath")) do

-       fedora.safeset("goipaths" .. suffix, "%{goipath" .. suffix .. "}")

-     end

-   end

- end

- 

- -- Set rpm variables related to the processing of a golang-*-devel subpackage

- local function develenv(suffix, verbose)

-   local fedora = require "fedora.common"

-   local     go = require "fedora.srpm.go"

-   local ismain = (suffix == "") or (suffix == "0")

-   if ismain then

-     fedora.zalias(  {"goipath", "gocid", "gofilelist",

-                      "godevelname", "godevelcid", "godevelfilelist", "godevelsummary", "godeveldescription",

-                      "godevelheader", "goextensions", "gosupfiles", "gosupfilesex",

-                      "goipaths", "goipathsex", "golicenses", "golicensesex", "godocs", "godocsex"},           verbose)

-   end

-   for list, flag in pairs(listflags) do

-     local l = rpm.expand("%{?" .. list .. suffix .. "}")

-     if (l ~= "") then

-       l = string.gsub(" " .. l, "%s+%" .. flag .. "%s+", " ")

-       l = string.gsub(l, "%s+", " ")

-       l = string.gsub(l, "^ ", "")

-       l = string.gsub(l, " $", "")

-       if (list ~= "goipaths") then

-         l = string.gsub(l, "([^%s]+)", flag .. " %1")

-       end

-       fedora.explicitset(list .. suffix, l)

-     end

-   end

-   local  goipaths = rpm.expand("%{?goipaths" .. suffix .. "}")

-   local   goipath = string.match(goipaths, "[^%s]+")

-   fedora.safeset("godevelcid"         .. suffix, "%{?gocid"       .. suffix .. "}",                           verbose)

-   local   rpmname = go.rpmname(goipath,           "%{?godevelcid" .. suffix .. "}")

-   fedora.safeset("godevelname"        .. suffix, rpmname .. "-devel",                                         verbose)

-   fedora.safeset("godevelfilelist"    .. suffix, rpmname .. "-%{gofilelist}",                                 verbose)

-   fedora.safeset("godevelsummary"     .. suffix, "%{summary}",                                                verbose)

-   fedora.safeset("godeveldescription" .. suffix, "%{?common_description}",                                    verbose)

-   local postdescr = "\n\nThis package contains the source code needed for building packages that reference " ..

-                     "the following Go import paths:"

-   postdescr       = postdescr .. string.gsub(goipaths, "([^%s]+)", "\n – %1")

-   fedora.explicitset("currentgodeveldescription", "%{expand:%{godeveldescription" .. suffix .. "}" ..

-                                                   postdescr .. "}",                                           verbose)

-   fedora.setcurrent({"godevelname", "godevelcid", "godevelfilelist", "godevelsummary",

-                      "godevelheader", "goextensions", "gosupfiles", "gosupfilesex",

-                      "goipaths", "goipathsex", "golicenses", "golicensesex", "godocs", "godocsex"}, suffix,   verbose)

-   if ismain then

-     fedora.zalias(  {"godevelname", "godevelcid", "godevelfilelist", "godevelsummary", "godeveldescription"}, verbose)

-   end

- end

- 

- -- Set rpm variables related to the processing of a compat-golang-*-devel subpackage

- local function altenv(suffix, rpmname, goaltipaths, verbose)

-   local fedora = require "fedora.common"

-   local     go = require "fedora.srpm.go"

-   local ismain = (suffix == "") or (suffix == "0")

-   if ismain then

-     fedora.zalias(  {"goipath", "gocanonipath",

-                      "goaltdescription", "goaltsummary", "goaltheader"},                                      verbose)

-   end

-   fedora.safeset("gocanonipath"     .. suffix,    "%{goipath" .. suffix .. "}",                               verbose)

-   fedora.safeset("goaltsummary"     .. suffix,    "%{summary}",                                               verbose)

-   fedora.safeset("goaltdescription" .. suffix,    "%{?common_description}",                                   verbose)

-   fedora.setcurrent( {"gocanonipath", "goaltcid", "goaltsummary"}, suffix,                                    verbose)

-   local postdescr = "\n\nThis package provides symbolic links that alias the following Go import paths "   ..

-                     "to %{currentgocanonipath}:"

-   local  posthead = ""

-   for _, goaltipath in ipairs(goaltipaths) do

-     postdescr     = postdescr .. "\n – " .. goaltipath

-     posthead      = "\nObsoletes: " .. go.rpmname(goaltipath, "") .. "-devel < %{version}-%{release}"

-   end

-   postdescr       = postdescr ..

-                     "\n\nAliasing Go import paths via symbolic links or http redirects is fragile. " ..

-                         "If your Go code depends on this package, you should patch it to import "   ..

-                         "directly %{currentgocanonipath}."

-   fedora.explicitset("currentgoaltdescription", "%{expand:%{?goaltdescription" .. suffix .. "}" ..

-                                                    postdescr .. "}",                                          verbose)

-   fedora.explicitset("currentgoaltheader",      "%{expand:%{?goaltheader" .. suffix .. "}"      ..

-                                                    posthead  .. "}",                                          verbose)

-   fedora.explicitset("currentgoaltname",        rpmname .. "-devel",                                          verbose)

-   fedora.explicitset("currentgoaltfilelist",    rpmname .. "-%{gofilelist}",                                  verbose)

-   if ismain then

-     fedora.zalias(  {"gocanonipath", "goaltsummary", "goaltdescription"},                                     verbose)

-   end

- end

- 

- -- Create a single %package section for a known kind of Go subpackage

- local function singlepkg(kind, suffix, verbose)

-   if     (kind == "devel")  then

-     develenv(suffix, verbose)

-     print(rpm.expand('%__godevelpkg\n'))

-   elseif (kind == "alt") then

-     local fedora = require "fedora.common"

-     local ismain = (suffix == "") or (suffix == "0")

-     if ismain then

-       fedora.zalias({"goaltipaths","gocid","goaltcid"},                verbose)

-     end

-     fedora.safeset("goaltcid" .. suffix, "%{?gocid"  .. suffix .. "}", verbose)

-     if ismain then

-       fedora.zalias({"goaltcid"},                                      verbose)

-     end

-     for rpmname, goaltipaths in pairs(indexedgoipaths("%{goaltipaths" .. suffix .. "}",

-                                                       "%{goaltcid"    .. suffix .. "}")) do

-       altenv(suffix, rpmname, goaltipaths, verbose)

-       print(rpm.expand('%__goaltpkg\n'))

-     end

-   else

-     rpm.expand("%{error:Unknown kind of Go subpackage: " .. kind .. "}")

-   end

- end

- 

- -- Create one or all %package sections for a known kind of go subpackage

- local function pkg(kind, suffix, processall, verbose)

-   local fedora = require "fedora.common"

-   if (kind == "devel") then

-     develenvinit()

-   end

-   if processall then

-     for _, suffix in pairs(fedora.getsuffixes(pivot[kind])) do

-        singlepkg(kind, suffix, verbose)

-     end

-   else

-     singlepkg(kind, suffix, verbose)

-   end

- end

- 

  -- Create a single set of %install tasks for a known kind of Go subpackage

  local function singleinstall(kind, suffix, verbose)

+   local go = require "fedora.srpm.go"

    if     (kind == "devel")  then

-     develenv(suffix, verbose)

+     go.develenv(suffix, verbose)

      for goipath in string.gmatch(rpm.expand("%{currentgoipaths}"), "[^%s]+") do

        env('', goipath, verbose, {})

        local vflag = verbose and " -v" or ""

@@ -244,9 +91,9 @@ 

      if ismain then

        fedora.zalias({"goaltcid"},                                      verbose)

      end

-     for rpmname, goaltipaths in pairs(indexedgoipaths("%{goaltipaths" .. suffix .. "}",

-                                                       "%{goaltcid"    .. suffix .. "}")) do

-       altenv(suffix, rpmname, goaltipaths, verbose)

+     for rpmname, goaltipaths in pairs(go.indexedgoipaths("%{goaltipaths" .. suffix .. "}",

+                                                          "%{goaltcid"    .. suffix .. "}")) do

+       go.altenv(suffix, rpmname, goaltipaths, verbose)

        gocanonipath = rpm.expand("%{currentgocanonipath}")

        for _, goaltipath in ipairs(goaltipaths) do

          fedora.explicitset("currentgoaltipath", goaltipath)

@@ -265,12 +112,13 @@ 

  

  -- Create one or all %install tasks for a known kind of go subpackage

  local function install(kind, suffix, processall, verbose)

-   local  fedora = require "fedora.common"

+   local fedora = require "fedora.common"

+   local go     = require "fedora.srpm.go"

    if (kind == "devel") then

-     develenvinit()

+     go.develenvinit()

    end

    if processall then

-     for _, suffix in pairs(fedora.getsuffixes(pivot[kind])) do

+     for _, suffix in pairs(fedora.getsuffixes(go.pivot[kind])) do

         singleinstall(kind, suffix, verbose)

      end

    else

@@ -278,52 +126,7 @@ 

    end

  end

  

- -- Create a single %files section for a known kind of Go subpackage

- local function singlefiles(kind, suffix, verbose)

-   if     (kind == "devel")  then

-     develenv(suffix, verbose)

-     print(rpm.expand('%files -n %{currentgodevelname}    -f "%{goworkdir}/%{currentgodevelfilelist}"\n'))

-   elseif (kind == "alt") then

-     local fedora = require "fedora.common"

-     local ismain = (suffix == "") or (suffix == "0")

-     if ismain then

-       fedora.zalias({"goaltipaths","gocid","goaltcid"},                verbose)

-     end

-     fedora.safeset("goaltcid" .. suffix, "%{?gocid"  .. suffix .. "}", verbose)

-     if ismain then

-       fedora.zalias({"goaltcid"},                                      verbose)

-     end

-     for rpmname, goaltipaths in pairs(indexedgoipaths("%{goaltipaths" .. suffix .. "}",

-                                                       "%{goaltcid"    .. suffix .. "}")) do

-       altenv(suffix, rpmname, goaltipaths, verbose)

-       print(rpm.expand('%files -n %{currentgoaltname} -f "%{goworkdir}/%{currentgoaltfilelist}"\n'))

-     end

-   else

-     rpm.expand("%{error:Unknown kind of Go subpackage: " .. kind .. "}")

-   end

- end

- 

- -- Create one or all %files sections for a known kind of go subpackage

- local function files(kind, suffix, processall, verbose)

-   local fedora = require "fedora.common"

-   if (kind == "devel") then

-     develenvinit()

-   end

-   if processall then

-     for _, suffix in pairs(fedora.getsuffixes(pivot[kind])) do

-        singlefiles(kind, suffix, verbose)

-     end

-   else

-     singlefiles(kind, suffix, verbose)

-   end

- end

- 

  return {

-   env       = env,

-   develenv  = develenv,

-   altenv    = altenv,

-   pkg       = pkg,

-   install   = install,

-   files     = files,

+   env     = env,

+   install = install,

  }

- 

file modified
+204 -3

@@ -1,4 +1,4 @@ 

- -- Copyright (c) 2017-2018 Nicolas Mailhot <nim@fedoraproject.org>

+ -- Copyright (c) 2017-2019 Nicolas Mailhot <nim@fedoraproject.org>

  --

  -- This program is free software: you can redistribute it and/or modify

  -- it under the terms of the GNU General Public License as published by

@@ -116,7 +116,208 @@ 

    end

  end

  

+ -- Pivot variable definitions for each kind of Go package

+ local pivot = {devel = "goipaths", alt = "goaltipaths"}

+ 

+ -- Default argument flag for each kind of list

+ local listflags = {goipaths = "-i", goipathsex = "-t", goextensions = "-e"}

+ 

+ -- Convert a space-separated list of import paths to a table indexed by their

+ -- rpmname version, to handle upstreams that play naming games

+ local function indexedgoipaths(goipaths, gocid)

+   local       go = require "fedora.srpm.go"

+   local giptable = {}

+   for goipath in string.gmatch(rpm.expand(goipaths), "[^%s,]+") do

+     local key = go.rpmname(goipath, gocid)

+     if (not string.match(key, "^compat-")) then

+       key = "compat-" .. key

+     end

+     if (giptable[key] == nil) then

+       giptable[key] = {}

+     end

+     table.insert(giptable[key], goipath)

+   end

+   return giptable

+ end

+ 

+ -- Create fallbacks to goipath variables if godevelipath variables are missing

+ local function develenvinit()

+   local  fedora = require "fedora.common"

+   if (next(fedora.getsuffixes("goipaths")) == nil) then

+     for _, suffix in pairs(fedora.getsuffixes("goipath")) do

+       fedora.safeset("goipaths" .. suffix, "%{goipath" .. suffix .. "}")

+     end

+   end

+ end

+ 

+ -- Set rpm variables related to the processing of a golang-*-devel subpackage

+ local function develenv(suffix, verbose)

+   local fedora = require "fedora.common"

+   local     go = require "fedora.srpm.go"

+   local ismain = (suffix == "") or (suffix == "0")

+   if ismain then

+     fedora.zalias(  {"goipath", "gocid", "gofilelist",

+                      "godevelname", "godevelcid", "godevelfilelist", "godevelsummary", "godeveldescription",

+                      "godevelheader", "goextensions", "gosupfiles", "gosupfilesex",

+                      "goipaths", "goipathsex", "golicenses", "golicensesex", "godocs", "godocsex"},           verbose)

+   end

+   for list, flag in pairs(listflags) do

+     local l = rpm.expand("%{?" .. list .. suffix .. "}")

+     if (l ~= "") then

+       l = string.gsub(" " .. l, "%s+%" .. flag .. "%s+", " ")

+       l = string.gsub(l, "%s+", " ")

+       l = string.gsub(l, "^ ", "")

+       l = string.gsub(l, " $", "")

+       if (list ~= "goipaths") then

+         l = string.gsub(l, "([^%s]+)", flag .. " %1")

+       end

+       fedora.explicitset(list .. suffix, l)

+     end

+   end

+   local  goipaths = rpm.expand("%{?goipaths" .. suffix .. "}")

+   local   goipath = string.match(goipaths, "[^%s]+")

+   fedora.safeset("godevelcid"         .. suffix, "%{?gocid"       .. suffix .. "}",                           verbose)

+   local   rpmname = go.rpmname(goipath,           "%{?godevelcid" .. suffix .. "}")

+   fedora.safeset("godevelname"        .. suffix, rpmname .. "-devel",                                         verbose)

+   fedora.safeset("godevelfilelist"    .. suffix, rpmname .. "-%{gofilelist}",                                 verbose)

+   fedora.safeset("godevelsummary"     .. suffix, "%{summary}",                                                verbose)

+   fedora.safeset("godeveldescription" .. suffix, "%{?common_description}",                                    verbose)

+   local postdescr = "\n\nThis package contains the source code needed for building packages that reference " ..

+                     "the following Go import paths:"

+   postdescr       = postdescr .. string.gsub(goipaths, "([^%s]+)", "\n – %1")

+   fedora.explicitset("currentgodeveldescription", "%{expand:%{godeveldescription" .. suffix .. "}" ..

+                                                   postdescr .. "}",                                           verbose)

+   fedora.setcurrent({"godevelname", "godevelcid", "godevelfilelist", "godevelsummary",

+                      "godevelheader", "goextensions", "gosupfiles", "gosupfilesex",

+                      "goipaths", "goipathsex", "golicenses", "golicensesex", "godocs", "godocsex"}, suffix,   verbose)

+   if ismain then

+     fedora.zalias(  {"godevelname", "godevelcid", "godevelfilelist", "godevelsummary", "godeveldescription"}, verbose)

+   end

+ end

+ 

+ -- Set rpm variables related to the processing of a compat-golang-*-devel subpackage

+ local function altenv(suffix, rpmname, goaltipaths, verbose)

+   local fedora = require "fedora.common"

+   local     go = require "fedora.srpm.go"

+   local ismain = (suffix == "") or (suffix == "0")

+   if ismain then

+     fedora.zalias(  {"goipath", "gocanonipath",

+                      "goaltdescription", "goaltsummary", "goaltheader"},                                      verbose)

+   end

+   fedora.safeset("gocanonipath"     .. suffix,    "%{goipath" .. suffix .. "}",                               verbose)

+   fedora.safeset("goaltsummary"     .. suffix,    "%{summary}",                                               verbose)

+   fedora.safeset("goaltdescription" .. suffix,    "%{?common_description}",                                   verbose)

+   fedora.setcurrent( {"gocanonipath", "goaltcid", "goaltsummary"}, suffix,                                    verbose)

+   local postdescr = "\n\nThis package provides symbolic links that alias the following Go import paths "   ..

+                     "to %{currentgocanonipath}:"

+   local  posthead = ""

+   for _, goaltipath in ipairs(goaltipaths) do

+     postdescr     = postdescr .. "\n – " .. goaltipath

+     posthead      = "\nObsoletes: " .. go.rpmname(goaltipath, "") .. "-devel < %{version}-%{release}"

+   end

+   postdescr       = postdescr ..

+                     "\n\nAliasing Go import paths via symbolic links or http redirects is fragile. " ..

+                         "If your Go code depends on this package, you should patch it to import "   ..

+                         "directly %{currentgocanonipath}."

+   fedora.explicitset("currentgoaltdescription", "%{expand:%{?goaltdescription" .. suffix .. "}" ..

+                                                    postdescr .. "}",                                          verbose)

+   fedora.explicitset("currentgoaltheader",      "%{expand:%{?goaltheader" .. suffix .. "}"      ..

+                                                    posthead  .. "}",                                          verbose)

+   fedora.explicitset("currentgoaltname",        rpmname .. "-devel",                                          verbose)

+   fedora.explicitset("currentgoaltfilelist",    rpmname .. "-%{gofilelist}",                                  verbose)

+   if ismain then

+     fedora.zalias(  {"gocanonipath", "goaltsummary", "goaltdescription"},                                     verbose)

+   end

+ end

+ 

+ -- Create a single %package section for a known kind of Go subpackage

+ local function singlepkg(kind, suffix, verbose)

+   if     (kind == "devel")  then

+     develenv(suffix, verbose)

+     print(rpm.expand('%__godevelpkg\n'))

+   elseif (kind == "alt") then

+     local fedora = require "fedora.common"

+     local ismain = (suffix == "") or (suffix == "0")

+     if ismain then

+       fedora.zalias({"goaltipaths","gocid","goaltcid"},                verbose)

+     end

+     fedora.safeset("goaltcid" .. suffix, "%{?gocid"  .. suffix .. "}", verbose)

+     if ismain then

+       fedora.zalias({"goaltcid"},                                      verbose)

+     end

+     for rpmname, goaltipaths in pairs(indexedgoipaths("%{goaltipaths" .. suffix .. "}",

+                                                       "%{goaltcid"    .. suffix .. "}")) do

+       altenv(suffix, rpmname, goaltipaths, verbose)

+       print(rpm.expand('%__goaltpkg\n'))

+     end

+   else

+     rpm.expand("%{error:Unknown kind of Go subpackage: " .. kind .. "}")

+   end

+ end

+ 

+ -- Create one or all %package sections for a known kind of go subpackage

+ local function pkg(kind, suffix, processall, verbose)

+   local fedora = require "fedora.common"

+   if (kind == "devel") then

+     develenvinit()

+   end

+   if processall then

+     for _, suffix in pairs(fedora.getsuffixes(pivot[kind])) do

+        singlepkg(kind, suffix, verbose)

+     end

+   else

+     singlepkg(kind, suffix, verbose)

+   end

+ end

+ 

+ -- Create a single %files section for a known kind of Go subpackage

+ local function singlefiles(kind, suffix, verbose)

+   if     (kind == "devel")  then

+     develenv(suffix, verbose)

+     print(rpm.expand('%files -n %{currentgodevelname}    -f "%{goworkdir}/%{currentgodevelfilelist}"\n'))

+   elseif (kind == "alt") then

+     local fedora = require "fedora.common"

+     local ismain = (suffix == "") or (suffix == "0")

+     if ismain then

+       fedora.zalias({"goaltipaths","gocid","goaltcid"},                verbose)

+     end

+     fedora.safeset("goaltcid" .. suffix, "%{?gocid"  .. suffix .. "}", verbose)

+     if ismain then

+       fedora.zalias({"goaltcid"},                                      verbose)

+     end

+     for rpmname, goaltipaths in pairs(indexedgoipaths("%{goaltipaths" .. suffix .. "}",

+                                                       "%{goaltcid"    .. suffix .. "}")) do

+       altenv(suffix, rpmname, goaltipaths, verbose)

+       print(rpm.expand('%files -n %{currentgoaltname} -f "%{goworkdir}/%{currentgoaltfilelist}"\n'))

+     end

+   else

+     rpm.expand("%{error:Unknown kind of Go subpackage: " .. kind .. "}")

+   end

+ end

+ 

+ -- Create one or all %files sections for a known kind of go subpackage

+ local function files(kind, suffix, processall, verbose)

+   local fedora = require "fedora.common"

+   if (kind == "devel") then

+     develenvinit()

+   end

+   if processall then

+     for _, suffix in pairs(fedora.getsuffixes(pivot[kind])) do

+        singlefiles(kind, suffix, verbose)

+     end

+   else

+     singlefiles(kind, suffix, verbose)

+   end

+ end

+ 

  return {

-   rpmname = rpmname,

-   meta    = meta,

+   rpmname         = rpmname,

+   meta            = meta,

+   pivot           = pivot,

+   indexedgoipaths = indexedgoipaths,

+   develenvinit    = develenvinit,

+   develenv        = develenv,

+   altenv          = altenv,

+   pkg             = pkg,

+   files           = files,

  }

@@ -56,41 +56,6 @@ 

  # The default filelist name generated by %goinstall

  %gofilelist devel.file-list

  

- # Create %package sections for every known kind of go subpackage. Arguments:

- # -v                  be verbose

- %gopkg(av) %{expand:

- %godevelpkg -a %{-v}

- %goaltpkg   -a %{-v}

- }

- 

- # Create a %package section for a golang-*-devel subpackage. Arguments:

- # -z <number>         read the zth block of definitions, for example

- #                     %{goipaths<number>}

- # -a                  process all blocks in one go, instead of using separate

- #                     -z calls

- # -v                  be verbose

- %godevelpkg(z:av) %{lua:

- local         go =  require "fedora.rpm.go"

- local     suffix =  rpm.expand("%{-z*}")

- local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "")

- local    verbose = (rpm.expand("%{-v}") ~= "")

- go.pkg("devel", suffix, processall, verbose)

- }

- 

- # Create a %package section for a compat-golang-*-devel subpackage. Arguments:

- # -z <number>         read the zth block of definitions, for example

- #                     %{goaltipaths<number>}

- # -a                  process all blocks in one go, instead of using separate

- #                     -z calls

- # -v                  be verbose

- %goaltpkg(z:av) %{lua:

- local         go =  require "fedora.rpm.go"

- local     suffix =  rpm.expand("%{-z*}")

- local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "")

- local    verbose = (rpm.expand("%{-v}") ~= "")

- go.pkg("alt", suffix, processall, verbose)

- }

- 

  # Sets environment variables suitable for a Go source archive. Optional arguments:

  # -z <number>         read the zth block of definitions, for example

  #                     %{goipath<number>}, %{commit<number>}…

@@ -348,7 +313,6 @@ 

  go.install("alt", suffix, processall, verbose)

  }

  

- 

  # Run go test with Fedora flags on all subdirectories except for those filtered out

  # THIS MACRO IS OPT-OUT.

  #

@@ -407,39 +371,3 @@ 

    process(rpm.expand("%{-z*}"))

  end

  }

- 

- 

- # Create %files sections for every known kind of Go subpackage. Arguments:

- # -v                  be verbose

- %gopkgfiles(av) %{expand:

- %godevelfiles -a %{-v}

- %goaltfiles   -a %{-v}

- }

- 

- # Create a %files section for a golang-*-devel subpackage. Arguments:

- # -z <number>         read the zth block of definitions, for example

- #                     %{goipaths<number>}

- # -a                  process all blocks in one go, instead of using separate

- #                     -z calls

- # -v                  be verbose

- %godevelfiles(z:av) %{lua:

- local         go =  require "fedora.rpm.go"

- local     suffix =  rpm.expand("%{-z*}")

- local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "")

- local    verbose = (rpm.expand("%{-v}") ~= "")

- go.files("devel", suffix, processall, verbose)

- }

- 

- # Create a %files section for a compat-golang-*-devel subpackage. Arguments:

- # -z <number>         read the zth block of definitions, for example

- #                     %{goaltipaths<number>}

- # -a                  process all blocks in one go, instead of using separate

- #                     -z calls

- # -v                  be verbose

- %goaltfiles(z:av) %{lua:

- local         go =  require "fedora.rpm.go"

- local     suffix =  rpm.expand("%{-z*}")

- local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "")

- local    verbose = (rpm.expand("%{-v}") ~= "")

- go.files("alt", suffix, processall, verbose)

- }

@@ -18,30 +18,6 @@ 

  # Internal utility macros

  # Direct use in spec file is not supported

  

- %__godevelpkg() %{expand:

- %package     -n %{currentgodevelname}

- Summary:        %{currentgodevelsummary}

- BuildRequires:  go-rpm-macros

- BuildArch:      noarch

- %{?currentgodevelheader}

- %description -n %{currentgodevelname}

- %(%reformatdescriptiontext << EOF_DESCR

- %{?currentgodeveldescription}

- EOF_DESCR)

- }

- 

- %__goaltpkg() %{expand:

- %package     -n %{currentgoaltname}

- Summary:        %{currentgoaltsummary}

- BuildRequires:  go-rpm-macros

- BuildArch:      noarch

- %{?currentgoaltheader}

- %description -n %{currentgoaltname}

- %(%reformatdescriptiontext << EOF_DESCR

- %{?currentgoaltdescription}

- EOF_DESCR)

- }

- 

  %__godevelinstall(-i:v) %{expand:

  (

  %define __godevelinstall_ipath %{-i*}

@@ -119,3 +119,73 @@ 

    go.meta(rpm.expand("%{-z*}"),verbose,informative,silent)

  end

  }

+ 

+ # Create %package sections for every known kind of go subpackage. Arguments:

+ # -v                  be verbose

+ %gopkg(av) %{expand:

+ %godevelpkg -a %{-v}

+ %goaltpkg   -a %{-v}

+ }

+ 

+ # Create a %package section for a golang-*-devel subpackage. Arguments:

+ # -z <number>         read the zth block of definitions, for example

+ #                     %{goipaths<number>}

+ # -a                  process all blocks in one go, instead of using separate

+ #                     -z calls

+ # -v                  be verbose

+ %godevelpkg(z:av) %{lua:

+ local         go =  require "fedora.srpm.go"

+ local     suffix =  rpm.expand("%{-z*}")

+ local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "")

+ local    verbose = (rpm.expand("%{-v}") ~= "")

+ go.pkg("devel", suffix, processall, verbose)

+ }

+ 

+ # Create a %package section for a compat-golang-*-devel subpackage. Arguments:

+ # -z <number>         read the zth block of definitions, for example

+ #                     %{goaltipaths<number>}

+ # -a                  process all blocks in one go, instead of using separate

+ #                     -z calls

+ # -v                  be verbose

+ %goaltpkg(z:av) %{lua:

+ local         go =  require "fedora.srpm.go"

+ local     suffix =  rpm.expand("%{-z*}")

+ local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "")

+ local    verbose = (rpm.expand("%{-v}") ~= "")

+ go.pkg("alt", suffix, processall, verbose)

+ }

+ 

+ # Create %files sections for every known kind of Go subpackage. Arguments:

+ # -v                  be verbose

+ %gopkgfiles(av) %{expand:

+ %godevelfiles -a %{-v}

+ %goaltfiles   -a %{-v}

+ }

+ 

+ # Create a %files section for a golang-*-devel subpackage. Arguments:

+ # -z <number>         read the zth block of definitions, for example

+ #                     %{goipaths<number>}

+ # -a                  process all blocks in one go, instead of using separate

+ #                     -z calls

+ # -v                  be verbose

+ %godevelfiles(z:av) %{lua:

+ local         go =  require "fedora.srpm.go"

+ local     suffix =  rpm.expand("%{-z*}")

+ local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "")

+ local    verbose = (rpm.expand("%{-v}") ~= "")

+ go.files("devel", suffix, processall, verbose)

+ }

+ 

+ # Create a %files section for a compat-golang-*-devel subpackage. Arguments:

+ # -z <number>         read the zth block of definitions, for example

+ #                     %{goaltipaths<number>}

+ # -a                  process all blocks in one go, instead of using separate

+ #                     -z calls

+ # -v                  be verbose

+ %goaltfiles(z:av) %{lua:

+ local         go =  require "fedora.srpm.go"

+ local     suffix =  rpm.expand("%{-z*}")

+ local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "")

+ local    verbose = (rpm.expand("%{-v}") ~= "")

+ go.files("alt", suffix, processall, verbose)

+ }

@@ -0,0 +1,43 @@ 

+ # Copyright © 2018 Nicolas Mailhot <nim@fedoraproject.org>

+ #

+ # This program is free software: you can redistribute it and/or modify

+ # it under the terms of the GNU General Public License as published by

+ # the Free Software Foundation, either version 3 of the License, or

+ # (at your option) any later version.

+ #

+ # This program is distributed in the hope that it will be useful,

+ # but WITHOUT ANY WARRANTY; without even the implied warranty of

+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ # GNU General Public License for more details.

+ #

+ # You should have received a copy of the GNU General Public License

+ # along with this program.  If not, see <https://www.gnu.org/licenses/>.

+ 

+ # SRPM macros for Go packages.

+ #

+ # Internal utility macros

+ # Direct use in spec file is not supported

+ 

+ %__godevelpkg() %{expand:

+ %package     -n %{currentgodevelname}

+ Summary:        %{currentgodevelsummary}

+ BuildRequires:  go-rpm-macros

+ BuildArch:      noarch

+ %{?currentgodevelheader}

+ %description -n %{currentgodevelname}

+ %(%reformatdescriptiontext << EOF_DESCR

+ %{?currentgodeveldescription}

+ EOF_DESCR)

+ }

+ 

+ %__goaltpkg() %{expand:

+ %package     -n %{currentgoaltname}

+ Summary:        %{currentgoaltsummary}

+ BuildRequires:  go-rpm-macros

+ BuildArch:      noarch

+ %{?currentgoaltheader}

+ %description -n %{currentgoaltname}

+ %(%reformatdescriptiontext << EOF_DESCR

+ %{?currentgoaltdescription}

+ EOF_DESCR)

+ }