#209 forge macros: Support Sourcehut. Fixes rhbz#2035935.
Merged 2 years ago by tibbs. Opened 2 years ago by gotmax23.
rpms/ gotmax23/redhat-rpm-config srht  into  rawhide

file modified
+21 -2
@@ -42,7 +42,10 @@ 

        description = 'https://code.googlesource.com/…/repo'},

      ["bitbucket.org"] = {

        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

      checkedurl = string.match(url,urlpatterns[id]["pattern"])

      if (checkedurl == nil) then
@@ -81,6 +84,8 @@ 

          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"

        end

        forgeurl, forge = checkforgeurl(url, forge, silent)

      end
@@ -150,7 +155,12 @@ 

        shortcommit = '%{lua:print(string.sub(rpm.expand("%{commit'     .. suffix .. '}"), 1, 12))}',

        owner       = '%{lua:print(string.match(rpm.expand("%{forgeurl' .. 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

    -- will treat branches and tags the same way better support branches explicitly

    -- than have packagers hijack %{tag} to download branch states
@@ -212,6 +222,15 @@ 

        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)

      end

      fedora.safeset("ref" .. suffix, ref, verbose)

      -- Mass setting of the remaining variables

file modified
+4 -1
@@ -4,7 +4,7 @@ 

  # 2) When making changes, increment the version (in baserelease) by 1.

  #    rpmdev-bumpspec and other tools update the macro below, which is used

  #    in Version: to get the desired effect.

- %global baserelease 230

+ %global baserelease 231

  

  Summary: Red Hat specific rpm configuration files

  Name: redhat-rpm-config
@@ -221,6 +221,9 @@ 

  %doc buildflags.md

  

  %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

  - Add support for runstatedir in %%configure

  

no initial comment

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

Friendly ping. @ignatenkobrain, perhaps you want to review this, as you were the last person to commit to the forge macros.

I am afraid nobody is comfortable touching the forge macros.

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging src.fedoraproject.org/rpms/redhat-rpm-config for 209,73dd61ec165d653fde9fb6fe2f8ca3b6e9cc266b

I am afraid nobody is comfortable touching the forge macros.

Well, I've touched it, and I'd appreciate if someone merged it. This PR simply adds support for Sourcehut, which will make it much easier to package go (and other) projects hosted there. There is no major re-architecting or other breaking changes. Currently, the go macros are kind of tied up in the forge macros, and it's difficult to maintain the go macros if it's impossible to make changes to the forge macros. It is not too difficult to side step the part that relies on %forgesource for individual packages, but I'd prefer not to have to do that.

rebased onto 3c98ea306f7ed2ff29cdde57dd1b14e1c33d0cad

2 years ago

Build succeeded.

Should we move the forge macros into a separate package if nobody here wants to maintain them?

I think that would be the best thing to do.

Regarding moving this stuff out of redhat-rpm-config:

I tried to do this before with fedora-rpm-macros to hold various things including some of the lua infrastructure stuff which eventually got pulled in with these macros. But I got flamed hard enough that I dropped the idea. I'm all for splitting these macros out now that it seems like there's support. All of these tiny macro packages have the same chance of breaking the entire distro as redhat-rpm-config goes, so it's all about ease of maintenance.

Regarding the actual change:

I went over it and it all seems to me, though I haven't done anything other than basic testing. I would just do the merge now if it were mergeable and if the issue of splitting it out was resolved.

rebased onto b16517c

2 years ago

I went over it and it all seems to me, though I haven't done anything other than basic testing. I would just do the merge now if it were mergeable and if the issue of splitting it out was resolved.

I've rebased. Thank you for looking at it!

Build succeeded.

Pull-Request has been merged by tibbs

2 years ago

I've merged, but then committed a fixup for the invalid date format in the changelog entry. Building at https://koji.fedoraproject.org/koji/taskinfo?taskID=91798878

Regarding moving this stuff out of redhat-rpm-config:

I tried to do this before with fedora-rpm-macros to hold various things including some of the lua infrastructure stuff which eventually got pulled in with these macros. But I got flamed hard enough that I dropped the idea. I'm all for splitting these macros out now that it seems like there's support. All of these tiny macro packages have the same chance of breaking the entire distro as redhat-rpm-config goes, so it's all about ease of maintenance.

I remember the case, although I don't remember the details. I do remember that it felt to us (rpm maintainers) like an attempt to covertly side-step the review that goes into redhat-rpm-config changes. Whether it actually was one, I doubt it. Probably the problem was simply just not discussing it first, because at the time we were already actively looking to split off "SIG" content to separate packages back then.

The maintenance situation of redhat-rpm-config has since changed a lot, for the better I must stress, with FPC taking over. But FWIW my blessings and support for splitting the forge stuff into a separate package. It would be a relief on the RHEL side.

Metadata