Mac Port简介和基本使用方法

熟悉开源系统的人可能就知道port(包管理的一种方式)是BSD世界里的东西,而Mac Port即是为开源项目而诞生的.你可以利用命令行安装很多开源库的软件.Mac Port其实类似debian的apt, redhat里的yum.

1.Mac Port的简介:

  • Mac Port 官方网站:http://www.macports.org/
  • Mac Port的下载地址  http://www.macports.org/install.php
  • Mac Port的说明文档  http://guide.macports.org/
  • Mac Port安装方式:DMG安装方式不需要介绍,唯一需要主要的是在最后的过程中会一直出现剩余1分钟,运行脚本,这就是由于网络的原因,可以尝试多试几次,如果还不能成功的话,只能选择从源码,如果不需要更改任何东西的话,直接./configure && make && sudo make install就行了。
  • Mac Port中第三方软件下载包存放的默认路径是:/opt/local/var/macports/distfiles/ 。为了提高安装速度,可以在安装新port时直接将此目录下的文件拷贝到新的Mac Port相同的目录中就可以避免Port去网上下载。

2.Mac Port的基本使用方法:

  • 使用Mac Port前应该首先更新Port的index :sudo port selfupdate
  • $ sudo port selfupdate 
    Password: 
    Warning: port definitions are more than two weeks old, consider using selfupdate 
    --->  Updating the ports tree 
    --->  Updating MacPorts base sources using rsync 
    MacPorts base version 1.9.2 installed, 
    MacPorts base version 1.9.2 downloaded. 
    --->  MacPorts base is already the latest version 

    The ports tree has been updated. To upgrade your installed ports, you should run 
      port upgrade outdated
     
  • 查看Mac Port中当前可用的软件包及其版本 : port list
  • $ port list 
    rabbitmq-server                @2.4.0          net/rabbitmq-server 
    AppHack                        @1.1            aqua/AppHack 
    AppKiDo                        @0.985          aqua/AppKiDo 
    AquaLess                       @1.6            aqua/AquaLess 
    ArpSpyX                        @1.1            aqua/ArpSpyX 
    AssignmentTrackerX             @2.0beta3.1     aqua/AssignmentTrackerX 
    BigSQL                         @1.0            aqua/BigSQL 
    BiggerSQL                      @1.3.9          aqua/BiggerSQL 
    Books                          @3.2.5c         aqua/Books 
    ......
  • 搜索需要安装的软件包:port search XXX
  • $ port search maven 
    maven @1.0.2 (java, devel) 
        A java-based build and project management environment. 

    maven-ant-tasks @2.0.10 (devel, java) 
        Use many of Maven's artifact handling features from Ant. 

    maven2 @2.2.1 (java, devel) 
        A java-based build and project management environment. 

    maven3 @3.0.3 (java, devel) 
        A java-based build and project management environment. 

    maven_select @0.3 (sysutils) 
        Switch the default Maven java build tool 

    Found 5 ports.
  • 查看具体的软件包的内容和说明:port info XXX
  • $ port info maven2 
    maven2 @2.2.1, Revision 3 (java, devel) 

    Description:          Maven is a Java project management and project comprehension tool. Maven is based on the concept of a 
                          project object model (POM) in that all the artifacts produced by Maven are a result of consulting a 
                          well defined model for your project.Builds, documentation, source metrics, and source cross-references 
                          are all controlled by your POM. Maven 2.0 is a complete rewrite of Maven 1.0 and as such is better 
                          organized, faster and easier to use. 
    Homepage:             http://maven.apache.org/ 

    Build Dependencies:   kaffe 
    Library Dependencies: maven_select 
    Platforms:            darwin 
    License:              unknown 
    Maintainers:          blair@macports.org, gk5885@kickstyle.net
  • 查看即将安装的或者已经安装的软件包的依赖关系:port deps XXX
  • $ port deps maven2 
    Full Name: maven2 @2.2.1_3 
    Build Dependencies:   kaffe 
    Library Dependencies: maven_select
  • 查看了软件包的内容和说明,并确认确实要安装:sudo port install XXX
  • 安装完毕之后,清除安装时产生的临时文件 :sudo port clean --all XXX
  • 卸载已经用Mac Port安装的软件 :sudo port uninstall XXX