redhat-rpm-config/forge.lua

332 lines
16 KiB
Lua
Raw Normal View History

forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
-- Lua code used by macros.forge and derivatives
-- Computes the suffix of a version string, removing vprefix if it matches
-- For example with vprefix 1.2.3: 1.2.3.rc2 → .rc2 but 1.2.30 → 1.2.30 not 0
local function getversionsuffix(vstring,vprefix)
if (string.sub(vstring, 1, #vprefix) == vprefix) and
(not string.match(string.sub(vstring, #vprefix + 1), "^%.?%d")) then
return string.sub(vstring, #vprefix + 1)
else
return vstring
end
end
-- Check if an identified url is sane
local function checkforgeurl(url, id, silent)
local checkedurl = nil
local checkedid = nil
local urlpatterns = {
gitlab = {
pattern = 'https://[^/]+/[^/]+/[^/#?]+',
description = 'https://(…[-.])gitlab[-.]…/owner/repo'},
2019-04-10 21:05:46 +00:00
pagure = {
pattern = 'https://[^/]+/[^/#?]+',
description = 'https://pagure.io/repo'},
pagure_ns = {
pattern = 'https://[^/]+/[^/]+/[^/#?]+',
description = 'https://pagure.io/namespace/repo'},
pagure_fork = {
pattern = 'https://[^/]+/fork/[^/]+/[^/#?]+',
description = 'https://pagure.io/fork/owner/repo'},
pagure_ns_fork = {
pattern = 'https://[^/]+/fork/[^/]+/[^/]+/[^/#?]+',
description = 'https://pagure.io/fork/owner/namespace/repo'},
["gitea.com"] = {
pattern = 'https://[^/]+/[^/]+/[^/#?]+',
description = 'https://gitea.com/owner/repo'},
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
github = {
pattern = 'https://[^/]+/[^/]+/[^/#?]+',
description = 'https://(…[-.])github[-.]…/owner/repo'},
["code.googlesource.com"] = {
pattern = 'https://code.googlesource.com/[^#?]*[^/#?]+',
description = 'https://code.googlesource.com/…/repo'},
["bitbucket.org"] = {
pattern = 'https://[^/]+/[^/]+/[^/#?]+',
description = 'https://bitbucket.org/owner/repo'},
sourcehut = {
pattern = 'https://[^/]+/~[^/]+/[^/#?]+',
description = 'https://git.sr.ht/~owner/repo'}}
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
if (urlpatterns[id] ~= nil) then
checkedurl = string.match(url,urlpatterns[id]["pattern"])
if (checkedurl == nil) then
if not silent then
rpm.expand("%{error:" .. id .. " URLs must match " .. urlpatterns[id]["description"] .. " !}")
end
else
checkedid = id
end
end
return checkedurl, checkedid
end
-- Check if an url matches a known forge
local function idforge(url, silent)
local forgeurl = nil
local forge = nil
if (url ~= "") then
forge = string.match(url, "^[^:]+://([^/]+)/")
if (forge == nil) then
if not silent then
rpm.expand("%{error:URLs must include a protocol such as https:// and a path starting with / !}")
end
else
2019-04-10 21:05:46 +00:00
if (forge == "pagure.io") then
if string.match(url, "[^:]+://pagure.io/fork/[^/]+/[^/]+/[^/]+") then
forge = "pagure_ns_fork"
elseif string.match(url, "[^:]+://pagure.io/fork/[^/]+/[^/]+") then
forge = "pagure_fork"
elseif string.match(url, "[^:]+://pagure.io/[^/]+/[^/]+") then
forge = "pagure_ns"
elseif string.match(url, "[^:]+://pagure.io/[^/]+") then
forge = "pagure"
end
elseif (string.match(forge, "^gitlab[%.-]") or string.match(forge, "[%.-]gitlab[%.]")) then
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
forge = "gitlab"
elseif (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then
forge = "github"
elseif string.match(url, "[^:]+://git.sr.ht/") then
forge = "sourcehut"
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
end
forgeurl, forge = checkforgeurl(url, forge, silent)
end
end
return forgeurl, forge
end
-- The forgemeta macro main processing function
-- See the documentation in the macros.forge file for argument description
-- Also called directly by gometa
2018-11-08 18:18:36 +00:00
local function meta(suffix, verbose, informative, silent)
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
local fedora = require "fedora.common"
local ismain = (suffix == "") or (suffix == "0")
if ismain then
fedora.zalias({"forgeurl", "forgesource", "forgesetupargs",
"archivename", "archiveext", "archiveurl",
2019-04-10 21:05:46 +00:00
"topdir", "extractdir", "repo", "owner", "namespace",
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
"scm", "tag", "commit", "shortcommit", "branch", "version",
"date", "distprefix"}, verbose)
end
local variables = {
default = {
scm = "git",
archiveext = "tar.bz2",
2019-04-10 21:05:46 +00:00
repo = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "^[^:]+://[^/]+/[^/]+/([^/?#]+)"))}',
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
archivename = "%{repo" .. suffix .. "}-%{ref" .. suffix .. "}",
topdir = "%{archivename" .. suffix .. "}" },
gitlab = {
archiveurl = "%{forgeurl" .. suffix .. "}/-/archive/%{ref" .. suffix .. "}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "}" },
2019-04-10 21:05:46 +00:00
pagure = {
archiveext = "tar.gz",
repo = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "^[^:]+://[^/]+/([^/?#]+)"))}',
archiveurl = "%{forgeurl" .. suffix .. "}/archive/%{ref" .. suffix .. "}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "}" },
pagure_ns = {
archiveext = "tar.gz",
namespace = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "^[^:]+://[^/]+/([^/]+)/[^/?#]+"))}',
repo = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "^[^:]+://[^/]+/[^/]+/([^/?#]+)"))}',
archivename = "%{namespace" .. suffix .. "}-%{repo" .. suffix .. "}-%{ref" .. suffix .. "}",
archiveurl = "%{forgeurl" .. suffix .. "}/archive/%{ref" .. suffix .. "}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "}" },
pagure_fork = {
archiveext = "tar.gz",
owner = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "https://[^/]+/fork/([^/]+)/[^/?#]+"))}',
repo = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "https://[^/]+/fork/[^/]+/([^/?#]+)"))}',
archivename = "%{owner" .. suffix .. "}-%{repo" .. suffix .. "}-%{ref" .. suffix .. "}",
archiveurl = "%{forgeurl" .. suffix .. "}/archive/%{ref" .. suffix .. "}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "}" },
pagure_ns_fork = {
owner = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "https://[^/]+/fork/([^/]+)/[^/]+/[^/?#]+"))}',
namespace = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "https://[^/]+/fork/[^/]+/([^/]+)/[^/?#]+")}',
repo = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "https://[^/]+/fork/[^/]+/[^/]+/([^/?#]+)")}',
archivename = "%{owner" .. suffix .. "}-%{namespace" .. suffix .. "}-%{repo" .. suffix .. "}-%{ref" .. suffix .. "}",
archiveurl = "%{forgeurl" .. suffix .. "}/archive/%{ref" .. suffix .. "}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "}" },
["gitea.com"] = {
archiveext = "tar.gz",
archivename = "%{fileref" .. suffix .. "}",
archiveurl = "%{forgeurl" .. suffix .. "}/archive/%{ref" .. suffix .. "}.%{archiveext" .. suffix .. "}",
topdir = "%{repo}" },
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
github = {
archiveext = "tar.gz",
archivename = "%{repo" .. suffix .. "}-%{fileref" .. suffix .. "}",
archiveurl = "%{forgeurl" .. suffix .. "}/archive/%{ref" .. suffix .. "}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "}" },
["code.googlesource.com"] = {
archiveext = "tar.gz",
repo = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "^[^:]+://.+/([^/?#]+)"))}',
archiveurl = "%{forgeurl" .. suffix .. "}/+archive/%{ref" .. suffix .. "}.%{archiveext" .. suffix .. "}",
topdir = "" },
["bitbucket.org"] = {
shortcommit = '%{lua:print(string.sub(rpm.expand("%{commit' .. suffix .. '}"), 1, 12))}',
2019-04-10 21:05:46 +00:00
owner = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "^[^:]+://[^/]+/([^/?#]+)"))}',
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
archivename = "%{owner" .. suffix .. "}-%{repo" .. suffix .. "}-%{shortcommit" .. suffix .. "}",
archiveurl = "%{forgeurl" .. suffix .. "}/get/%{ref" .. suffix .. "}.%{archiveext" .. suffix .. "}" },
sourcehut = {
archiveext = "tar.gz",
archivename = "%{repo" .. suffix .. "}-%{fileref" .. suffix .. "}",
archiveurl = "%{forgeurl" .. suffix .. "}/archive/%{ref" .. suffix .. "}.%{archiveext" .. suffix .. "}",
topdir = "%{repo" .. suffix .. "}-%{ref" .. suffix .. "}" } }
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
-- Packaging a moving branch is quite a bad idea, but since at least Gitlab
-- will treat branches and tags the same way better support branches explicitly
-- than have packagers hijack %{tag} to download branch states
local spec = {}
for _, v in ipairs({'forgeurl','tag','commit','branch','version'}) do
spec[v] = rpm.expand("%{?" .. v .. suffix .. "}")
end
-- Compute the reference of the object to fetch
local isrelease = false
if (spec["tag"] ~= "") then ref = "%{?tag" .. suffix .. "}"
elseif (spec["commit"] ~= "") then ref = "%{?commit" .. suffix .. "}"
elseif (spec["branch"] ~= "") then ref = "%{?branch" .. suffix .. "}"
else ref = "%{?version" .. suffix .. "}"
isrelease = true
end
if (rpm.expand(ref) == "") then
if (suffix == "") then
rpm.expand("%{error:You need to define Version:, %{commit} or %{tag} before the macro invocation !}")
else
rpm.expand("%{error:You need to define %{version" .. suffix .. "}, %{commit" .. suffix .. "} or %{tag" .. suffix .. "} before the macro invocation !}")
end
end
local forgeurl = spec["forgeurl"]
-- For backwards compatibility only
local expliciturl = rpm.expand("%{?-u*}")
if (expliciturl ~= "") then
rpm.expand("%{warn:-u use in %%forgemeta is deprecated, use -z instead to select a separate set of rpm variables!}")
forgeurl = expliciturl
end
local forge
forgeurl, forge = idforge(forgeurl, silent)
if (forge ~= nil) then
fedora.explicitset("forgeurl" .. suffix, forgeurl, verbose)
-- Custom processing of quirky forges that can not be handled with simple variables
if (forge == "github") then
-- Workaround the way GitHub injects "v"s before some version strings (but not all!)
-- To package one of the minority of sane GitHub projects that do not munge their version
-- strings set tag to %{version} in your spec
local fileref = ref
if (ref == "%{?version" .. suffix .. "}") then
ref = "v" .. ref
elseif (fileref ~= "%{?commit" .. suffix .. "}") and
string.match(rpm.expand(fileref), "^v[%d]") then
fileref = string.gsub(rpm.expand(fileref), "^v", "")
elseif (string.match(rpm.expand(fileref), "/")) then
fileref = string.gsub(rpm.expand(fileref), "/", "-")
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
end
fedora.safeset("fileref" .. suffix, fileref, verbose)
elseif (forge == "gitea.com") then
-- Workaround the way gitea mangles /s in ref names
local fileref = ref
fileref = string.gsub(rpm.expand(fileref), "/", "-")
fedora.safeset("fileref" .. suffix, fileref, verbose)
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
elseif (forge == "code.googlesource.com") then
if (ref == "%{?version" .. suffix .. "}") then
ref = "v" .. ref
end
elseif (forge == "bitbucket.org") then
if (spec["commit"] == "") then
rpm.expand("%{error:All BitBucket URLs require commit value knowledge: you need to define %{commit}!}")
end
elseif (forge == "sourcehut") then
local fileref = ref
if (fileref ~= "%{?commit" .. suffix .. "}") and
string.match(rpm.expand(fileref), "^v[%d]") then
fileref = string.gsub(rpm.expand(fileref), "^v", "")
elseif (string.match(rpm.expand(fileref), "/")) then
fileref = string.gsub(rpm.expand(fileref), "/", "-")
end
fedora.safeset("fileref" .. suffix, fileref, verbose)
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
end
fedora.safeset("ref" .. suffix, ref, verbose)
-- Mass setting of the remaining variables
for k,v in pairs(variables[forge]) do
fedora.safeset(k .. suffix, variables[forge][k], verbose)
end
for k,v in pairs(variables["default"]) do
if (variables[forge][k] == nil) then
fedora.safeset(k .. suffix, variables["default"][k], verbose)
end
end
end
-- Generic rules
for _, v in ipairs({'archiveurl','archivename','archiveext','topdir'}) do
spec[v] = rpm.expand("%{?" .. v .. suffix .. "}")
end
-- Source URL processing (computing the forgesource spec variable)
local forgesource = "%{archiveurl" .. suffix .. "}"
if (string.match(spec["archiveurl"], "/([^/]+)$") ~= spec["archivename"] .. "." .. spec["archiveext"]) then
forgesource = "%{?archiveurl" .. suffix .. "}#/%{?archivename" .. suffix .. "}.%{archiveext" .. suffix .. "}"
end
fedora.safeset("forgesource" .. suffix, forgesource, verbose)
-- Setup processing (computing the forgesetup and extractdir variables)
local forgesetupargs = "-n %{extractdir" .. suffix .. "}"
local extractdir = "%{topdir" .. suffix .. "}"
if (spec["topdir"] == "") then
forgesetupargs = "-c " .. forgesetupargs
extractdir = "%{archivename" .. suffix .. "}"
end
if not ismain then
if (spec["topdir"] ~= "") then
forgesetupargs = "-T -D -b " .. suffix .. " " .. forgesetupargs
else
forgesetupargs = "-T -D -a " .. suffix .. " " .. forgesetupargs
end
end
fedora.safeset("forgesetupargs" .. suffix, forgesetupargs, verbose)
fedora.safeset("extractdir" .. suffix, extractdir, verbose)
-- dist processing (computing the correct prefix for snapshots)
local distprefix = ""
if not isrelease then
distprefix = string.lower(rpm.expand(ref))
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
if (ref == "%{?commit" .. suffix .. "}") then
distprefix = string.sub(distprefix, 1, 7)
elseif (ref ~= "%{?branch" .. suffix .. "}") then
distprefix = string.gsub(distprefix, "[%p%s]+", ".")
distprefix = string.gsub(distprefix, "^" .. string.lower(rpm.expand("%{?repo}")) .. "%.?", "")
local v = string.gsub(rpm.expand("%{version}"), "[%p%s]+", ".")
for _, p in ipairs({'','v','v.','version','version.','tags.v', 'tags.v.'}) do
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
distprefix = getversionsuffix(distprefix, p .. v)
end
distprefix = string.gsub(distprefix, "^%.", "")
end
if (distprefix ~= "") then
distprefix = "%{scm" .. suffix .. "}" .. distprefix
date = rpm.expand("%{?date" .. suffix .. "}")
if (date ~= "") then
distprefix = date .. distprefix
else
distprefix = "%([ -r %{_sourcedir}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "} ] && date +%Y%m%d -u -r %{_sourcedir}/%{archivename" .. suffix .. "}.%{archiveext" .. suffix .. "})" .. distprefix
end
distprefix = "." .. distprefix
end
end
if (spec["version"] ~= "") and
(spec["version"] ~= "0") and
(spec["version"] ~= rpm.expand("%{?version}")) then
distprefix = ".%{version" .. suffix .. "}" .. distprefix
end
if (rpm.expand(distprefix) ~= "") then
if not ismain then
distprefix = string.gsub(distprefix, "^%.", ".s")
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
end
fedora.safeset ("distprefix" .. suffix, distprefix, verbose)
end
if ismain then
fedora.zalias({"forgeurl", "forgesource", "forgesetupargs",
"archivename", "archiveext", "archiveurl",
2019-04-10 21:05:46 +00:00
"topdir", "extractdir", "repo", "owner", "namespace",
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
"scm", "shortcommit", "distprefix"}, verbose)
end
-- Final spec variable summary if the macro was called with -i
if informative then
rpm.expand("%{echo:Packaging variables read or set by %%forgemeta}")
fedora.echovars({"forgeurl", "forgesource", "forgesetupargs",
"archivename", "archiveext", "archiveurl",
2019-04-10 21:05:46 +00:00
"topdir", "extractdir", "repo", "owner", "namespace",
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
"scm", "tag", "commit", "shortcommit", "branch", "version",
"date", "distprefix"}, suffix)
fedora.echovars({"dist"},"")
rpm.expand("%{echo: (snapshot date is either manually supplied or computed once %%{_sourcedir}/%%{archivename" .. suffix .. "}.%%{archiveext" .. suffix .. "} is available)}")
end
end
return {
2018-11-08 18:18:36 +00:00
meta = meta,
forge: refactor to allow multiple calls – permit extraction of multiple archives in a single specfile – %forgemeta, %forgesetup, %forgeautosetup: add a “-z <number>” switch to select a specific set of rpm variables (for example forgeurl<number> and version<number>) – %forgemeta, %forgesetup: add a “-a” switch to process all sets in one go (makes no sense in forgeautosetup, as you need so select specific patches) – %forgemeta: deprecate the “-u” switch, use “-z” it’s better (“-u” was awkward and mainly used by the %gometa macro. %gometa will now call the lua code directly) – %forgesetup: use “-v” for verbose processing, be quiet by default, drop “-q” (align with %forgemeta, %forgeautosetup and %autosetup) – %forgesetup, %forgeautosetup: only pass flags that make sense to %setup/%autosetup; reorder to match what works in el7 – factor out complex or common lua code in separate lua modules, to allow: – code reuse in other macros without cut and pasting – direct lua routine invocation from other macros without going through a rpm macro – rpm syntax errors that point to a line in an actual lua file – %forgemeta: refactor the logic to drop as much forge-specific code as possible, use a single logic flow with tables of constants – %forgemeta: export more computed info in rpm variables, such as the %{_builddir} subdirectory an archive was extracted to (lifesaver when processing multiple archives) – %forgemeta: prepend secondary distprefixes with .S, to make clear they do not apply to the main archive – %forgemeta: add versionx to secondary distprefixes, if relevant – %forgemeta: make tar.bz2 the default archive format Caveats: – forge services implement full-release downloads via tags. However the actual syntax of such tags is not standardised. If the macro does not guess the correct tag an upstream uses for a specific release, you will need to set the tag value explicitly. – GitHub lets upstreams move their projects to new URLs, keeping the old URL active. It all works transparently *except* the top directory inside generated archives always matches the new project name (even when accessed by compatibility URLs, and even for releases that antedate the renaming). Therefore, if macro processing of a GitHub archive suddenly fails, start by checking if upstream didn’t rename itself. Multicall usage example (with “-a”) – to process a specific bloc in one of the macros use “-z <suffix>” – suffix 0 and no suffix are synonyms – therefore, calling the macros without “-a” or “-z” just works for the general use case when you have a single archive to process – caveat: forge services implement full-release %<-- %global forgeurl0 https://gitlab.com/osslugaru/lugaru Version: 1.2 %global forgeurl1 https://gitlab.com/osslugaru/lugaru %global tag1 1.1 %global forgeurl2 https://gitlab.com/osslugaru/lugaru %global commit2 68488b0a11df90dca703c67e5592b93c6a269957 %global forgeurl3 https://gitlab.com/osslugaru/lugaru %global branch3 v1.1 %global forgeurl4 https://github.com/google/trillian %global version4 1.0.8 %global forgeurl5 https://github.com/kubernetes/apiextensions-apiserver %global version5 1.9.6 %global tag5 kubernetes-%{version5} %global forgeurl6 https://github.com/jdbranham/grafana-diagram %global version6 1.3 %global commit6 440689793ab6da82019c5ee43b49438dfef976d5 %global forgeurl7 https://github.com/rethinkdb/rethinkdb-go %global version7 1.4.2 %global branch7 v1 %global forgeurl8 https://code.googlesource.com/gocloud %global version8 0.20.0 %global forgeurl9 https://code.googlesource.com/gocloud %global tag9 v0.27.0 %global forgeurl10 https://code.googlesource.com/google-api-go-client %global commit10 24928b980e6919be4c72647aacd53ebcbb8c4bab %global version10 0 %global forgeurl11 https://code.googlesource.com/google-api-go-client %global branch11 dartman %global forgeurl12 https://bitbucket.org/nielsenb/pdfocr %global version12 0.3.0 %global commit12 4f5750d202d33267094621630836f1215a5efa66 %global forgeurl13 https://bitbucket.org/nielsenb/pdfocr %global version13 0.1.4 %global tag13 v0.1.4 %global commit13 c0359843a3420769940e12019ebd68891a053bd8 %global forgeurl14 https://bitbucket.org/creachadair/shell %global commit14 3dcd505a7ca5845388111724cc2e094581e92cc6 %global forgeurl15 https://bitbucket.org/kirbyvisp/vdjpuzzle2/ %global branch15 js-edits %global commit15 36a3850eb4a04c05e0f7e29e7d0c196f373eb672 %forgemeta -ia Name: testing Release: 1%{?dist} Summary: A test package URL: %{forgeurl} License: Public domain Source0: %{forgesource0} Source1: %{forgesource1} Source2: %{forgesource2} Source3: %{forgesource3} Source4: %{forgesource4} Source5: %{forgesource5} Source6: %{forgesource6} Source7: %{forgesource7} Source8: %{forgesource8} Source9: %{forgesource9} Source10: %{forgesource10} Source11: %{forgesource11} Source12: %{forgesource12} Source13: %{forgesource13} Source14: %{forgesource14} Source15: %{forgesource15} %description A test package %prep %forgesetup -a %build exit 1 %install %files %doc %<-- Merges: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/35
2018-09-07 17:56:46 +00:00
}