作为Linux的忠实爱好者,真的是无法容忍一款没有命令行包管理工具的类unix操作系统,比如说Mac,但又割舍不下对苹果本子的喜爱,于是我决定使用第三方软件填补Mac在这一方面的缺失,搜索一番之后发现原来早就有此类开发项目存在,所以说生活在当下真是幸福,Mac平台下的第三方包管理工具主要有三款:Fink,Macports和HomeBrew,我自然不会放弃试用上面任何一款包管理工具,之前也提及过任何一款包管理工具提供的功能以及实现功能的机制都是类似的:
Mechanism: get resource from Remote source repository & provide dependency management of packages
Function: 1. search packages from remote side; 2. download/install/upgrade packages from remote side; 3. list packages installed and files of special package; 4. uninstall packages
上面是对包管理工具的essential function简要概括,下面分别安装三款工具作对比。
HomeBrew
HomeBrew使用ruby脚本作为安装程序,可见https://brew.sh
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
上述命令的意思是调用ruby解释器执行网址指定的install脚本,和直接用浏览器将网址定义的文件下载到本地然后ruby <file>相同的效果。
在terminal中敲入上述命令,在选项出敲击回车即可,部分回显信息摘录如下。
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following existing directories will be made group writable:
/usr/local/bin
==> The following existing directories will have their owner set to ftericsson:
/usr/local/bin
==> The following existing directories will have their group set to admin:
/usr/local/bin
==> The following new directories will be created:
/usr/local/Cellar
/usr/local/Homebrew
/usr/local/Frameworks
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/opt
/usr/local/sbin
/usr/local/share
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var
Press RETURN to continue or any other key to abort
可见HomeBrew默认安装路径是/usr/local/,brew命令在/usr/local/bin/brew,该命令为shell脚本。在HomeBrew的世界里formula的概念很重要,每个软件包都有对应的formula文件,文件为ruby脚本,大体描述了软件包的用处,下载地址,需要直接从homebrew bottle下载包(bottle do)还是从脚本定义的URL下载包,然后就是安装软件所需要的操作,包括compile,建立softlink和文件移动等。
localhost:Formula ftericsson$ cat /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/zzz.rb
class Zzz < Formula
desc "Command-line tool to put Macs to sleep"
homepage "https://github.com/Orc/Zzz"
url "https://github.com/Orc/Zzz/archive/v1.tar.gz"
sha256 "8c8958b65a74ab1081ce1a950af6d360166828bdb383d71cc8fe37ddb1702576"
head "https://github.com/Orc/Zzz.git"
bottle :unneeded
# No test is

本文对比了Mac平台上的三种包管理工具:HomeBrew、Fink和MacPorts。重点介绍了HomeBrew的安装、工作原理、软件架构以及卸载方法。HomeBrew使用Ruby脚本作为安装程序,并依赖GitHub进行更新和扩展。它通过Formula文件描述软件包的安装过程,提供便捷的包管理和软件安装。
最低0.47元/天 解锁文章
1061

被折叠的 条评论
为什么被折叠?



