Skip to content

Load formulae from the internal API with HOMEBREW_USE_INTERNAL_API #20052

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Jun 5, 2025

This PR is an initial pass at updating how we load Formulae to use the slimmed-down internal API, and fetch the remaining metadata from the OCI image. This is still a work-in-progress, but I wanted to open to get feedback on the approach.


One thing I definitely want to hear thoughts on:

How should we go about adding the JSON data to the OCI manifest files? Once this PR is merged, newly created bottles will have the additional data. For now, I've simply added a fallback for "if this fails, use https://formulae.brew.sh/api/formula/wget.json", but I don't think we should be relying on this method long-term, since I imagine many formulae won't get rebottled anytime soon.

Is there a way to mass-update manifest files?

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

All makes sense to me so far, nice work!

@MikeMcQuaid
Copy link
Member

Is there a way to mass-update manifest files?

It's definitely possible. Not sure the easiest way to do so. brew pr-upload --keep-old --upload-only should do at least some of this locally.

May be worth uploading your own test bottle(s) to your own GitHub Packages somewhere and seeing what needs done. After that, we could test on a specific homebrew-core bottle and, eventually, run on all existing bottles.

@Rylan12
Copy link
Member Author

Rylan12 commented Jun 6, 2025

Okay, I wrote a script to easily migrate the manifest to include the new information:

https://github.com/Rylan12/formula-manifest-migration/blob/main/migrate.rb

For now, I have one test package (rylan12/formula-manifest-migration/wget:1.25.0) that this works for.

Anyone can easily view the manifest JSON with:

# Using oras
oras manifest fetch ghcr.io/rylan12/formula-manifest-migration/wget:1.25.0

# Using skopeo
skopeo inspect --raw docker://ghcr.io/rylan12/formula-manifest-migration/wget:1.25.0

Some more thorough testing is probably warranted, and then I'll probably choose one or a few lesser used homebrew/core formulae to try migrating, and test the entire pipeline on those before modifying everything.

@MikeMcQuaid
Copy link
Member

MikeMcQuaid commented Jun 6, 2025

@Rylan12 looks good to me so far! I couldn't authenticate but Oras worked as expected and looks good.

skopeo inspect --raw docker://ghcr.io/rylan12/formula-manifest-migration/wget:1.25.0 | jq -r '.annotations["sh.brew.formula.json"]' | jq . showed the relevant added JSON (if IU've understood correctly).

One thought is it might be worth dropping empty hashes/empty arrays/null values from the output to slim it down a bit? We're not as space conscious here but every little helps.

@Rylan12
Copy link
Member Author

Rylan12 commented Jun 6, 2025

@MikeMcQuaid no pressure, but if you'd like to try the script, I added the hello formula and gave you admin access so in theory migrate.rb hello should work

https://github.com/users/Rylan12/packages/container/package/formula-manifest-migration%2Fhello

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants