|
如果你习惯了使用linux里边的apt-get,那么你一定要在你的mac里安装MacPorts。以下是转载过来的关于这个软件的简介和安装步骤:

MacPorts简介
MacPorts,曾经叫做DarwinPorts,是一个软件包管理系统,用来简化Mac OS X和Darwin操作系统上软件的安装。它是一个用来简化自由软件/开放源代码软件的安装的自由/开放源代码项目,与Fink和BSD类ports套件的目标和功能类似。跟BSD中的ports道理一样。MacPorts就像apt-get、yum一样,可以快速安装些软件。
MacPorts下载与安装
一.通过(.pkg)安装: Mac OS X Package (.pkg) Installer
访问官方网站: http://www.macports.org/install.php
http://distfiles.macports.org/MacPorts/MacPorts-2.1.1-10.7-Lion.pkg
二.通过(Source)安装MacPorts:Source Installation
1.cd到Downloads/目录下wget下载 MacPorts-2.1.1.tar.gz
输入: wget https://distfiles.macports.org/MacPorts/MacPorts-2.1.1.tar.gz

2.解压 MacPorts-2.1.1.tar.gz 输入: tar zxvf MacPorts-2.1.1.tar.gz (tar jxvf MacPorts2.1.1.tar.bz2)

3.cd到解压到的目录MacPorts-2.1.1输入: ./configure && make && sudo make install 安装

中间提示输入密码完成安装!
7.然后将/opt/local/bin和/opt/local/sbin添加到$PATH搜索路径中
编辑/etc/profile文件 $ sudo vim /etc/profile (特许编辑,强制保存退出 wq!)文件最后加上下面两句
1
2
| [color=#800080 !important]export [color=#000000 !important]PATH[color=#006fe0 !important]=[color=#006fe0 !important]/[color=#000000 !important]opt[color=#006fe0 !important]/[color=#000000 !important]local[color=#006fe0 !important]/[color=#000000 !important]bin[color=#006fe0 !important]:[color=#333333 !important]$[color=#800080 !important]PATH
[color=#800080 !important]export [color=#000000 !important]PATH[color=#006fe0 !important]=[color=#006fe0 !important]/[color=#000000 !important]opt[color=#006fe0 !important]/[color=#000000 !important]local[color=#006fe0 !important]/[color=#000000 !important]sbin[color=#006fe0 !important]:[color=#333333 !important]$[color=#000000 !important]PATH
|
MacPorts使用
1.Mac Port中第三方软件下载包存放的默认路径是:/opt/local/var/macports/distfiles/
为了提高安装速度,可以在安装新port时直接将此目录下的文件拷贝到新的Mac Port相同的目录中就可以避免Port去网上下载。
2.使用Mac Port前应该首先更新Port的index
输入: $ sudo port -v selfupdate (强烈推荐第一次运行的时候使用-v参数,显示详细的更新过程)

3.查看Mac Port中当前可用的软件包及其版本 输入: $ port list

4.查看有更新的软件以及版本 输入: $ port outdated

5.升级可以更新的软件 输入: $ sudo port upgrade outdated

6.在Mac Port搜索需要安装的软件包 输入: $ port search maven
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| [color=#000000 !important]HuiMinmatoMacBook[color=#006fe0 !important]-[color=#000000 !important]Pro[color=#006fe0 !important]:[color=#800080 !important]Downloads [color=#000000 !important]zikercn[color=#333333 !important]$[color=#006fe0 !important] [color=#800080 !important]port [color=#800080 !important]search [color=#800080 !important]maven
[color=#000000 !important]maven[color=#006fe0 !important] [color=#333333 !important]@[color=#ce0000 !important]1.0.2[color=#006fe0 !important] [color=#333333 !important]([color=#000000 !important]java[color=#333333 !important],[color=#006fe0 !important] [color=#000000 !important]devel[color=#333333 !important])
[color=#006fe0 !important] [color=#800080 !important]stub [color=#000000 !important]port[color=#333333 !important],[color=#006fe0 !important] [color=#800080 !important]use [color=#800080 !important]maven1 [color=#800080 !important]instead
[color=#000000 !important]maven[color=#006fe0 !important]-[color=#000000 !important]ant[color=#006fe0 !important]-[color=#000000 !important]tasks[color=#006fe0 !important] [color=#333333 !important]@[color=#ce0000 !important]2.1.3[color=#006fe0 !important] [color=#333333 !important]([color=#000000 !important]devel[color=#333333 !important],[color=#006fe0 !important] [color=#000000 !important]java[color=#333333 !important])
[color=#006fe0 !important] [color=#800080 !important]Use [color=#800080 !important]many [color=#800080 !important]of [color=#000000 !important]Maven'[color=#000000 !important]s[color=#006fe0 !important] [color=#800080 !important]artifact [color=#800080 !important]handling [color=#800080 !important]features [color=#800080 !important]from [color=#000000 !important]Ant[color=#333333 !important].
[color=#000000 !important]maven1[color=#006fe0 !important] [color=#333333 !important]@[color=#ce0000 !important]1.1[color=#006fe0 !important] [color=#333333 !important]([color=#000000 !important]java[color=#333333 !important],[color=#006fe0 !important] [color=#000000 !important]devel[color=#333333 !important])
[color=#006fe0 !important] [color=#000000 !important]A[color=#006fe0 !important] [color=#000000 !important]java[color=#006fe0 !important]-[color=#800080 !important]based [color=#800080 !important]build [color=#800080 !important]and [color=#800080 !important]project [color=#800080 !important]management [color=#000000 !important]environment[color=#333333 !important].
[color=#000000 !important]maven2[color=#006fe0 !important] [color=#333333 !important]@[color=#ce0000 !important]2.2.1[color=#006fe0 !important] [color=#333333 !important]([color=#000000 !important]java[color=#333333 !important],[color=#006fe0 !important] [color=#000000 !important]devel[color=#333333 !important])
[color=#006fe0 !important] [color=#000000 !important]A[color=#006fe0 !important] [color=#000000 !important]java[color=#006fe0 !important]-[color=#800080 !important]based [color=#800080 !important]build [color=#800080 !important]and [color=#800080 !important]project [color=#800080 !important]management [color=#000000 !important]environment[color=#333333 !important].
[color=#000000 !important]maven3[color=#006fe0 !important] [color=#333333 !important]@[color=#ce0000 !important]3.0.4[color=#006fe0 !important] [color=#333333 !important]([color=#000000 !important]java[color=#333333 !important],[color=#006fe0 !important] [color=#000000 !important]devel[color=#333333 !important])
[color=#006fe0 !important] [color=#000000 !important]A[color=#006fe0 !important] [color=#000000 !important]java[color=#006fe0 !important]-[color=#800080 !important]based [color=#800080 !important]build [color=#800080 !important]and [color=#800080 !important]project [color=#800080 !important]management [color=#000000 !important]environment[color=#333333 !important].
[color=#000000 !important]maven_select[color=#006fe0 !important] [color=#333333 !important]@[color=#ce0000 !important]0.3[color=#006fe0 !important] [color=#333333 !important]([color=#000000 !important]sysutils[color=#333333 !important])
[color=#006fe0 !important] [color=#800080 !important]common [color=#800080 !important]files [color=#800080 !important]for [color=#800080 !important]selecting [color=#800080 !important]default [color=#800080 !important]Maven [color=#800080 !important]version
[color=#000000 !important]Found[color=#006fe0 !important] [color=#ce0000 !important]6[color=#006fe0 !important] [color=#000000 !important]ports[color=#333333 !important].
|
7.搜索到需要安装的软件包之后,如何查看具体的软件包的内容和说明
输入: $ port info maven3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| [color=#000000 !important]maven3[color=#006fe0 !important] [color=#333333 !important]@[color=#ce0000 !important]3.0.4[color=#006fe0 !important] [color=#333333 !important]([color=#000000 !important]java[color=#333333 !important],[color=#006fe0 !important] [color=#800080 !important]devel[color=#333333 !important])
[color=#000000 !important]Description[color=#006fe0 !important]:[color=#006fe0 !important] [color=#800080 !important]Maven [color=#000000 !important]is[color=#006fe0 !important] [color=#000000 !important]a[color=#006fe0 !important] [color=#800080 !important]Java [color=#800080 !important]project [color=#800080 !important]management [color=#800080 !important]and [color=#800080 !important]project
[color=#800080 !important] [color=#800080 !important]comprehension [color=#000000 !important]tool[color=#333333 !important].[color=#006fe0 !important] [color=#800080 !important]Maven [color=#800080 !important]is [color=#800080 !important]based [color=#800080 !important]on [color=#800080 !important]the [color=#800080 !important]concept [color=#000000 !important]of[color=#006fe0 !important] [color=#000000 !important]a
[color=#006fe0 !important] [color=#800080 !important]project [color=#800080 !important]object [color=#004ed0 !important]model[color=#006fe0 !important] [color=#333333 !important]([color=#000000 !important]POM[color=#333333 !important])[color=#006fe0 !important] [color=#800080 !important]in [color=#800080 !important]that [color=#800080 !important]all [color=#800080 !important]the [color=#800080 !important]artifacts
[color=#800080 !important] [color=#800080 !important]produced [color=#800080 !important]by [color=#800080 !important]Maven [color=#000000 !important]are[color=#006fe0 !important] [color=#000000 !important]a[color=#006fe0 !important] [color=#800080 !important]result [color=#800080 !important]of [color=#000000 !important]consulting[color=#006fe0 !important] [color=#000000 !important]a[color=#006fe0 !important] [color=#800080 !important]well
[color=#800080 !important] [color=#800080 !important]defined [color=#800080 !important]model [color=#800080 !important]for [color=#800080 !important]your [color=#000000 !important]project[color=#333333 !important].[color=#002d7a !important]Builds[color=#333333 !important],[color=#006fe0 !important] [color=#000000 !important]documentation[color=#333333 !important],
[color=#006fe0 !important] [color=#800080 !important]source [color=#000000 !important]metrics[color=#333333 !important],[color=#006fe0 !important] [color=#800080 !important]and [color=#800080 !important]source [color=#000000 !important]cross[color=#006fe0 !important]-[color=#800080 !important]references [color=#800080 !important]are [color=#800080 !important]all
[color=#800080 !important] [color=#800080 !important]controlled [color=#800080 !important]by [color=#800080 !important]your [color=#000000 !important]POM[color=#333333 !important].[color=#006fe0 !important] [color=#000000 !important]Maven[color=#006fe0 !important] [color=#ce0000 !important]3[color=#006fe0 !important] [color=#800080 !important]aims [color=#800080 !important]to [color=#800080 !important]ensure [color=#800080 !important]backward
[color=#800080 !important] [color=#800080 !important]compatibility [color=#800080 !important]with [color=#000000 !important]Maven[color=#006fe0 !important] [color=#ce0000 !important]2[color=#333333 !important],[color=#006fe0 !important] [color=#800080 !important]improve [color=#000000 !important]usability[color=#333333 !important],[color=#006fe0 !important] [color=#800080 !important]increase
[color=#800080 !important] [color=#000000 !important]performance[color=#333333 !important],[color=#006fe0 !important] [color=#800080 !important]allow [color=#800080 !important]safe [color=#000000 !important]embedding[color=#333333 !important],[color=#006fe0 !important] [color=#800080 !important]and [color=#800080 !important]pave [color=#800080 !important]the [color=#800080 !important]way [color=#800080 !important]to
[color=#800080 !important] [color=#800080 !important]implement [color=#800080 !important]many [color=#800080 !important]highly [color=#800080 !important]demanded [color=#000000 !important]features[color=#333333 !important].
[color=#000000 !important]Homepage[color=#006fe0 !important]:[color=#006fe0 !important] [color=#000000 !important]http[color=#006fe0 !important]:[color=#ff8000 !important]//maven.apache.org/
[color=#000000 !important]Build[color=#006fe0 !important] [color=#000000 !important]Dependencies[color=#006fe0 !important]:[color=#006fe0 !important] [color=#800080 !important]kaffe
[color=#000000 !important]Runtime[color=#006fe0 !important] [color=#000000 !important]Dependencies[color=#006fe0 !important]:[color=#006fe0 !important] [color=#000000 !important]maven_select
[color=#000000 !important]Platforms[color=#006fe0 !important]:[color=#006fe0 !important] [color=#000000 !important]darwin
[color=#000000 !important]License[color=#006fe0 !important]:[color=#006fe0 !important] [color=#000000 !important]unknown
[color=#000000 !important]Maintainers[color=#006fe0 !important]:[color=#006fe0 !important] [color=#000000 !important]blair[color=#333333 !important]@[color=#000000 !important]macports[color=#333333 !important].[color=#002d7a !important]org[color=#333333 !important],[color=#006fe0 !important] [color=#000000 !important]gk5885[color=#333333 !important]@[color=#000000 !important]kickstyle[color=#333333 !important].[color=#002d7a !important]net
|
8.查看即将安装的或者已经安装的软件包的依赖关系
输入: $ port deps maven3
1
2
3
| [color=#000000 !important]Full[color=#006fe0 !important] [color=#000000 !important]Name[color=#006fe0 !important]:[color=#006fe0 !important] [color=#000000 !important]maven3[color=#006fe0 !important] [color=#333333 !important]@[color=#ce0000 !important]3.0.4_0
[color=#000000 !important]Build[color=#006fe0 !important] [color=#000000 !important]Dependencies[color=#006fe0 !important]:[color=#006fe0 !important] [color=#800080 !important]kaffe
[color=#000000 !important]Runtime[color=#006fe0 !important] [color=#000000 !important]Dependencies[color=#006fe0 !important]:[color=#006fe0 !important] [color=#000000 !important]maven_select
|
9. 查看安装时允许客户定制的参数 输入: $ port variants maven3
1
| [color=#800080 !important]maven3 [color=#800080 !important]has [color=#800080 !important]no [color=#000000 !important]variants
|
10.查看了软件包的内容和说明,并确认确实要安装,则输入: $ sudo port install maven3
1
2
3
4
5
6
7
| [color=#800080 !important]To [color=#800080 !important]make [color=#000000 !important]maven[color=#006fe0 !important] [color=#ce0000 !important]3.0.4[color=#006fe0 !important] [color=#800080 !important]the [color=#800080 !important]default[color=#333333 !important],[color=#006fe0 !important] [color=#800080 !important]please [color=#800080 !important]run
[color=#800080 !important] [color=#800080 !important]sudo [color=#800080 !important]port [color=#000000 !important]select[color=#006fe0 !important] [color=#006fe0 !important]--[color=#800080 !important]set [color=#800080 !important]maven [color=#000000 !important]maven3
[color=#006fe0 !important]--[color=#006fe0 !important]-[color=#006fe0 !important]&[color=#000000 !important]gt[color=#333333 !important];[color=#006fe0 !important] [color=#800080 !important]Cleaning [color=#000000 !important]maven3
[color=#006fe0 !important]--[color=#006fe0 !important]-[color=#006fe0 !important]&[color=#000000 !important]gt[color=#333333 !important];[color=#006fe0 !important] [color=#800080 !important]Updating [color=#800080 !important]database [color=#000000 !important]of[color=#006fe0 !important] [color=#004ed0 !important]binaries[color=#006fe0 !important]:[color=#006fe0 !important] [color=#ce0000 !important]100.0[color=#006fe0 !important]%
[color=#006fe0 !important]--[color=#006fe0 !important]-[color=#006fe0 !important]&[color=#000000 !important]gt[color=#333333 !important];[color=#006fe0 !important] [color=#800080 !important]Scanning [color=#800080 !important]binaries [color=#800080 !important]for [color=#000000 !important]linking[color=#006fe0 !important] [color=#004ed0 !important]errors[color=#006fe0 !important]:[color=#006fe0 !important] [color=#ce0000 !important]100.0[color=#006fe0 !important]%
[color=#006fe0 !important]--[color=#006fe0 !important]-[color=#006fe0 !important]&[color=#000000 !important]gt[color=#333333 !important];[color=#006fe0 !important] [color=#800080 !important]No [color=#800080 !important]broken [color=#800080 !important]files [color=#000000 !important]found[color=#333333 !important].
|
11. 卸载已经用Mac Port安装的软件 输入: $ sudo port uninstall maven3
1
2
3
4
| [color=#006fe0 !important]--[color=#006fe0 !important]-[color=#006fe0 !important]&[color=#000000 !important]gt[color=#333333 !important];[color=#006fe0 !important] [color=#800080 !important]Deactivating [color=#000000 !important]maven3[color=#006fe0 !important] [color=#333333 !important]@[color=#ce0000 !important]3.0.4_0
[color=#006fe0 !important]--[color=#006fe0 !important]-[color=#006fe0 !important]&[color=#000000 !important]gt[color=#333333 !important];[color=#006fe0 !important] [color=#800080 !important]Cleaning [color=#000000 !important]maven3
[color=#006fe0 !important]--[color=#006fe0 !important]-[color=#006fe0 !important]&[color=#000000 !important]gt[color=#333333 !important];[color=#006fe0 !important] [color=#800080 !important]Uninstalling [color=#000000 !important]maven3[color=#006fe0 !important] [color=#333333 !important]@[color=#ce0000 !important]3.0.4_0
[color=#006fe0 !important]--[color=#006fe0 !important]-[color=#006fe0 !important]&[color=#000000 !important]gt[color=#333333 !important];[color=#006fe0 !important] [color=#800080 !important]Cleaning [color=#000000 !important]maven3
|
MacPorts卸载删除
1.卸载原有的MacPorts(如果你没有安装,直接跳过这一步,输入: $ port version 查看)
#原版使用MacPorts安装过的软件在/opt/local目录下,删除之前最好查看下,心里有个数.
1
2
3
4
5
6
7
8
9
10
11
12
| [color=#800080 !important]sudo [color=#000000 !important]port[color=#006fe0 !important] [color=#006fe0 !important]-[color=#000000 !important]f[color=#006fe0 !important] [color=#800080 !important]uninstall [color=#800080 !important]installed
[color=#800080 !important]sudo [color=#000000 !important]rm[color=#006fe0 !important] [color=#006fe0 !important]-[color=#000000 !important]rf[color=#006fe0 !important] [color=#333333 !important][[color=#006fe0 !important]/加下面的每条[color=#333333 !important]]
[color=#006fe0 !important]/[color=#000000 !important]opt[color=#006fe0 !important]/[color=#000000 !important]local[color=#006fe0 !important]
[color=#006fe0 !important]/[color=#000000 !important]Applications[color=#006fe0 !important]/[color=#000000 !important]DarwinPorts[color=#006fe0 !important]
[color=#006fe0 !important]/[color=#000000 !important]Applications[color=#006fe0 !important]/[color=#000000 !important]MacPorts[color=#006fe0 !important]
[color=#006fe0 !important]/[color=#000000 !important]Library[color=#006fe0 !important]/[color=#000000 !important]LaunchDaemons[color=#006fe0 !important]/[color=#000000 !important]org[color=#333333 !important].[color=#002d7a !important]macports[color=#333333 !important].[color=#006fe0 !important]*[color=#006fe0 !important]
[color=#006fe0 !important]/[color=#000000 !important]Library[color=#006fe0 !important]/[color=#000000 !important]Receipts[color=#006fe0 !important]/[color=#800080 !important]DarwinPorts[color=#006fe0 !important]*[color=#333333 !important].[color=#002d7a !important]pkg[color=#006fe0 !important]
[color=#006fe0 !important]/[color=#000000 !important]Library[color=#006fe0 !important]/[color=#000000 !important]Receipts[color=#006fe0 !important]/[color=#800080 !important]MacPorts[color=#006fe0 !important]*[color=#333333 !important].[color=#002d7a !important]pkg[color=#006fe0 !important]
[color=#006fe0 !important]/[color=#000000 !important]Library[color=#006fe0 !important]/[color=#000000 !important]StartupItems[color=#006fe0 !important]/[color=#000000 !important]DarwinPortsStartup[color=#006fe0 !important]
[color=#006fe0 !important]/[color=#000000 !important]Library[color=#006fe0 !important]/[color=#000000 !important]Tcl[color=#006fe0 !important]/[color=#000000 !important]darwinports1[color=#333333 !important].[color=#ce0000 !important]0[color=#006fe0 !important]
[color=#006fe0 !important]/[color=#000000 !important]Library[color=#006fe0 !important]/[color=#000000 !important]Tcl[color=#006fe0 !important]/[color=#000000 !important]macports1[color=#333333 !important].[color=#ce0000 !important]0[color=#006fe0 !important]
[color=#006fe0 !important]~[color=#006fe0 !important]/[color=#333333 !important].[color=#002d7a !important]macports
|
安装过程中你可能会遇到和我一样的问题:mac ports安装软件提示” Warning: xcodebuild exists but failed to execute”。
此文大部分内容转自:http://www.zikercn.com/node/8 |
|
|