My formula need to persist configuration file between upgrade, so I symlink those configuration directory to /usr/local/var/foo-app.
I would like to know, does homebrew formula has hook to do clean up when user uninstall the formula. Or Its okay to left /usr/local/var/foo-app there.
Related
I am running out of space on my laptop, and I was wondering if it would be possible to change the default directory of installing casks on an external hard drive so that I can use the internal hard drive just for the OS and important files.
I guess you can overwrite the environment variable HOMEBREW_CASK_OPTS or you can use the --appdir=/my/path option. You can get more information with the command man brew-cask and there is a nice markdown documentation in the cask repository. Otherwise the executables can be found in the Applications folder.
EDIT:
Sometimes it helps to run a cleanup to delete the old versions:
brew cleanup
brew cask cleanup
brew install --head <formula> installs a formula from master (usually). But it feels useless to me, because it fails if you've already got that formula installed due to a link conflict error. (Not even --force works.) Therefore you always have to do brew unlink <formula> first, or uninstall entirely.
I would have expected there to be a way to install a formula without linking it somehow, but apparently not.
Ultimately what I want is to have two copies installed, one the proper release, and one built from master. But the proper one should always have the link. (I would have like to have had another link like /usr/local/bin/<formula>_HEAD, but that's another issue.)
As a workaround, I can copy the formula and give at new name, but that seems gross, and you can't have a "--head-only" formula it seems, so I'd have to keep the version info up to date in the copy as well.
Maybe I need a totally separate installation of Homebrew? But that seems like overkill.
I'm packaging a java app as a Homebrew formula.
I've got this in my formula
def install
bin.install "bin/my-app"
lib.install Dir["lib/*.jar"]
end
It works fine, but it ends up symlinking all the jar files into /usr/local/lib/.
I see that the keg_only option. However that will also prevent bin/my-app from being symlinked into /usr/local/bin.
Is there an option for me to say, "Install the bin as you normally do, but these libs need to only live in the Cellar for my app."?
I received an answer at the Homebrew forum
Consider installing the JARs in libexec instead:
libexec.install Dir["lib/*.jar"]
and adjust the necessary paths in my-app (I assume it’s a typical
Java launcher script). That’s a fairly common pattern in Java
formulas.
This is what I have now
def install
bin.install "bin/my-app"
libexec.install Dir["lib/*.jar"]
inreplace "#{bin}/my-app", '/lib/', '/libexec/'
end
So I've made an edit to the tmux formula in homebrew, but now I'm starting to think about how I can keep that change between machines without forking and maintaining my own version of homebrew.
If I do fork homebrew, I would just have to edit and install script to point to my location, but would the formulas locations still be maintained?
So I guess my question is what are my options here? Should I fork homebrew or just make a note of the changes?
You can make your own tap. The easiest way is to create a repository on GitHub called homebrew-self. Your custom formula goes in the root of the repository. Then, you can use it in Homebrew by running
brew tap <your github username>
If you're modifying a formula that's already in Homebrew, though, the easiest (and best) way is to submit a pull request containing your changes.
I'm trying to write a brew formula(for example, foo) but need to save some files in /usr/local/Cellar/foo/1.0.0/ such as VERSION, but I find that brew only save some files in that dir such as README, LICENSE and so on.
So.. how can I change the default behaviour?
I find this can be implemented by add prefix.install 'VERSION' to install method of your formula class.