mac # 安裝MacPorts

The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac operating system.

MacPorts,曾經叫做DarwinPorts,是一個軟件包管理系統,用來簡化Mac OS X和Darwin操作系統上軟件的安裝。它是一個用來簡化自由軟件/開放源代碼軟件的安裝的自由/開放源代碼項目,與Fink和BSD類ports套件的目標和功能類似。跟BSD中的ports道理一樣。
MacPorts就像apt-get、yum一樣,可以快速安裝些軟件。

$ git clone https://github.com/macports/macports-base.git
$ git checkout v2.5.3  
$ ./configure --enable-readline
$ make
$ sudo make install
$ make distclean

然后配置環境變量

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

成功后:

$ which port
/opt/local/bin/port

$ port
MacPorts 2.5.3
Entering shell mode... ("help" for help, "quit" to quit)
[Users/Private] > 

遇到問題及解決

  • Can't open index file for source
# port
MacPorts 2.5.3
Entering shell mode... ("help" for help, "quit" to quit)
[var/root] > install gdb-apple
Error: Port gdb-apple not found
[var/root] > 
[var/root] > search gdb
Warning: Can't open index file for source: rsync://rsync.macports.org/macports/release/tarballs/ports.tar
Error: search for name gdb failed: No index(es) found! Have you synced your port definitions? Try running 'port selfupdate'.
No match for gdb found

解決方法:
直接port selfupdate,會卡在下邊這個地方:

total size is 512  speedup is 6.56
MacPorts base version 2.5.3 installed,
MacPorts base version 2.5.3 downloaded.
--->  Updating the ports tree

怎么辦呢?

Edit $prefix/etc/macports/sources.conf, comment out the rsync entry, and add a new entry as follows:

#rsync://rsync.macports.org/release/ports/ [default]
http://www.macports.org/files/ports.tar.gz [default]

其中$prefix為port安裝的目錄,默認為/opt/local

# pwd
/opt/local/etc/macports

然后進行修改和selfupdate:

  cp sources.conf sources.conf_bck
  vim sources.conf_bck 
  mv sources.conf_bck sources.conf
  按照上文中修改為http://www.macports.org/files/ports.tar.gz [default]

  port -v selfupdate

結果如下:

# port -v selfupdate
--->  Updating MacPorts base sources using rsync

Willkommen auf dem RSYNC-server auf ftp.fau.de.
Nicht all unsere Mirror sind per rsync verfuegbar.

Welcome to the RSYNC daemon on ftp.fau.de.
Not all of our mirrors are available through rsync.


receiving file list ... done

sent 16 bytes  received 55 bytes  15.78 bytes/sec
total size is 85608448  speedup is 1205752.79

Willkommen auf dem RSYNC-server auf ftp.fau.de.
Nicht all unsere Mirror sind per rsync verfuegbar.

Welcome to the RSYNC daemon on ftp.fau.de.
Not all of our mirrors are available through rsync.


receiving file list ... done

sent 16 bytes  received 62 bytes  14.18 bytes/sec
total size is 512  speedup is 6.56
MacPorts base version 2.5.3 installed,
MacPorts base version 2.5.3 downloaded.
--->  Updating the ports tree
Synchronizing local ports tree from http://www.macports.org/files/ports.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   178  100   178    0     0    267      0 --:--:-- --:--:-- --:--:--   266
100 35.5M  100 35.5M    0     0  16428      0  0:37:47  0:37:47 --:--:-- 12470
x .gitattributes
x .github/
x .gitignore
x .mailmap
x .travis.yml
x LICENSE
x PortIndex_darwin_10_i386/

...

x PortIndex_darwin_12_i386/PortIndex.quick
x PortIndex_darwin_11_i386/PortIndex
x PortIndex_darwin_11_i386/PortIndex.quick
x PortIndex_darwin_10_i386/PortIndex
x PortIndex_darwin_10_i386/PortIndex.quick
x .github/PULL_REQUEST_TEMPLATE.md
--->  MacPorts base is already the latest version

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

References:

https://www.macports.org/install.php
https://guide.macports.org/#installing.macports.git
https://guide.macports.org/#installing.shell
https://blog.csdn.net/testcs_dn/article/details/73294078
https://www.cnblogs.com/8586/archive/2012/12/02/2797911.html

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容