forge macros: Support Sourcehut. Fixes rhbz#2035935.
This commit is contained in:
parent
c0d29236fe
commit
b16517ce77
23
forge.lua
23
forge.lua
@ -42,7 +42,10 @@ local function checkforgeurl(url, id, silent)
|
|||||||
description = 'https://code.googlesource.com/…/repo'},
|
description = 'https://code.googlesource.com/…/repo'},
|
||||||
["bitbucket.org"] = {
|
["bitbucket.org"] = {
|
||||||
pattern = 'https://[^/]+/[^/]+/[^/#?]+',
|
pattern = 'https://[^/]+/[^/]+/[^/#?]+',
|
||||||
description = 'https://bitbucket.org/owner/repo'}}
|
description = 'https://bitbucket.org/owner/repo'},
|
||||||
|
sourcehut = {
|
||||||
|
pattern = 'https://[^/]+/~[^/]+/[^/#?]+',
|
||||||
|
description = 'https://git.sr.ht/~owner/repo'}}
|
||||||
if (urlpatterns[id] ~= nil) then
|
if (urlpatterns[id] ~= nil) then
|
||||||
checkedurl = string.match(url,urlpatterns[id]["pattern"])
|
checkedurl = string.match(url,urlpatterns[id]["pattern"])
|
||||||
if (checkedurl == nil) then
|
if (checkedurl == nil) then
|
||||||
@ -81,6 +84,8 @@ local function idforge(url, silent)
|
|||||||
forge = "gitlab"
|
forge = "gitlab"
|
||||||
elseif (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then
|
elseif (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then
|
||||||
forge = "github"
|
forge = "github"
|
||||||
|
elseif string.match(url, "[^:]+://git.sr.ht/") then
|
||||||
|
forge = "sourcehut"
|
||||||
end
|
end
|
||||||
forgeurl, forge = checkforgeurl(url, forge, silent)
|
forgeurl, forge = checkforgeurl(url, forge, silent)
|
||||||
end
|
end
|
||||||
@ -150,7 +155,12 @@ local function meta(suffix, verbose, informative, silent)
|
|||||||
shortcommit = '%{lua:print(string.sub(rpm.expand("%{commit' .. suffix .. '}"), 1, 12))}',
|
shortcommit = '%{lua:print(string.sub(rpm.expand("%{commit' .. suffix .. '}"), 1, 12))}',
|
||||||
owner = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "^[^:]+://[^/]+/([^/?#]+)"))}',
|
owner = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. suffix .. '}"), "^[^:]+://[^/]+/([^/?#]+)"))}',
|
||||||
archivename = "%{owner" .. suffix .. "}-%{repo" .. suffix .. "}-%{shortcommit" .. suffix .. "}",
|
archivename = "%{owner" .. suffix .. "}-%{repo" .. suffix .. "}-%{shortcommit" .. suffix .. "}",
|
||||||
archiveurl = "%{forgeurl" .. suffix .. "}/get/%{ref" .. suffix .. "}.%{archiveext" .. 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 .. "}" } }
|
||||||
-- Packaging a moving branch is quite a bad idea, but since at least Gitlab
|
-- 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
|
-- will treat branches and tags the same way better support branches explicitly
|
||||||
-- than have packagers hijack %{tag} to download branch states
|
-- than have packagers hijack %{tag} to download branch states
|
||||||
@ -212,6 +222,15 @@ local function meta(suffix, verbose, informative, silent)
|
|||||||
if (spec["commit"] == "") then
|
if (spec["commit"] == "") then
|
||||||
rpm.expand("%{error:All BitBucket URLs require commit value knowledge: you need to define %{commit}!}")
|
rpm.expand("%{error:All BitBucket URLs require commit value knowledge: you need to define %{commit}!}")
|
||||||
end
|
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)
|
||||||
end
|
end
|
||||||
fedora.safeset("ref" .. suffix, ref, verbose)
|
fedora.safeset("ref" .. suffix, ref, verbose)
|
||||||
-- Mass setting of the remaining variables
|
-- Mass setting of the remaining variables
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# 2) When making changes, increment the version (in baserelease) by 1.
|
# 2) When making changes, increment the version (in baserelease) by 1.
|
||||||
# rpmdev-bumpspec and other tools update the macro below, which is used
|
# rpmdev-bumpspec and other tools update the macro below, which is used
|
||||||
# in Version: to get the desired effect.
|
# in Version: to get the desired effect.
|
||||||
%global baserelease 230
|
%global baserelease 231
|
||||||
|
|
||||||
Summary: Red Hat specific rpm configuration files
|
Summary: Red Hat specific rpm configuration files
|
||||||
Name: redhat-rpm-config
|
Name: redhat-rpm-config
|
||||||
@ -221,6 +221,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
|
|||||||
%doc buildflags.md
|
%doc buildflags.md
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu 08 Sep 2022 Maxwell G <gotmax@e.email> - 231-1
|
||||||
|
- forge macros: Support Sourcehut. Fixes rhbz#2035935.
|
||||||
|
|
||||||
* Tue Aug 30 2022 Frederic Berat <fberat@redhat.com> - 230-1
|
* Tue Aug 30 2022 Frederic Berat <fberat@redhat.com> - 230-1
|
||||||
- Add support for runstatedir in %%configure
|
- Add support for runstatedir in %%configure
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user