文章转载至http://www.zikercn.com/node/8
星期四, 06/07/2012 - 19:02 — 张慧敏
MacPorts,以前叫做DarwinPorts,是一个软件包管理系统,用来简化Mac OS X和Darwin操作系统上软件的安装。它是一个用来简化自由软件/开放源码软件的安装的自由/开放源码项目,与Fink和BSD类ports套件的目标和功能类似。跟BSD中的ports道理一样。MacPorts就像apt-get、yum一样,能够高速安装些软件。
一.通过(.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 安装
中间提示输入password完毕安装!
7.然后将/opt/local/bin和/opt/local/sbin加入到$PATH搜索路径中
编辑/etc/profile文件 $ sudo vim /etc/profile (特许编辑,强制保存退出 wq!)文件最后加上以下两句
1
2
|
export
PATH=
/opt/local/bin
:$PATH
export
PATH=
/opt/local/sbin
:$PATH
|
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
|
HuiMinmatoMacBook-Pro:Downloads zikercn$ port search maven
maven @1.0.2 (java, devel)
stub port, use maven1 instead
maven-ant-tasks @2.1.3 (devel, java)
Use many of Maven's artifact handling features from Ant.
maven1 @1.1 (java, devel)
A java-based build and project management environment.
maven2 @2.2.1 (java, devel)
A java-based build and project management environment.
maven3 @3.0.4 (java, devel)
A java-based build and project management environment.
maven_select @0.3 (sysutils)
common files
for
selecting default Maven version
Found 6 ports.
|
7.搜索到须要安装的软件包之后,怎样查看详细的软件包的内容和说明
输入: $ port info maven3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
maven3 @3.0.4 (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 3 aims to ensure backward
compatibility with Maven 2, improve usability, increase
performance, allow safe embedding, and pave the way to
implement many highly demanded features.
Homepage: http:
//maven
.apache.org/
Build Dependencies: kaffe
Runtime Dependencies: maven_select
Platforms: darwin
License: unknown
Maintainers: [email protected], [email protected]
|
8.查看即将安装的或者已经安装的软件包的依赖关系
输入: $ port deps maven3
1
2
3
|
Full Name: maven3 @3.0.4_0
Build Dependencies: kaffe
Runtime Dependencies: maven_select
|
9. 查看安装时同意客户定制的參数 输入: $ port variants maven3
1
|
maven3 has no variants
|
10.查看了软件包的内容和说明,并确认确实要安装,则输入: $ sudo port install maven3
1
2
3
4
5
6
7
|
To
make
maven 3.0.4 the default, please run
sudo
port
select
--
set
maven maven3
---> Cleaning maven3
---> Updating database of binaries: 100.0%
---> Scanning binaries
for
linking errors: 100.0%
---> No broken files found.
|
11. 卸载已经用Mac Port安装的软件 输入: $ sudo port uninstall maven3
1
2
3
4
|
---> Deactivating maven3 @3.0.4_0
---> Cleaning maven3
---> Uninstalling maven3 @3.0.4_0
---> Cleaning maven3
|
1.卸载原有的MacPorts(假设你没有安装,直接跳过这一步,输入: $ port version 查看)
#原版使用MacPorts安装过的软件在/opt/local文件夹下,删除之前最好查看下,心里有个数.
1
2
3
4
5
6
7
8
9
10
11
12
|
sudo
port -f 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
|