這是一套 ports 的管理,有用過 FreeBSD 應該就不陌生了,簡單的來說就像 linux 的 apt 或 yum 套件管理工具,透過他可以幫你安裝程式。沒想到我現在才開始用,在這之前都一直使用 tarball 安裝法,好像有點蠢 XD
安裝完 MacPorts 後,使用前需要更新一下 ports tree (類似軟體清單):
$ sudo port -v selfupdate
如果很順利,大概會有類似的訊息:
---> Updating the ports tree
Synchronizing local ports tree from rsync://rsync.macports.org/release/ports/
receiving file list ... done
./
sent 59 bytes received 515550 bytes 114579.78 bytes/sec
total size is 28438585 speedup is 55.16
Creating port index in /opt/local/var/macports/sources/rsync.macports.org/release/ports
Total number of ports parsed: 0
Ports successfully parsed: 0
Ports failed: 0
Up-to-date ports skipped: 7918
---> Updating MacPorts base sources using rsync
receiving file list ... done
sent 36 bytes received 6858 bytes 2757.60 bytes/sec
total size is 2889184 speedup is 419.09
MacPorts base version 1.9.2 installed,
MacPorts base version 1.9.2 downloaded.
Synchronizing local ports tree from rsync://rsync.macports.org/release/ports/
receiving file list ... done
./
sent 59 bytes received 515550 bytes 114579.78 bytes/sec
total size is 28438585 speedup is 55.16
Creating port index in /opt/local/var/macports/sources/rsync.macports.org/release/ports
Total number of ports parsed: 0
Ports successfully parsed: 0
Ports failed: 0
Up-to-date ports skipped: 7918
---> Updating MacPorts base sources using rsync
receiving file list ... done
sent 36 bytes received 6858 bytes 2757.60 bytes/sec
total size is 2889184 speedup is 419.09
MacPorts base version 1.9.2 installed,
MacPorts base version 1.9.2 downloaded.
接下來要安裝軟體,就是需要用 sudo port install app ,如安裝 wget:
$ sudo port install wget
接著就會很自動地幫你安裝相依性環境、取得 wget 原始碼、編譯及安裝,就可以用 wget 指令囉。
關於 port 的使用,請 man port 來查看,常用的指令:
$ port installed (查看已安裝項目)
$ port search vim (尋找 vim 工具)
$ sudo port install app (安裝 app)
$ sudo port uninstall app (移除 app)
$ port search vim (尋找 vim 工具)
$ sudo port install app (安裝 app)
$ sudo port uninstall app (移除 app)
然而 MacPorts 預設採用 rsync 去取得 ports tree ,如果很不幸的使用環境是在防火牆後面,將導致 rsync 失敗,只好改用第二種方案,過程分為兩步驟:
- 使用 svn 取得 ports tree
- 使用 portindex 更新 ports tree
作法:
$ sudo mkdir -p /opt/local/var/macports/sources/svn.macports.org/trunk/dports
$ cd /opt/local/var/macports/sources/svn.macports.org/trunk/dports
$ sudo svn co http://svn.macports.org/repository/macports/trunk/dports/ .
$ cd /opt/local/var/macports/sources/svn.macports.org/trunk/dports
$ sudo svn co http://svn.macports.org/repository/macports/trunk/dports/ .
$ sudo vim opt/local/etc/macports/sources.conf
#rsync://rsync.macports.org/release/ports/ [default]
file:///opt/local/var/macports/sources/svn.macports.org/trunk/dports [default]
file:///opt/local/var/macports/sources/svn.macports.org/trunk/dports [default]
$ cd /opt/local/var/macports/sources/svn.macports.org/trunk/dports
$ sudo portindex
$ sudo portindex
如此一來就可以正常使用 MacPorts 安裝軟體。參考資料:http://guide.macports.org/#installing.macports.subversion 和 Using MacPorts behind a firewall。
如果哪天突然想移除 MacPorts 的話,可以透過以下指令移除透過 MacPorts 安裝的所有套件:
$ sudo port -f uninstall installed
接著再用 port installed 查看就沒東西囉
沒有留言:
張貼留言