irofコマンドをbrewでインストールしてみる
このブログポストはいろふアドベントカレンダーのXデー(マヤ暦最後の日)の記事です。
というわけで、最後の日にふさわしくなく世界のirofさんをコマンド化して、brewで入れてみようと思います。
まず irof コマンドを作りましょう。
といってもあまり良いのが思いつかないのでechoで 「irof」を表示したいと思います。
こんな感じのです。
https://gist.github.com/4345634
では最初はbrewのFomulaを作ります。
brew create https://gist.github.com/4345634/download Formula name [download]: irof Warning: Version cannot be determined from URL. You'll need to add an explicit 'version' to the formula. ==> Downloading https://gist.github.com/4345634/download ######################################################################## 100.0% Please `brew audit irof` before submitting, thanks.
こんな感じで irofォーミュラを作りました。
brew create の後のURLは後で編集するので適当でいいですが、ここで作ってしまうとFomulaに登録されてしまい、後からGithub経由でbrew-tapした時に追加されないので注意が必要です。
versionを追加して適当に書くとこんな感じになりました。
require 'formula' # Documentation: https://github.com/mxcl/homebrew/wiki/Formula-Cookbook # PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST! class Irof < Formula url 'https://github.com/tango238/homebrew-irof/tarball/master' version '0' #sha1 'ca0ec4a469f998c79ad3c113dd81359080fdc8dc' def install bin.install ['irof'] end def test end end
https://github.com/tango238/homebrew-irof/blob/master/irof.rb
/usr/local/Library/Formula の中に irof.rb ファイルができているので brew edit irof でも編集出来ます。
これをgithubにリポジトリを作成してコミットします。
リポジトリ名は「homebrew-irof」でないといけません。
homebrew-Xxxみたいな決まりっぽいです。
さてコミットが終わったらさっそくirofコマンドをbrewでインストールしてみましょう。
brew tap tango238/irof Cloning into /usr/local/Library/Taps/tango238-irof... remote: Counting objects: 45, done. remote: Compressing objects: 100% (37/37), done. remote: Total 45 (delta 22), reused 26 (delta 6) Unpacking objects: 100% (45/45), done. Tapped 1 formula
brew install irof ==> Downloading https://github.com/tango238/homebrew-irof/tarball/master Already downloaded: /Library/Caches/Homebrew/irof-0.tgz Warning: Cannot verify package integrity The formula did not provide a download checksum For your reference the SHA1 is: 3bc8f583bffd12787a38a330647f1ee2ce120b5d ==> chmod 755 /usr/local/Cellar/irof/0/bin/irof /usr/local/Cellar/irof/0: 3 files, 12K, built in 2 second
ここまで来たらあとは irof と打つだけ!
かと思いきや
zsh: permission denied: irof
が出ちゃいました。。うーん、よく分からないし、眠たいし、世界も終わっちゃうので、とりあえずchmodで権限追加します。。。
chmod 755 /usr/local/Cellar/irof/0/bin/irof
そして今度こそ!!!
このブログを参考にして是非あなたもあなただけのirofコマンドを作ってみてくださいね!