MacPortsを使ってgitをインストールしてみた

特にMercurialで困っていることはないのですが、最近採用しているプロジェクトをよく見かけるのでgitを突っ込んでみました。

そもそもMacPortsにあるのだろうか

/Users/home> port search git
cogito          devel/cogito   0.18.2       Git core and cogito tools to provide a fully-distributed SCM
git-core        devel/git-core 1.5.4.5      The stupid content tracker.
stgit           devel/stgit    0.14.1       Push/pop utility on top of GIT
cgit            www/cgit       0.7.1        A fast web interface for the git source code management system 

多分cogitoとgit-coreかな。

オプション見てみる

/Users/home> 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

ドキュメントは今のところローカルには要らない。gitweb.cgiは使うか分からんけど一応含めておこう。svnはきっと必要だろうなぁ。bashはいいや。

/Users/home> port variants cogito
cogito has the variants:
	universal

必要なしっぽい。

インストールしてみる

/Users/home> sudo port install git-core +gitweb +svn
(中略)
--->  Building apr 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_devel_apr/
work/apr-1.2.12" && make all " returned error 2
Command output: /bin/sh /opt/local/var/macports/build/
_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_apr/work/apr-1.2.12/libtool
 --silent --mode=compile /usr/bin/gcc-4.0   
-O2 -DHAVE_CONFIG_H -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp  
-I/opt/local/include -I./include 
-I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_apr/
work/apr-1.2.12/include/arch/unix 
-I./include/arch/unix 
-I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_apr/
work/apr-1.2.12/include  -o misc/unix/rand.lo -c misc/unix/rand.c && touch misc/unix/rand.lo
misc/unix/rand.c:39:18: error: uuid.h: No such file or directory
make[1]: *** [misc/unix/rand.lo] Error 1
make: *** [all-recursive] Error 1

成功している部分は中略している。どうやらuuid.hが見つからないそうだ。ググってみると、どうやら/usr/include内にあるらしい。

/Users/home> ls -l /usr/include/uuid
total 8
-r--r--r--  1 root  wheel  2523  2 19 19:55 uuid.h

見つけたので/opt/local以下にコピーしてみる。

/Users/home> cp /usr/include/uuid/uuid.h /opt/local/include/uuid.h

再度インストール。

/Users/home> sudo port install git-core +gitweb +svn
--->  Fetching git-core
--->  Attempting to fetch git-1.5.4.5.tar.bz2 from http://www.kernel.org/pub/software/scm/git/
--->  Attempting to fetch git-manpages-1.5.4.5.tar.bz2 from http://www.kernel.org/pub/software/scm/git/
--->  Attempting to fetch git-htmldocs-1.5.4.5.tar.bz2 from http://www.kernel.org/pub/software/scm/git/
--->  Verifying checksum(s) for git-core
--->  Extracting git-core
--->  Applying patches to git-core
--->  Configuring git-core
--->  Building git-core with target all gitweb/gitweb.cgi
--->  Staging git-core into destroot
--->  Installing git-core 1.5.4.5_0+doc+gitweb+svn
--->  Activating git-core 1.5.4.5_0+doc+gitweb+svn
--->  Cleaning git-core

正常に終了。指定していないがdocも入っているようだ。まぁいいか。
次はcogitoをインストール。

/Users/home> sudo port install cogito
--->  Fetching cogito
--->  Attempting to fetch cogito-0.18.2.tar.bz2 from http://kernel.org/pub/software/scm/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

こちらは詰まることもなく正常に終了。

ちょっと見てみる

/Users/home> git
usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare]
 [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find the change that introduced a bug by binary search
   branch     List, create, or delete branches
   checkout   Checkout and switch to a branch
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty git repository or reinitialize an existing one
   log        Show commit logs
   merge      Join two or more development histories together
   mv         Move or rename a file, a directory, or a symlink
   pull       Fetch from and merge with another repository or a local branch
   push       Update remote refs along with associated objects
   rebase     Forward-port local commits to the updated upstream head
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG

とりあえず正常に動く、かな。