Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: add using: attribute to head & stable URLs #16102

Merged
merged 1 commit into from Oct 12, 2023

Conversation

EricFromCanada
Copy link
Member

@EricFromCanada EricFromCanada commented Oct 11, 2023

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Some formulae rely on the using: attribute to indicate how a resource is to be downloaded if it can't be detected via the domain name or protocol, e.g.:

  • libvorbis's stable URL has using: :homebrew_curl as it's hosted on a TLS-1.3-only server
  • trino's stable URL has using: :nounzip to allow for manual hard-link-preserving decompression
  • the head URLs for abcl, global, nginx, objfw, squid each have a using attribute to indicate the VCS needed to fetch their sources

This change allows from-source installations of these and similar formulae to work when using the API.

Current output:

$ brew info --json pytouhou | jq .[0].urls
{
  "stable": {
    "url": "https://hg.linkmauve.fr/touhou",
    "tag": null,
    "revision": "5270c34b4c00",
    "checksum": null
  },
  "head": {
    "url": "https://hg.linkmauve.fr/touhou",
    "branch": null
  }
}

$ brew fetch --HEAD blastem
==> Downloading https://www.retrodev.com/repos/blastem
##################################################################################################################################################################### 100.0%
Downloaded to: /Users/eric/Library/Caches/Homebrew/downloads/ae00afc1c31ad2cdd9ef6e4ea0876edc8206c3c47c11a628a8593d838242aca5--blastem
SHA256: 72b87d3a585b96e977f9f29cf6fcd9dcee0e9026fc3c69d0b9fdb16b35e679e9
# this just downloads a web page

Future:

$ HOMEBREW_NO_INSTALL_FROM_API=1 brew info --json pytouhou | jq .[0].urls
{
  "stable": {
    "url": "https://hg.linkmauve.fr/touhou",
    "tag": null,
    "revision": "5270c34b4c00",
    "checksum": null,
    "using": "hg"
  },
  "head": {
    "url": "https://hg.linkmauve.fr/touhou",
    "branch": null,
    "using": "hg"
  }
}

$ HOMEBREW_NO_INSTALL_FROM_API=1 brew fetch --HEAD blastem
==> Cloning https://www.retrodev.com/repos/blastem
requesting all changes
adding changesets
adding manifests
adding file changes
added 2346 changesets with 5011 changes to 324 files (+1 heads)
new changesets 2432d177e1ac:c76c81c21ae5
updating to branch default
300 files updated, 0 files merged, 0 files removed, 0 files unresolved
Resource: vasm
==> Downloading http://phoenix.owl.de/tags/vasm1_8i.tar.gz
##################################################################################################################################################################### 100.0%
Downloaded to: /Users/eric/Library/Caches/Homebrew/downloads/4f31e8fb49321255218db07092e8864e9e036e14c2c563c1add9ea1201164d99--vasm1_8i.tar.gz
SHA256: 9ae0b37bca11cae5cf00e4d47e7225737bdaec4028e4db2a501b4eca7df8639d
==> Downloading https://www.retrodev.com/repos/blastem/raw-rev/dbbf0100f249
##################################################################################################################################################################### 100.0%
Downloaded to: /Users/eric/Library/Caches/Homebrew/downloads/70a17ee109695d03f5ece64dd949f1b08371b9e3592a96d1738aac5868fba8c3--dbbf0100f249
SHA256: e332764bfa08e08e0f9cbbebefe73b88adb99a1e96a77a16a0aeeae827ac72ff

@EricFromCanada EricFromCanada added the install from api Relates to API installs label Oct 11, 2023
@MikeMcQuaid MikeMcQuaid requested a review from Bo98 October 11, 2023 14:50
@Bo98
Copy link
Member

Bo98 commented Oct 11, 2023

Will need adding here too:

url_spec = { tag: urls_stable["tag"], revision: urls_stable["revision"] }.compact

plus the equivalent a few lines down for head

@@ -2281,6 +2281,7 @@ def to_hash
"url" => stable_spec.url,
"tag" => stable_spec.specs[:tag],
"revision" => stable_spec.specs[:revision],
"using" => stable_spec.using,
Copy link
Member

@Bo98 Bo98 Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using can be a Class and we're probably not going to ever support that, nor do we need to for Homebrew/core.

Suggested change
"using" => stable_spec.using,
"using" => (stable_spec.using if stable_spec.using.is_a?(Symbol)),

(+ same change to head)

url_spec = {
tag: urls_stable["tag"],
revision: urls_stable["revision"],
using: urls_stable["using"],
Copy link
Member

@Bo98 Bo98 Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using: urls_stable["using"],
using: urls_stable["using"]&.to_sym,

(+ same change to head)

@EricFromCanada EricFromCanada merged commit eacf8d9 into Homebrew:master Oct 12, 2023
27 checks passed
@EricFromCanada EricFromCanada deleted the api-urls-using branch October 12, 2023 01:57
@MikeMcQuaid
Copy link
Member

Thanks @EricFromCanada!

@github-actions github-actions bot added the outdated PR was locked due to age label Nov 12, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
install from api Relates to API installs outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants