Mac Portsをインストールするっ!


Xcodeがインストールされていることを確認

% ls -ld /Developer/Applications/Xcode.app
drwxrwxr-x  3 root  admin  102 Sep 29 08:39 /Developer/Applications/Xcode.app/
% gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

MacPorts をインストール

MacPortsのWebペイジ からdownload (http://distfiles.macports.org/MacPorts/) に飛び、 最新版(1.9.1)のdmgファイル(MacPorts-1.9.1-10.6-SnowLeopard.dmg)をダウンロードして、 インストール。 (自動で開始されない場合は、ダブルクリックすれば自動でインストーラーが実行されるはず)

PATHに/opt/local/binがあることを確認

bashの場合は以下で/opt/local/binおよび/opt/local/sbinが追加されていることを確認。

$ cat ~/.profile
…
# 
# Your previous .profile (if any) is saved as .profile.mpsaved 
# Setting the path for MacPorts. 
export PATH=/opt/local/bin:/opt/local/sbin:$PATH 

一応 sourceしておく。

$ source ~/.profile

また、tcsh等のcsh系の場合は、~/.cshrcに追加されていることを確認して、sourceしてrehash

% cat ~/.cshrc
…
##
# Your previous /Users/void/.cshrc file was backed up as /Users/void/.cshrc.macports-saved_2010-09-30_at_06:21:42
##

# MacPorts Installer addition on 2010-09-30_at_06:21:42: adding an appropriate PATH variable for use with MacPorts.
setenv PATH /opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
% source ~/.cshrc
% rehash

MacPorts をアップデート

念のため、selfupdateしておく

$ sudo port -d selfupdate
Password:
--->  Updating the ports tree
DEBUG: Synchronizing ports tree(s)
Synchronizing local ports tree from rsync://rsync.macports.org/release/ports/
DEBUG: /usr/bin/rsync -rtzv --delete-after '--exclude=/PortIndex*' rsync://rsync.macports.org/release/ports/ /opt/local/var/macports/sources/rsync.macports.org/release/ports
receiving file list ... done
./
databases/qdbm/
databases/qdbm/Portfile

sent 105 bytes  received 478037 bytes  86934.91 bytes/sec
total size is 26572348  speedup is 55.57
Creating port index in /opt/local/var/macports/sources/rsync.macports.org/release/ports
Adding port databases/qdbm

Total number of ports parsed:   0
Ports successfully parsed:      0
Ports failed:                   0
Up-to-date ports skipped:       7399

DEBUG: MacPorts sources location: /opt/local/var/macports/sources/rsync.macports.org/release/base
--->  Updating MacPorts base sources using rsync
receiving file list ... done

sent 36 bytes  received 6810 bytes  2738.40 bytes/sec
total size is 2879032  speedup is 420.54
MacPorts base version 1.9.1 installed,
DEBUG: Rebuilding and reinstalling MacPorts if needed
MacPorts base version 1.9.1 downloaded.
--->  MacPorts base is already the latest version
DEBUG: Setting MacPorts sources ownership to root

The ports tree has been updated. To upgrade your installed ports, you should run
  port upgrade outdated
$

MacPorts自体をアンインストールしたくなったら?

以下のようにやればいいそうです。(FAQ - MacPorts - Trac)


sudo rm -rf \
    /opt/local \
    /Applications/DarwinPorts \
    /Applications/MacPorts \
    /Library/LaunchDaemons/org.macports.* \
    /Library/Receipts/DarwinPorts*.pkg \
    /Library/Receipts/MacPorts*.pkg \
    /Library/StartupItems/DarwinPortsStartup \
    /Library/Tcl/darwinports1.0 \
    /Library/Tcl/macports1.0 \
    ~/.macports

return