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

Possible for Brewfile track a baseline set of Mac App Store apps, but not add new ones? #94

Closed
zcutlip opened this issue Nov 3, 2020 · 14 comments

Comments

@zcutlip
Copy link

zcutlip commented Nov 3, 2020

Is there a way to track a base set of mas apps in brewfile, but ignore any additional apps that get installed? I generally disable HOMEBREW_BREWFILE_APPSTORE, and this is why. I don't want every single app I install to get added to my brewfile.

If not, I wonder if having an additional setting would be possible? E.g.,

HOMEBREW_BREWFILE_APPSTORE=0 # Disable App Store
HOMEBREW_BREWFILE_APPSTORE=1 # Enable App Store
HOMEBREW_BREWFILE_APPSTORE=2 # Don't add additional App Store apps to Brewfile
@rcmdnk
Copy link
Owner

rcmdnk commented Nov 4, 2020

So, you have minimum apps list which should be installed at all of your Mac,
but you install some apps which should not be installed at another Mac, right?

With current brew-file system,
maybe it is better to separate Brewfile:

  1. Set HOMEBREW_BREWFILE_APPSTORE = 1.
  2. Do brew init to make Brewfile including mas apps.
  3. Make mas apps only Brewfile from it, and remove some if needed.
  4. Keep the file as you (push it in another GitHub repository, in Dropbox, write in Evernote, or etc...)
  5. Set HOMEBREW_BREWFILE_APPSTORE = 0 and do brew init.

Then, usually use Brewfile without mas apps.

And if you get new Mac,
put your mas Brewfile like ~/Brewfile.mas, and run
brew file install -f ~/Brwefile.mas.

There are some manual procedure,
but I think this accomplishs what you want.


On the other hand,

HOMEBREW_BREWFILE_APPSTORE=2 # Don't add additional App Store apps to Brewfile

I think this option is harmless for current functions (if I can correctly implement...),
I will try to implement it.

@zcutlip
Copy link
Author

zcutlip commented Nov 12, 2020

I think this is a workable approach:

brew file install -f ~/Brewfile.mas

I'll try working with that if you'd rather not change the behavior of mas apps.

@rcmdnk
Copy link
Owner

rcmdnk commented Nov 17, 2020

sorry for the late work.

Anyway, I've tried to implemented HOMEBREW_BREWFILE_APPSTORE=2 option,
and now it is available in the master branch.

You can enable this option by setting environmental variable:

export HOMEBREW_BREWFILE_APPSTORE=2

or using command line option

$ brew file init --appstore 2

Although it works as expected as long as I checked,
I want to ask you to check the functions before putting them in the release.

Could you please try the new version?
You can check it by cloning the repository and using bin/brew-file of master branch directly.

@zcutlip
Copy link
Author

zcutlip commented Nov 18, 2020

Thank you so much for working on this feature, especially if this isn't something that you personally wanted or needed.

I have a question: when I run brew-file out of a local clone of master, it re-taps everything and attempts to reinstall all of my casks.

Is this because I'm running brew-file from a location different from where homebrew is installed? Or is this a bug?

@rcmdnk
Copy link
Owner

rcmdnk commented Nov 18, 2020

um... it should be a bug, sorry.

Which subcommand do you use when it happened?
maybe brew-file install?

Could you please check other subcommands, such
brew-file get_files
brew-file help
brew-file init
etc... (better to make a backup of Brewfile before trying them...)

@zcutlip
Copy link
Author

zcutlip commented Nov 19, 2020

It was brew-file update. Here's truncated output:

./bin/brew-file update
$ brew update
Already up-to-date.
$ brew upgrade --fetch-HEAD
$ brew cask upgrade
Warning: Calling brew cask upgrade is deprecated! Use brew upgrade --cask instead.
$ brew tap homebrew/core
==> Unshallowing homebrew/core
$ brew tap homebrew/bundle
==> Unshallowing homebrew/bundle
$ brew tap homebrew/cask-drivers
==> Unshallowing homebrew/cask-drivers
$ brew tap homebrew/cask-fonts
==> Unshallowing homebrew/cask-fonts
$ brew tap homebrew/cask-versions
==> Unshallowing homebrew/cask-versions
$ brew tap homebrew/cask
==> Unshallowing homebrew/cask
$ brew tap rcmdnk/file
==> Unshallowing rcmdnk/file
$ brew tap teamookla/speedtest
$ brew tap vitorgalvao/tiny-scripts
==> Unshallowing vitorgalvao/tiny-scripts
$ brew cask install --force font-hack-nerd-font

The other commands:
./bin/brew-file install: no output

./bin/brew-file get_files:

/Users/zach/.dotfiles/brewfile/Brewfile
/Users/zach/.dotfiles/brewfile/osarian.Brewfile
/Users/zach/.dotfiles/brewfile/${HOSTNMAME}-mas.Brewfile #< -- this is weird because it should have expanded to `osarian-mas.Brewfile`

brew-file help:

usage: brew-file [-f INPUT] [-b BACKUP] [-F FORM] [--leaves] [--on_request] [--top_packages TOP_PACKAGES] [-U] [-r REPO] [-n] [--caskonly] [--appstore APPSTORE]
                 [--no_appstore] [-C] [-y] [-V VERBOSE] [-h]
                 [command] ...

Brew-file: Manager for packages of Homebrew
https://github.com/rcmdnk/homebrew-file
<truncated>

./bin/brew-file init

/Users/zach/.dotfiles/brewfile/Brewfile is already there.

####################################################
# Initialize /Users/zach/.dotfiles/brewfile/Brewfile
####################################################


############################################################
# You can edit /Users/zach/.dotfiles/brewfile/Brewfile with:
#     $ brew-file edit
############################################################

The init command deleted the "Additional files" section from Brewfile:

git diff brewfile/Brewfile
diff --git a/brewfile/Brewfile b/brewfile/Brewfile
index a98009c..adff6f4 100644
--- a/brewfile/Brewfile
+++ b/brewfile/Brewfile
@@ -72,6 +72,7 @@ tap homebrew/cask-versions
 tap homebrew/cask
 cask 1password-cli
 cask adoptopenjdk
+cask docker
 cask filemon
 cask ghidra
 cask hfsleuth
@@ -91,7 +92,3 @@ brew speedtest

 tap vitorgalvao/tiny-scripts
 brew cask-repair
-
-# Additional files
-file ./${HOSTNAME}.Brewfile
-file ./${HOSTNMAME}-mas.Brewfile

@rcmdnk
Copy link
Owner

rcmdnk commented Nov 19, 2020

ok, I found a bug in brew-file update.
Disappearance "Additional files" was also made by upgrade (not by init, they were already deleted by upgrade).

Current master version should work...

@zcutlip
Copy link
Author

zcutlip commented Nov 19, 2020

The following commands seem to work as expected:

  • brew-file update
  • brew-file install
  • brew-file help
  • brew-file get_files

The brew-file init command doesn't seem to be working quite right:

./bin/brew-file init
/Users/zach/.dotfiles/brewfile/Brewfile is already there.
[WARNING]: Input file /Users/zach/.dotfiles/brewfile/Brewfile is not found.
Do you want to initialize from installed packages? [y/n]: y
[WARNING]: Input file /Users/zach/.dotfiles/brewfile/Brewfile is not found.
Do you want to initialize from installed packages? [y/n]: y
[WARNING]: Input file /Users/zach/.dotfiles/brewfile/Brewfile is not found.
Do you want to initialize from installed packages? [y/n]: y
[WARNING]: Input file /Users/zach/.dotfiles/brewfile/Brewfile is not found.
Do you want to initialize from installed packages? [y/n]: y
[WARNING]: Input file /Users/zach/.dotfiles/brewfile/Brewfile is not found.
Do you want to initialize from installed packages? [y/n]: y
[WARNING]: Input file /Users/zach/.dotfiles/brewfile/Brewfile is not found.
Do you want to initialize from installed packages? [y/n]: n
[ERROR]: Ok, please prepare brewfile
[ERROR]: or you can initialize /Users/zach/.dotfiles/brewfile/Brewfile with:
[ERROR]:     $ brew-file init

@rcmdnk
Copy link
Owner

rcmdnk commented Nov 20, 2020

sorry, there was an another bug for HOMEBREW_BREWFILE_APPSTORE=2, which make such a loop.
I pushed fixed version in the master branch.
Could you please try again?

@zcutlip
Copy link
Author

zcutlip commented Nov 20, 2020

I updated master and all the commands seem to work.

Thank you! I'm sorry this was a lot of trouble for you.

@rcmdnk
Copy link
Owner

rcmdnk commented Nov 22, 2020

ok, thanks for debugging!
It is now available in the release, i.e. brew file update will install the version.

Please do not hesitate to send issues which make the tool better!

@rcmdnk rcmdnk closed this as completed Nov 22, 2020
@zcutlip
Copy link
Author

zcutlip commented Nov 22, 2020

Thank you! I can't wait to try it out.

It looks like brew-file.rb is still installing version 8.0.5, though.

@rcmdnk
Copy link
Owner

rcmdnk commented Nov 22, 2020

oops! sry, I forgot to update the formula.
the file has been updated now.

@zcutlip
Copy link
Author

zcutlip commented Nov 22, 2020

Awesome; this works great! Thank you for working on this.

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