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

Ability to install specific builds of a JDK? #50

Open
nskobelevs opened this issue Jun 14, 2023 · 5 comments
Open

Ability to install specific builds of a JDK? #50

nskobelevs opened this issue Jun 14, 2023 · 5 comments

Comments

@nskobelevs
Copy link
Contributor

I was wondering whether it's possible to extend these casks to allow users to install a specific of JDKs?

I've had a few instances where I've ran into bugs on the latest JDK build where the only build is to downgrade to a previous build until the issue is fixed on the latest release. It would be nice to be able to install older versions through brew (e.g. zulu-jdk@17.0.6) instead of having to manually install the version through the dmg.

Example Issue which requires downgrading

@mdogan
Copy link
Owner

mdogan commented Jun 16, 2023

I think it's possible to keep all versions as separate casks. That will require a few changes to the updater app. I can try to implement this when I have some free time, but can't promise when unfortunately. As always all contributions are welcome.

@nskobelevs
Copy link
Contributor Author

I had a look at updater and while I can't make any promises, I am interested to look into this further.

There are a few things to discuss though.

Version Definitions
Firstly I couldn't find any homebrew documentation on this but it seems that versioning this way just means having a separate cask definitions for each version? For example I'm seeing python@3.7.rb, python@3.8.rb, etc in the homebrew-core repo (I'm assuming it wouldn't be any different for casks). Am I right to understand then that updater needs to output a .rb file for every version Zulu has? So we'd have zulu-jdk17@17.0.7.rb, zulu-jdk17@17.0.6.rb etc?

Default Version
Even with separate versions available we would still like zulu-jdk17 to work and install the latest version available. homebrew-core has an Aliases folder which seems to allow to reference another formula - I'll explore whether this works for casks (e.g. python3 referencing most latest python version)

Double Versioning
Having a cask be like zulu-jdk17@17.0.0 feels clunky given the double versioning. Is there scope for simplifying the cask to zulu-jdk with version afterwards? Again it might be possible to use aliases to keep the old names - so zulu-jdk17 aliases to zulu-jdk@17.<latest>

Conflicts
The Zulu .pkg's currently install in /Library/Java/JavaVirtualMachines/zulu-{version}.jdk meaning it's not possible to install multiple minor versions of the same major JDK version. (e.g having 17.0.7 and 17.0.6 side-by-side)

I don't know is this is something you want to support or how often someone might need to have multiple minor versions but it might be possible by switching to .tar.gz and manually unpacking in e.g. .../zulu-17.0.7.jdk. However I'm not sure about the logistics of this in the context of homebrew given the uninstall action is now different and whether that affects users who installed previous to the change.

off-topic:

Zulu API
I've roughly figured out how the API works and how to get versions from the updater code but I'm having a lot of trouble find documentation on their Discovery API - it seems they've migrated to their Metadata API with the only reference to the old Discovery API being their article Migrate from Zulu OpenJDK Discovery API to Azul Metadata API. While I wasn't able any indication that the Discovery API is planned to be deprecated, I was wondering if this migration would be benificial?

@JakeWharton
Copy link
Contributor

it seems that versioning this way just means having a separate cask definitions for each version?

That is my understanding. They abandoned versioning a long time ago so this is basically a trick to emulate it.

homebrew-core has an Aliases folder which seems to allow to reference another formula - I'll explore whether this works for casks

Cool! This definitely sounds desirable.

I'm curious what happens when you install a specific version and then the alias. Does it no op? Then then if you uninstall the specific version it should also be a no op as the alias is still "installed".

Or here's another one: you install a specific version and the alias, and then the alias changes. Does upgrade install the newer version and keep the old?

I assume so, but we should test it.

Having a cask be like zulu-jdk17@17.0.0 feels clunky given the double versioning.

I don't hate this, but if we are doing aliases perhaps we can start with zulu-jdk@17.0.0 for the specific versions and worry about migrating the existing names to @17 and such later.

it might be possible by switching to .tar.gz

That would have been my suggestion.

I think we can also install into ~/Library directory rather than /Library, but maybe that discussion is for another time. It would avoid sudo.

I was wondering if this migration would be benificial?

Let's either do it before or after as a separate change. But sounds like it is the direction they are going.

@nskobelevs
Copy link
Contributor Author

I'm curious what happens when you install a specific version and then the alias. Does it no op? Then then if you uninstall the specific version it should also be a no op as the alias is still "installed".
Or here's another one: you install a specific version and the alias, and then the alias changes. Does upgrade install the newer version and keep the old?
I assume so, but we should test it.

From exploring brew source code my understanding is that aliases are only used when trying to resolve a formula name passed as argument to brew to an actual formula definition after which it's indifferentiable from a non-alias. The aliases aren't separate formula either - they don't know up on brew list for example. So my understanding is that the answer to any of these questions is essentially what you would expect to happen if you the user used the fully qualified name instead of the alias.

e.g. brew install python@3.11 followed by brew install python3 is a warning since python3 resolves to python@3.11 which is already installed.

After installation there is no reference to the alias - python@3.11 is the formula installed. When a new python version comes out and the python3 alias gets bumped to python@3.12 you won't be able to uninstall your python@3.11 using python3 alias since it'll resolve to python@3.12.

The Aliases folder only works for formulae and not casks.

I created an Alias for one of these casks and it was unable to resolve it - however trying to install it without --cask the alias was properly resolved but it threw an error given it expected a formula definition and not a cask one.
This lack of support can be partially confirmed from the docs where the Formula Cookbook states "Add aliases by creating symlinks in an Aliases directory in the tap root." while the Cask Cookbook makes no such mention.

it might be possible by switching to .tar.gz
That would have been my suggestion.

I think this might be the way to go at some stage as like you said it prevent requiring sudo but also if installation is moved to ~/Library could this be converted to a formula instead of a cask? (Or are there other home-brew limitations forcing this to be a cask other than the .pkg install?) Moving a formula could open up the use of Aliases

Let's either do it before or after as a separate change. But sounds like it is the direction they are going.

I'll take a look at the migration article and perhaps do the migration before the versioning

@JakeWharton
Copy link
Contributor

So my understanding is that the answer to any of these questions is essentially what you would expect to happen if you the user used the fully qualified name instead of the alias.

Okay. That makes sense. But also means it sounds like a non-starter for use here. Ultimately it's not that big of a deal since 100% of the files are generated rather than hand-written.

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

No branches or pull requests

3 participants