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

Cask groups #4973

Closed
nicolas-brousse opened this issue Jun 18, 2014 · 12 comments
Closed

Cask groups #4973

nicolas-brousse opened this issue Jun 18, 2014 · 12 comments

Comments

@nicolas-brousse
Copy link
Contributor

Hi everybody,

I've an idea for a futur release. I think groups of cask can be interesting for companies.

For example, install group of apps for web developers or mobile developers:
brew cask install group company/developers

class Developer < CaskGroup
  app 'google-chrome'
  app 'atom'
end

EDIT:
Companies could create their own groups with a remote repository. Like "taps" with homebrew.

@tapeinosyne
Copy link
Contributor

In practice, the Caskfile should satisfy this use case rather well.

Do Caskfiles fall short of what you had in mind? Perhaps our docs are unclear about their availability or purpose?

@rolandwalker
Copy link
Contributor

Hi @nicolas-brousse !

Someone should submit a patch to the Homebrew project such that brew bundle would accept a URL as an argument. That would help companies could create a shared, private Caskfile representing a group. See the source for brew bundle at https://github.com/Homebrew/homebrew/blob/master/Library/Contributions/cmd/brew-bundle.rb .

@nicolas-brousse
Copy link
Contributor Author

I know Brewfile but I didn't know Caskfile.
Caskfile is interesting and useful for a project but for a workstation it could have more features.

My idea is not to have a simple list of cask but it's subscribe to a group and if this group is modified when you brew cask upgrade (I know this feature does not exist currently) it install the added cask.

I try to describe a more speaking example.


Example

So I have a company and I decide to create to groups of casks. On for developer, one for designers and one for common tools.

# developer.rb
class Developer < CaskGroup
  app 'atom'
  app 'sequel-pro'
end

# designer.rb
class Designer < CaskGroup
  app 'adobe-creative-cloud'
  app 'imageoptim'
end

# common.rb
class Common < CaskGroup
  app 'google-chrome'
end

Developers can install common and developer group. And designers can install common and designer group.
Like this: brew cask tap [organization/repository] and brew cask join-group [group name]

Now I decide to update common group.

class Common < CaskGroup
   app 'google-chrome'
+  app 'alfred'
+  app 'evernote'
end

After I ask team to brew cask upgrade and it automatically install alfred and evernote applications.


I think and I hope that it is a better explanation :)

@alebcay
Copy link
Member

alebcay commented Jun 18, 2014

When we say Caskfile, we secretly mean Brewfile with Homebrew-Cask commands. If you understand the function of a Brewfile, a file that looks like:

tap homebrew/versions
install gcc
install flac
install fish
... # etc

Essentially, its a list of brew commands without the opening brew directive.

Fortunately, Cask is an extension of Homebrew. So, we can specify similar functionality to handle apps:

tap caskroom/cask
cask install google-chrome
cask install alfred
cask install evernote
... # etc

We can make as many such files with different contents as desired and point to it with

$ brew bundle /path/to/my/file

or

$ brew bundle # automatically looks for ./Brewfile in the current directory

@nicolas-brousse
Copy link
Contributor Author

Thanks @rolandwalker and @alebcay for your answers.
I know Brewfile and I understand Caskfile is same and it permit to make a file that regroup a list of Formulae to install them.

So if I try to convert my proposal with Brewfile. That gives something like that?

# common/Brewfile
tap caskroom/cask

cask install google-chrome
cask install alfred

# developer/Brewfile
tap caskroom/cask

cask install atom
cask install sequel-pro

# designer/Brewfile
tap caskroom/cask

cask install adobe-creative-cloud
cask install imageoptim

I'm agree it's good for a first installation.
But if I want to add the cask evernote into the common/Brewfile.
How developers and designers could process to upgrade?

@alebcay
Copy link
Member

alebcay commented Jun 18, 2014

You can upgrade a regular Homebrew formula with

update
upgrade

in the file. Currently, Cask has no option to upgrade Casks (it's actively being worked on though). Therefore, the only option is to reinstall. Normally, Cask won't reinstall over a Cask that is already installed. We can get around that by using the --force flag when installing. So you should change all of your install commands to:

tap caskroom/cask

cask install --force google-chrome
cask install --force alfred

etc. If you want to add a Cask, say Evernote, simply append the line, and the file is now:

tap caskroom/cask

cask install --force google-chrome
cask install --force alfred
cask install --force evernote

Then simply run brew bundle again. Unfortunately, there's no way for the system to currently detect that only evernote is missing and not even bother looking at the other two Casks, but that functionality is possible if you use shell scripts instead of Cask/Brew files, which are beyond the scope of this discussion.

@tapeinosyne
Copy link
Contributor

A simple solution could be to brew bundle a sort of "meta-caskfile" as a cron job, or explicitly ask employees to bundle it when needed.

For example, a dev workstation would use the following Caskfile:

# Meta-Caskfile
update          # update to latest cask definitions
cask upgrade    # upgrades currently installed casks

# Bundle actual Caskfiles from company- or group-wide upstream
bundle /intranet/[…]/Caskfile-common    # skips installed casks, installs missing ones
bundle /intranet/[…]/Caskfile-dev       # as above

@alebcay
Copy link
Member

alebcay commented Jun 18, 2014

@ndr-qef your method seems much more reasonable than mine. I forgot that not using --force no longer makes Brewfile execution grind to a halt.

@rolandwalker
Copy link
Contributor

@nicolas-brousse, I see.

You want integration with update and upgrade, which would be nice. The way we would like to implement that is via Cask dependencies.

You will see back in #2001 I mention that "hard" dependencies between Casks are very few, and that the main use-case of such a feature would be meta-packages, which is what you are describing.

We did implement dependencies on Homebrew Formulae in #2305. Though nobody has implemented intra-Cask dependencies yet, we plan to, as mentioned in HACKING.md, and we recently stubbed out the necessary extension to the Cask DSL in pending PR #4896 here: https://github.com/caskroom/homebrew-cask/pull/4896/files#diff-ea6b3e6aa990eabf846e14be8329e9dcR5

The way the interface would work is, you could create ordinary (but empty) Cask files that defined your grouping via dependencies:

class DevelGroup < Cask
  depends_on :cask => 'google-chrome'
  depends_on :cask => 'alfred'
  ...
end

And you could serve them from private taps as described in ALTERNATE_CASK_TAPS.md.

So, this functionality is planned. How quickly it comes depends on whether someone volunteers to implement dependencies, once the depends_on :cask stub goes into the DSL.

@nicolas-brousse
Copy link
Contributor Author

Thanks @rolandwalker for your answer.

I think that it answers well my proposal of CaskGroup :)

I currently use homebrew-cask for a personal use only. But it will change soon ;)
I find this tool very useful to simplify the first workstation installation. And soon to simplify the upgrade of GUI applications :) in one command.

I would like to help you to implement dependencies but I don't have the level in ruby programming :(

@rolandwalker
Copy link
Contributor

@nicolas-brousse we are pleased to have your input here, in what ever form it may take.

Caskfiles can be made to work, for now, for most people, with some compromises.

I intend to close this proposal as a duplicate of #2001. This issue is now referenced there, so others will be able to find this informative discussion. Further comments are very welcome at #2001, as are patches to the documentation expanding on the use of Caskfiles.

@nicolas-brousse
Copy link
Contributor Author

Okey :)

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

No branches or pull requests

5 participants