homebrew
doc がたくさんあるので読むと良い。
https://github.com/Homebrew/brew/tree/master/docs
用語集
table:用語
用語 中身
Formula パッケージ定義
Keg Formula によってインストールされた成果物。ソースからビルドする
Bottole pre-build された Keg
Cellar Keg 群のインストール先
Tap Formula 群を保持する Git リポジトリ
Cask macOS ネイティブアプリインストールのための Homebrew 拡張
Brew Bundle 依存関係記述のための Homebrew 拡張
Formula について
Ruby で記述された、パッケージの定義
https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md
Formula の書き方
API を確認する。
https://rubydoc.brew.sh/Formula
https://github.com/Homebrew/brew/blob/master/docs/Acceptable-Formulae.md
先駆者の確認。
https://nshipster.com/homebrew/
既存の Swift 製 CLI の記載方法を確認してみる。
https://github.com/uber/mockolo
https://github.com/Homebrew/homebrew-core/pull/51274
https://github.com/uber/mockolo/issues/97
brew create <URL> で install 対象のリポジトリを指定すると、Formula ファイルの雛形が自動生成される。
ソースからビルドさせる方式でも良いと思うけど、インストールに時間がかかるので、できるならバイナリを用意した方が良い。
参考
https://qiita.com/mono0926/items/c32c008384df40bf4e41
bottle の生成は bot が自動でやっているみたい?
要確認
https://github.com/tinder-maxwellelliott/homebrew-core/commit/b778314e484e4caa5d27c5fe6a434c26499987eb
https://gist.github.com/bigbes/c5c428db20e36ef5a18feafd050e560c
Tap について
Homebrew は、複数の Formula を Git リポジトリに管理していて、そこからパッケージ定義を引いてくる
デフォルトだと、Homebrew Core が利用される
brew tap <user/repo> を実行すると、https://github.com/<user>/homebrew-<repo> を Tap に追加し、そこからも Formula を引いてこれるようになる
tap の man は tap [options] [user/repo] [URL] のようになっていて、[URL] は未指定だと https で GitHub にアクセスするが、任意のリポジトリも指定できる。これにより、任意の Git リポジトリを指定して tap を追加することが可能
以下、マニュアルの転記
With URL unspecified, tap a formula repository from GitHub using HTTPS. Since so many taps are hosted on GitHub, this command is a shortcut for brew tap user/repo https://github.com/user/homebrew-repo.
With URL specified, tap a formula repository from anywhere, using any transport protocol that git(1) handles. The one-argument form of tap simplifies but also limits. This two-argument command makes no assumptions, so taps can be cloned from places other than GitHub and using protocols other than HTTPS, e.g. SSH, git, HTTP, FTP(S), rsync.
https://github.com/Homebrew/brew/blob/master/docs/Manpage.md#tap-options-userrepo-url
https://github.com/Homebrew/brew/blob/master/docs/Taps.md
Tap を作る場合
リポジトリ名は homebrew- prefix が推奨
brew tap コマンドで URL を省略した場合、それは brew tap user/repo https://github.com/user/homebrew-repo のショートカットとして扱われるため
Formula の配置場所は、Formula ディレクトリ配下か、HomebrewFormula ディレクトリ配下か、リポジトリ直下
1 つのディレクトリが認識されたら他のディレクトリは無視される
直下の他のファイルと混ざらないようにするためにも、サブディレクトリを作るのがおすすめ
homebrew-core の命名と formula の名前が被らないようにするのが良い
Tap を一度作れば、あとはユーザがわが brew update すれば追従する
https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md