YAMAGUCHI::weblog

海水パンツとゴーグルで、巨万の富を築きました。カリブの怪物、フリーアルバイター瞳です。

MacPortsを使ってVim7.xをインストールする

動機

最近は様々な環境を触ってるけれど、Emacsがインストールされていない/できないことがよくあるので、この辺でviに慣れておこうと思って身の回りのvi環境を整えようと思ったから。

方法

MacPortsのローカルレポジトリの作成
$ sudo mkdir /opt/localports
$ cd /opt/localports
$ sudo mkdir `ls -F1 \
/opt/local/var/macports/sources/rsync.macports.org/release/ports/ | \
grep '\/$'`

下記のようにsource.confを設定。

$ sudo vi /opt/local/etc/macports/source.conf
#  To get the ports tree from the master MacPorts server in California, USA use:
#      rsync://rsync.macports.org/release/ports/
#  To get it from the mirror in Trondheim, Norway use:
#      rsync://trd.no.rsync.macports.org/release/ports/
#  A current list of mirrors is available at http://trac.macports.org/wiki/Mirrors
file:///opt/localports
rsync://rsync.macports.org/release/ports/ [default]
まずはデフォルトの状態でのパッケージを確認
$ sudo port selfupdate

MacPorts base version 1.700 installed
Downloaded MacPorts base version 1.710
...

$ port version
Version: 1.710

$ port search vim
ctags @5.7 (devel)    Reimplementation of ctags(1)
hs-plugins @20050407 (devel)    A plugin library for Haskell
MacVim @7.2.snapshot44 (editors)    MacVim is a GUI version of vim for Mac OS X
p5-text-vimcolor @0.11 (perl)    syntax color text in HTML or XML using Vim.
txt2regex @0.8 (sysutils)    Converts human sentences to regexes
vim @7.2.148 (editors)    Vi "workalike" with many additional features
vim-app @7.2.148 (editors)    Vim.app is a GUI version of the famous editor vim.
vim2html @1.46 (textproc)    vim2html converts any Vim-editable file into well-formed HTML
yi @0.1.0 (editors)    the extensible Yi text editor

Found 9 ports.

$ port variants vim
vim has the variants:
        athena: Build GUI version using Athena widgets
        gtk1: Build GUI version using GTK 1.x widgets
        gtk2: Build GUI version using GTK 2.x widgets
        motif: Build GUI version with Motif widgets
        tiny: Build tiny feature set
        small: Build small feature set
        big: Build big feature set
        huge: Build huge feature set
        xim: Build with support for X Input Method
        perl: Enable Perl scripting
        python: Compatibility variant, requires +python25
        python25: Enable Python scripting
        python26: Enable Python scripting
        ruby: Enable Ruby scripting
        tcl: Enable Tcl scripting
        cscope: Enable source code browsing with cscope
        nls: National Language Support
        puredarwin: Platform variant, do not select manually
        universal: Build for multiple architectures
PrivatePortfileを設定

上記のPrivatePortfileをダウンロード、展開しportindexで追加。

$ tar xjf macvim.20090410.0.tbz2
$ tar xjf vim-app.7.2.147.2.tbz2
$ sudo portindex
Creating software index in /opt/privateportfile
Adding port editors/macvim
Adding port editors/vim-app

Total number of ports parsed:   2 
Ports successfully parsed:      2        
Ports failed:                   0

あらためてportsを確認。

$ port search vim
Warning: Can't open index file for source: file:///opt/localports
Warning: Can't open index file for source: file:///opt/localports
Warning: Can't open index file for source: file:///opt/localports
ctags @5.7 (devel)    Reimplementation of ctags(1)
...

あれ?なんかエラーが出てる。なんだこのエラー…

仕方なくデフォルトでインストール
$ sudo port install vim@7.2.148_0+huge+nls+python+python25+cscope     
--->  Fetching ctags
--->  Attempting to fetch ctags-5.7.tar.gz from http://downloads.sourceforge.net/ctags
--->  Verifying checksum(s) for ctags
--->  Extracting ctags
--->  Configuring ctags
--->  Building ctags
--->  Staging ctags into destroot
--->  Installing ctags @5.7_0
--->  Activating ctags @5.7_0
--->  Cleaning ctags
--->  Fetching vim
--->  Attempting to fetch 7.2.001-100.gz from http://trd.no.distfiles.macports.org/vim72
--->  Attempting to fetch 7.2.101 from http://trd.no.distfiles.macports.org/vim72
--->  Attempting to fetch 7.2.102 from http://trd.no.distfiles.macports.org/vim72
...
--->  Attempting to fetch 7.2.146 from http://trd.no.distfiles.macports.org/vim72
--->  Attempting to fetch 7.2.147 from http://trd.no.distfiles.macports.org/vim72
--->  Attempting to fetch 7.2.148 from http://trd.no.distfiles.macports.org/vim72
--->  Attempting to fetch 7.2.148 from http://ftp.vim.org/pub/vim/patches/7.2
--->  Attempting to fetch vim-7.2.tar.bz2 from http://trd.no.distfiles.macports.org/vim72
--->  Attempting to fetch vim-7.2-extra.tar.gz from http://trd.no.distfiles.macports.org/vim72
--->  Attempting to fetch vim-7.2-lang.tar.gz from http://trd.no.distfiles.macports.org/vim72
--->  Verifying checksum(s) for vim
--->  Extracting vim
--->  Applying patches to vim
--->  Configuring vim
--->  Building vim
--->  Staging vim into destroot
--->  Installing vim @7.2.148_0+cscope+huge+nls+python+python25
--->  Activating vim @7.2.148_0+cscope+huge+nls+python+python25
--->  Cleaning vim