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

Linuxbrew #2

Closed
jamesstidard opened this issue Aug 5, 2019 · 4 comments
Closed

Linuxbrew #2

jamesstidard opened this issue Aug 5, 2019 · 4 comments

Comments

@jamesstidard
Copy link
Contributor

Hi,

I was wondering if it's possible to detect / handle if the machine is either using linuxbrew or homebrew.

I use both linux and macOS and I use brew on both to keep the same package manager. However, the Brewfile I produce will have mas and cask entires. Do you have a recommended way of handling this for this plugin?

Thanks for the plugin.

@sobolevn
Copy link
Owner

sobolevn commented Aug 5, 2019

Hm 🤔

Never had the opportunity to work with Linuxbrew. So, have no idea how it works.
But, I know that brew bundle dump has flags for what to output:

» brew bundle dump --help 
Usage: brew bundle subcommand

Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask and the Mac App
Store.

     --file=                        read the Brewfile from this file. Use
                                     --file=- to output to stdin/stdout.
     --global                       read the Brewfile from ~/.Brewfile.

brew bundle [install] [-v|--verbose] [--no-upgrade]
[--file=path|--global]

Install or upgrade all dependencies in a Brewfile.

     -v, --verbose                  print the output from commands as they are
                                     run.
     --no-upgrade                   don't run brew upgrade on outdated
                                     dependencies. Note they may still be
                                     upgraded by brew install if needed.

brew bundle dump [--force] [--describe] [--no-restart]
[--file=path|--global]

Write all installed casks/formulae/taps into a Brewfile.

     --force                        overwrite an existing Brewfile.
     --describe                     output a description comment above each
                                     line. This comment will not be output if
                                     the dependency does not have a description.
     --no-restart                   do not add restart_service to formula
                                     lines.

brew bundle cleanup [--force] [--zap] [--file=path|--global]

Uninstall all dependencies not listed in a Brewfile.

     --force                        actually perform the cleanup operations.
     --zap                          casks will be removed using the zap
                                     command instead of uninstall.

brew bundle check [--no-upgrade] [--file=path|--global] [--verbose]

Check if all dependencies are installed in a Brewfile.

     --no-upgrade                   ignore outdated dependencies.
     -v, --verbose                  output and check for all missing
                                     dependencies.

brew bundle exec command

Run an external command in an isolated build environment.

brew bundle list [--all|--brews|--casks|--taps|--mas]
[--file=path|--global]

List all dependencies present in a Brewfile. By default, only brew dependencies
are output.

     --all                          output all dependencies.
     --brews                        output Homebrew dependencies.
     --casks                        output Homebrew Cask dependencies.
     --taps                         output tap dependencies.
     --mas                          output Mac App Store dependencies.

We can add an option to pass flags to the command call: brew_bundle_dump_flags: ['--brews', '--casks', '--taps']

PRs are welcome.

@jamesstidard
Copy link
Contributor Author

Yeah that sounds like the way to go. I’ll have a read about the plugin protocol and submit a PR. Cheers

@jamesstidard
Copy link
Contributor Author

Took a shot at this. Unfortunately it didn't turn out as simple as I expected. brew bundle doesn't accept those same filters that brew bundle list does.

The output of the list is also not in the Brewfile format, so ended up abandoning that route. I also got the impression from this ticket that this use case doesn't really have the support of the maintainers.

Anyway, the simplest way I could think of implementing it was to use the HOMEBREW_BUNDLE_X_SKIP environment variables that bundle does respect. From that ticket above, I make sure to use the id value instead of the name for all mas entries.

I've also gone with just include as the option, where you can provide a whitelist of the types you want to install e.g. include: ['tap', 'brew'] would do it for linuxbrew. Defaults to include all. Would be easy to switch to exclude instead or some else - if you have a preference.

I guess it might also be possible to detect linuxbrew vs homebrew systems and have the defaults make sense for that system. i.e. all for Mac and just taps and brews for linux.

Anyway, let me know what you think and if maybe this is do too much. It was a larger change than I had anticipated.

@sobolevn
Copy link
Owner

sobolevn commented Aug 6, 2019

I like the idea and the implementation. Thanks again!

Closed by #3

@sobolevn sobolevn closed this as completed Aug 6, 2019
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

2 participants