Notes on creating a new package
last updated: Oct 20, 2023
I'm trying to package whisper.cpp as a library for homebrew
-
brew create --autotools https://github.com/ggerganov/whisper.cpp/archive/refs/tags/v1.4.0.tar.gz
- created the package as
lib-whispercpp
, I'm not sure if that's because of something I did earlier or if it auto-decided that's what the package name should have been - Later on, I changed it to
libwhisper
because that seems to be the best match for their naming conventions
- created the package as
-
I found it helpful to clone homebrew-core so I could run greps against the already-existing formulae and search for useful tips and tricks
-
I made a directory and created a very short makefile to save commands I used frequently:
.PHONY: edit
edit:
nvim /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libwhisper.rb
.PHONY: audit
audit:
brew audit --new libwhisper
.PHONY: install
install:
brew install --build-from-source libwhisper
.PHONY: install
uninstall:
- brew uninstall libwhisper
.PHONY: test
test:
# I ended up writing a small C program to use both as the test in the
# formula, as well as to test the installed library
/usr/bin/clang test.c -I/opt/homebrew/Cellar/libwhisper/1.4.0/include -L/opt/homebrew/Cellar/libwhisper/1.4.0/lib -lwhisper -o test
./test
brew test libwhisper
I wanted to create a tap so that I could install in the meantime. for use in blisper (and maybe other experiments), so I:
- created a repository:
gh repo create --public llimllib/homebrew-whisper
- added it as a remote:
git remote add origin https://github.com/llimllib/homebrew-whisper.git
- (I had forgotten the
--src
arg togh repo create
- (I had forgotten the
- pushed a
Formula
directory containing the formula I'd just built, a README, and a few gitihub actions I took frombrew tap-new llimllib/deleteme
- I didn't expect that latter command to install into the brew directory, but it did; I went in it to inspect and copy their template files then deleted it after
- To test the repo, I uninstalled
libwhisper
that I had done locally, and ran:brew install llimllib/whisper/libwhisper
- which worked! neato.