ついにhomebrewにgit-nowがmergeされたよ><b
今朝ようやくhomebrewにとりこまれました!!
それでつっこまれていたgnu-getoptにlinkするところですが、同じようにdepends_on gnu-getoptしていたこちらを参考に、patchをあてる方法を使いました。
diffはちょっと長いですが以下です。
diff --git a/git-now.rb b/git-now.rb index f4e04c5..7263a66 100644 --- a/git-now.rb +++ b/git-now.rb @@ -1,31 +1,30 @@ require 'formula' class GitNow < Formula - url 'https://github.com/iwata/git-now.git', :tag => 'v0.1.0.8.1' - version '0.1.0.8.1' + url 'https://github.com/iwata/git-now.git', :tag => 'v0.1.0.9' + version '0.1.0.9' head 'https://github.com/iwata/git-now.git', :branch => 'develop' homepage 'https://github.com/iwata/git-now' def options [ - ['--gnu-getopt', "Link a gnu-getopt formula"], ['--zsh-completion', "copy zsh completion function file to #{share}/zsh/functions"] ] end - # for longopt - if ARGV.include? '--gnu-getopt' - depends_on 'gnu-getopt' + def patches + DATA end + + # for longopt + depends_on 'gnu-getopt' + if ARGV.include? '--zsh-completion' depends_on 'zsh' end def install system "make", "prefix=#{prefix}", "install" - if ARGV.include? '--gnu-getopt' - system "brew ln gnu-getopt" - end if ARGV.include? '--zsh-completion' zsh_functions_d = share + 'zsh/functions' zsh_functions_d.install "etc/_git-now" @@ -33,3 +32,22 @@ class GitNow < Formula end end + +#This patch makes sure GNUtools are used on OSX. +#gnu-getopt is keg-only hence the backtick expansion. +#These aliases only exist for the duration of git-now, +#inside the git-now shells. Normal operation of bash is +#unaffected - getopt will still find the version supplied +#by OSX in other shells, for example. +__END__ +--- a/git-now ++++ b/git-now +@@ -1,5 +1,7 @@ + #!/bin/sh + ++alias getopt='`brew --prefix gnu-getopt`/bin/getopt' ++ + # enable debug mode + if [ "$DEBUG" = "yes" ]; then + set -x +
patchの内容はこのshell内だけ、gnu-getoptのaliasをhomebrewでいれたgnu-getoptにするというものです。
元のgit-nowにこのaliasを書いてしまうと、homebrew以外でinstallした環境では動作しなくなってしまいます。
そんなときにdef patchesの出番!!ってことでやってます。これでinstall時にこのpatchをあててくれるようになります。
それでpatchあてるときは、それがどういうpatchなのかということも記述せい(キリッという規約がhomebrewにはあるので、怪しい英語で記述してあげます。
あと噂によるとshopt -s expand_aliasesがないとshell内定義したaliasは展開されないっぽいのですが、これで動いたのでよしとします。
これで無事homebrew本家のformula仲間入りを果たしたので、
$ brew install git-now $ brew install --zsh-completion git-now
でinstallできるようになりました!!
あとdepends_on zshはcommitterの人に削除されました><
zsh依存にしたくないからということでした。でもhomebrewでzshが入ってないと、補完関数のコピー先である/usr/local/share/etc/zsh/functionsが作られてないはずなので動くのかなー、という気がしないわけでもないです。
使う場合は.zshrcで$fpathに/usr/local/share/etc/zsh/functionsを追加するのをお忘れなく。
git-nowのhow toのようなものはまた次回書いてみようと思いまう。