开发利器之Mac下的MacPorts

来源:互联网 发布:遇到蛇怎么办 知乎 编辑:程序博客网 时间:2024/06/05 09:35

  今天笔者推荐Mac开发者们安装的一个利器-----MacPorts。这是一个开源的工程,旨在设计一个简单易用的系统帮助大家在命令行,X11 或 Aqua编译、安装和升级基于开源的软件。有了它,开发者就能更轻松了。

       下面是官方网站下载地址:http://www.macports.org/install.php,根据自己的Mac操作系统环境点击如下图红框内的相应的链接:


  下载之后,双击按照提示安装完后打开终端,输入:sudo port -v selfupdate,更新MacPorts到最新版本。


恭喜,你可以享受他的便利了。

在终端输入:man port 回车,然后按方向键上或下,你可以浏览到一些命令的帮助信息:




下面简单介绍几条命令:

安装软件:sudo port install Name

卸载软件:sudo port uninstall Name 使用参数-f可以强制删除它所依赖的库  port -f uninstall Name 

搜索软件:port search Name

查看软件:port info Name

查看软件的依赖库:port deps Name

安装软件前查看软件版本:port variants Name

关于select,例子如下

           

port select --list python  //列出python的可用版本port select --show gcc   //显示当前的gcc的版本port select --set gcc mp-gcc44  //改变当前gcc的版本

激活已经安装的软件:port activate Name

更新软件:

     Upgrade the installed portname.  For example:           port upgrade vim     To upgrade all installed ports:           port upgrade installed     To upgrade portname and the ports that depend on it:           port -R upgrade libiconv     To force an upgrade (rebuild) use:           port upgrade --force vim     To upgrade portname without following its dependencies, use -n.  For exam-     ple:           port -n upgrade wireshark

清除软件产生的垃圾:


port clean --dist vim  //清理分配的文件port clean --logs vim  //清理日志文件port clean --all vim   //清理所有产生的文件,包括分配的文件和日志文件

MacPorts自身:sudo port selfupdate

一些编译的命令(懒得一一介绍,直接贴出英文文档):

DEVELOPER TARGETS     The targets that are often used by Port developers are intended to provide     access to the different phases of a Port's build process:   dir     Displays the path to the directory containing portname.   work     Displays the path to the work directory for portname.   cd     Changes the current working directory to the one containing portname.     Only useful in interactive mode.   file     Displays the path to the Portfile for portname.   url     Displays the URL for the path of the given portname, which can be passed     as port-url   cat     Concatenates and prints the contents of Portfile on stdout.   edit     Opens Portfile with your default editor specified in your shell's environ-     ment variable.     You can also use the --editor flag on the command line to specify an     alternative editor. For example:           port edit --editor nano apache2   fetch     Fetches the distribution files required to build portname.   checksum     Compute the checksums of the distribution files for portname, and compare     them to the checksums listed in Portfile.   extract     Extracts the distribution files for portname.   patch     Applies any required patches to portname's extracted distribution files.   configure     Runs any configure process for portname.   build     Build portname.   destroot     Installs portname to a temporary directory.   test     Tests portname.   lint     Verifies Portfile for portname.  To nitpick about whitespace and patchfile     names, use --nitpick.   distcheck     Check if the distfiles haven't changed and can be fetched.   distfiles     Display each distfile, its checksums, and the URLs used to fetch it.   livecheck     Check if the software hasn't been updated since the Portfile was last mod-     ified.

打包的命令:

PACKAGING TARGETS     There are also targets for producing installable packages of ports:   pkg     Creates an OS X installer package of portname.   mpkg     Creates an OS X installer metapackage of portname and its dependencies.   dmg     Creates an internet-enabled disk image containing an OS X package of     portname.   mdmg     Creates an internet-enabled disk image containing an OS X metapackage of     portname and its dependencies.   rpm     Creates an RPM binary package of portname, similar to a tgz "archive".   srpm     Creates a SRPM source package of portname, similar to a xar "portpkg".   dpkg     Creates a DEB binary package of portname.

    更具体的介绍,可以点击官网的文档查看,链接:http://guide.macports.org/

    好了,到此介绍结束!希望这能帮助快速学会使用该开发工具。

	
				
		
原创粉丝点击