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
网友评论