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


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

% ls -ld /Applications/Xcode.app
drwxr-xr-x  3 root  wheel  102 Aug  9 15:24 /Applications/Xcode.app/
% gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
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 (https://distfiles.macports.org/MacPorts/) に飛び、 最新版(2.2.0)のpkgファイル(MacPorts-2.2.0-10.8-MountainLion.pkg)をダウンロードして、 インストール。 (自動で開始されない場合は、ダブルクリックすれば自動でインストーラーが実行されるはず)

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_2013-08-12_at_10:13:56
##

# MacPorts Installer addition on 2013-08-12_at_10:13:56: 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:
DEBUG: Copying /Users/bribser003/Library/Preferences/com.apple.dt.Xcode.plist to /opt/local/var/macports/home/Library/Preferences
DEBUG: MacPorts sources location: /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
--->  Updating MacPorts base sources using rsync
receiving file list ... done

sent 36 bytes  received 69 bytes  42.00 bytes/sec
total size is 4925440  speedup is 46908.95
receiving file list ... done

sent 36 bytes  received 76 bytes  74.67 bytes/sec
total size is 512  speedup is 4.57
DEBUG: successful verification with key /opt/local/share/macports/macports-pubkey.pem
DEBUG: /usr/bin/tar -C /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/tmp -xf /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/base.tar
MacPorts base version 2.2.0 installed,
DEBUG: Rebuilding and reinstalling MacPorts if needed
MacPorts base version 2.2.0 downloaded.
--->  Updating the ports tree
Synchronizing local ports tree from rsync://rsync.macports.org/release/tarballs/ports.tar
DEBUG: /usr/bin/rsync -rtzv --delete-after  rsync://rsync.macports.org/release/tarballs/ports.tar /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
receiving file list ... done

sent 36 bytes  received 70 bytes  42.40 bytes/sec
total size is 53934080  speedup is 508812.08
DEBUG: /usr/bin/rsync -rtzv --delete-after  rsync://rsync.macports.org/release/tarballs/ports.tar.rmd160 /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
receiving file list ... done

sent 36 bytes  received 77 bytes  75.33 bytes/sec
total size is 512  speedup is 4.53
DEBUG: successful verification with key /opt/local/share/macports/macports-pubkey.pem
DEBUG: /usr/bin/tar -C /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/tmp -xf /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports.tar
Creating port index in /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports

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

--->  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