gitをインストール

仕事ではSubversionを使っているケースがほとんどだけど、ローカルなリポジトリが欲しいときがどんどん増えてきたので、はやりのgitを使うことにしました。

まずはgit-coreとcogitをいれればいいみたいなので、http://en.yummy.stripper.jp/?eid=825692 を参考に

sudo port install git-core +svn

ってやってみた。そしたら大量のパッケージをインストールしつつも、

###########################################################
# A startup item has been generated that will aid in
# starting openssh with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo launchctl load -w /Library/LaunchDaemons/org.macports.OpenSSH.plist
###########################################################

みたいなメッセージを表示しつつ、perlのインストールに時間がかかりながらも、終了〜とか思ったらエラーだった。

--->  Fetching sqlite3
--->  Attempting to fetch sqlite-3.5.8.tar.gz from http://www.sqlite.org/
--->  Verifying checksum(s) for sqlite3
--->  Extracting sqlite3
--->  Configuring sqlite3
--->  Building sqlite3 with target all
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_sqlite3/work/sqlite-3.5.8" && gnumake all " returned error 2
Command output: sed -e s/--VERS--/3.5.8/ ./src/sqlite.h.in | \
	sed -e s/--VERSION-NUMBER--/3005008/ >sqlite3.h
/usr/bin/gcc-4.0 -O2 -o mkkeywordhash  ./tool/mkkeywordhash.c
./mkkeywordhash >keywordhash.h
/usr/bin/gcc-4.0 -O2 -o lemon ./tool/lemon.c
cp ./tool/lempar.c .
cp ./src/parse.y .
./lemon  parse.y
mv parse.h parse.h.temp
f ./addopcodes.awk parse.h.temp >parse.h
/bin/sh: f: command not found
gnumake: [parse.c] Error 127 (ignored)
cat parse.h ./src/vdbe.c |  -f ./mkopcodeh.awk >opcodes.h
/bin/sh: -f: command not found
cat: stdout: Broken pipe
gnumake: *** [opcodes.h] Error 127

Error: The following dependencies failed to build: p5-svn-simple subversion-perlbindings apr-util sqlite3 neon subversion p5-term-readkey rsync popt
Error: Status 1 encountered during processing.

わけわかんね。sqlite3のインストールで失敗してるっぽい。まあ何も考えずに入れようとしてたので、infoとvariantsくらいは確認するべきか。

$ port info git-core
git-core 1.5.4.5, Revision 1, devel/git-core (Variants: universal, doc, gitweb, svn, bash_completion)
http://git.or.cz/

A stupid (but extremely fast) directory content manager. It doesn't do a whole lot, but what it _does_ do is track directory contents efficiently.

Library Dependencies: curl, zlib, openssl, expat, libiconv
Runtime Dependencies: openssh, rsync, perl5.8, p5-error
Platforms: darwin
Maintainers: bryan@larsen.st openmaintainer@macports.org


$ port variants git-core
git-core has the variants:
	universal
	doc: Install HTML and plaintext documentation
	gitweb: Install gitweb.cgi
	svn: Bi-directional subversion repository support
	bash_completion: Bash completion support

あ、bash_completionってあるじゃん。これも入れよう。
そういえば、さっきのメッセージになにか書いてあったな。わかないけど、やっちまえ。

$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.OpenSSH.plist

で、もう一回。

$ sudo port install git-core +svn +bash_completion
--->  Building sqlite3 with target all
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_sqlite3/work/sqlite-3.5.8" && gnumake all " returned error 2
Command output: sqlite3.c:75427: error: 'TK_GE' undeclared (first use in this function)
sqlite3.c:75430: error: 'TK_RSHIFT' undeclared (first use in this function)
sqlite3.c:75433: error: 'TK_GT' undeclared (first use in this function)
sqlite3.c:75439: error: 'TK_ILLEGAL' undeclared (first use in this function)
sqlite3.c:75448: error: 'TK_BITOR' undeclared (first use in this function)
sqlite3.c:75451: error: 'TK_CONCAT' undeclared (first use in this function)
sqlite3.c:75456: error: 'TK_COMMA' undeclared (first use in this function)
sqlite3.c:75460: error: 'TK_BITAND' undeclared (first use in this function)
sqlite3.c:75464: error: 'TK_BITNOT' undeclared (first use in this function)
sqlite3.c:75481: error: 'TK_STRING' undeclared (first use in this function)
sqlite3.c:75493: error: 'TK_DOT' undeclared (first use in this function)
sqlite3.c:75501: error: 'TK_INTEGER' undeclared (first use in this function)
sqlite3.c:75507: error: 'TK_FLOAT' undeclared (first use in this function)
sqlite3.c:75527: error: 'TK_ID' undeclared (first use in this function)
sqlite3.c:75527: warning: assignment makes integer from pointer without a cast
sqlite3.c:75531: error: 'TK_VARIABLE' undeclared (first use in this function)
sqlite3.c:75540: error: 'TK_REGISTER' undeclared (first use in this function)
sqlite3.c:75580: error: 'TK_BLOB' undeclared (first use in this function)
sqlite3.c: In function 'sqlite3RunParser':
sqlite3.c:75651: error: 'TK_SPACE' undeclared (first use in this function)
sqlite3.c:75651: warning: case label value exceeds maximum value for type
sqlite3.c:75652: error: 'TK_COMMENT' undeclared (first use in this function)
sqlite3.c:75652: warning: case label value exceeds maximum value for type
sqlite3.c:75660: error: 'TK_ILLEGAL' undeclared (first use in this function)
sqlite3.c:75660: warning: case label value exceeds maximum value for type
sqlite3.c:75669: error: 'TK_SEMI' undeclared (first use in this function)
sqlite3.c:75669: warning: case label value exceeds maximum value for type
sqlite3.c:75685: warning: comparison between pointer and integer
sqlite3.c:75686: warning: passing argument 2 of 'sqlite3Parser' makes integer from pointer without a cast
gnumake: *** [sqlite3.lo] Error 1

Error: The following dependencies failed to build: p5-svn-simple subversion-perlbindings apr-util sqlite3 neon subversion bash-completion p5-term-readkey rsync popt
Error: Status 1 encountered during processing.

やっぱりsqlite3が問題なので、一旦cleanしてみる。

$ sudo port clean sqlite3
--->  Cleaning sqlite3

で、もう一回。

$ sudo port install sqlite3
--->  Fetching sqlite3
--->  Verifying checksum(s) for sqlite3
--->  Extracting sqlite3
--->  Configuring sqlite3
--->  Building sqlite3 with target all
--->  Staging sqlite3 into destroot
--->  Installing sqlite3 3.5.8_0
--->  Activating sqlite3 3.5.8_0
--->  Cleaning sqlite3

お、できたできた!

じゃあ、もう一回git-coreいってみましょー

$ sudo port install git-core +svn +bash_completion

また途中でこんなメッセージ。

Set this at the *end* your .bash_profile:

    if [ -f /opt/local/etc/bash_completion ]; then
        . /opt/local/etc/bash_completion
    fi

.bash_profileの*最後*にこれを入れろってことね。りょーかーい。

で、なんとか入った模様っす〜。

$ git --version
git version 1.5.4.5


次はcogitoっすー。こっちは簡単でしょーと根拠なくタカを括ってたら失敗。
でもさっきの教訓を生かして、port cleanしてもう一回やってみたらうまく行きました。

$ sudo port clean cogito
Password:
--->  Cleaning cogito

$ sudo port install cogito
--->  Fetching cogito
--->  Verifying checksum(s) for cogito
--->  Extracting cogito
--->  Applying patches to cogito
--->  Configuring cogito
--->  Building cogito with target all
--->  Staging cogito into destroot
--->  Installing cogito 0.18.2_1
--->  Activating cogito 0.18.2_1
--->  Cleaning cogito
$ cg-add --help
Usage: cg-add [-a] [-N] [-r] FILE...
Add new files to the repository

Options:
  -h, --help   Print usage summary
  --long-help  Print user manual

ちゃんと入ったらしいっす。