首页 > 代码库 > macports 安装手记

macports 安装手记

起先是为了在mac上装gcc4.7,搜了半圈发现macports最方便。于是按照官方的介绍撸开了袖子干。

参见:https://guide.macports.org/chunked/installing.html

1.首先卸载了旧版本的macport

   sudo port -fp uninstall installed

 以及其他

    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

2. 然后开始安装,我选得是svn安装

$ mkdir -p /opt/mports$ cd /opt/mports$ svn checkout https://svn.macports.org/repository/macports/trunk$ cd /opt/mports/trunk/base$ ./configure --enable-readline$ make$ sudo make install$ make distclean

 

3. udpate, 这一步遇到一些困难,花了好些时间才解决

  由于直接update总是失败,将update改为本地 ,即修改 /opt/local/etc/macports/sources.conf,把最后 rsync 那行注掉,改成本地路径

#rsync://rsync.macports.org/release/tarballs/ports.tar [default]file:///opt/mports/trunk/dports [default]

   当执行完update命令:

 sudo port selfupdate

   有如下错误:

--->  Updating the ports treeSynchronizing local ports tree from file:///opt/mports/trunk/dportsUpdating .:svn: E175002: Unable to connect to a repository at URL https://svn.macports.org/repository/macports/trunksvn: E175002: OPTIONS of https://svn.macports.org/repository/macports/trunk: Server certificate verification failed: issuer is not trusted (https://svn.macports.org)Command failed: /usr/bin/svn update --non-interactive /opt/mports/trunk/dportsExit code: 1Syncing local Subversion ports tree failedError: Couldnt sync the ports tree: Synchronization of 1 source failedError: Follow http://guide.macports.org/#project.tickets to report a bug.Error: /opt/local/bin/port: port selfupdate failed: Couldnt sync the ports tree: Synchronization of 1 source failed

 

用了 port -d selfupdate debug 跟踪,发现是svn权限的问题。当update的时候,会invoke command “/usr/bin/svn update --non-interactive /opt/mports/trunk/dports”  黄色flag 表示执行update的时候和系统无及时交互,所以没机会存证书.

stackoverflows上一些老外也讨论过这个问题,参见

http://stackoverflow.com/questions/3147660/server-certificate-verification-failed-issuer-is-not-trusted

最后解决

First, tell subversion to use your proxy to connect to the server:If $prefix/var/macports/home/.subversion/servers doesnt exist, create it by copying the corresponding file from another user. (SVN automatically creates this file if it doesnt exist.)Edit the file and set a proxy for hosts at *.macports.org. Different proxy configurations require different sets of options here, but the file is pretty well commented, so it should be easy to figure out what you need. At a minimum youll need settings for http-proxy-host and http-proxy-port.Finally, if you want to use SVN over HTTPS to access the repository, youll need to tell SVN to trust the MacPorts signature. (SVN doesnt trust the authority that issued it, and port sync below invokes svn up with the --non-interactive flag, so you wont have the opportunity to accept the certificate then.)mkdir -p $prefix/var/macports/home/.subversion/auth/svn.ssl.serverAs a normal user, run svn ls https://svn.macports.org/repository/macports/trunk/dports/. When prompted, accept the certificate permanently.SVN will store the certificate in a file in the directory $HOME/.subversion/auth/svn.ssl.server. In that directory, find the file that contains the string "https://svn.macports.org" and copy it into $prefix/var/macports/home/.subversion/auth/svn.ssl.server.

一句话总结就是 将 $HOME/.subversion/auth/svn.ssl.server. 目录下含字段"https://svn.macports.org"的文件拷贝到 

/opt/local/var/macports/home/.subversion/auth/svn.ssl.server/

 

然后执行  port selfupdate

成功,over

macports 安装手记