HOME BREW 是 MAC 或者 Linux 上非常流行的(特别是MACOS上)第三方软件包管理器
HOME BREW 部件:
该包管理器相关数据和安装的软件包均在:/opt/homebrew 目录下
HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles HOMEBREW_CELLAR=/opt/homebrew/Cellar HOMEBREW_PREFIX=/opt/homebrew HOMEBREW_REPOSITORY=/opt/homebrew INFOPATH=/opt/homebrew/share/info:
换源的时候重新设置环境变量并用 export 导出即可,参见软件源更换的相关部分
注意挂上互联网工具
export ALL_PROXY=socks5h://127.0.0.1:10808 export HTTP_PROXY=http://127.0.0.1:10809 export HTTPS_PROXY=http://127.0.0.1:10809
一般来说设置 ALL_PROXY 也就够了
一句话安装脚本
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
可以注意到安装需要 ruby 的支持,这个软件在 MAC 上已经有了,但是其他 *NIX 发行版上可能未必有,需要安装
有源码包和编译包,使用 brew install PKG-NAME
是源码包,使用 brew install PKG-NAME –cask
安装的是二进制包。一般不用管,只要使用Search搜索了出来,系统会提示软件在哪个 channel 里面,如果在 CASK 里面,安装时就使用 –cask
选项。
因为直接从GITHUB取数据,并且直接使用GITHUB REPO URL,所以不支持中文名,一些中文的软件可能要麻烦一点,可以参考:这个仓库查找对应中英文名称。
四个板斧
FROM:
部分History
并下载想要安装的历史版本的 .rb 文件,保存为:PKGNAME-$(VERSION).rb注:如果之前已经安装了,系统会提示你进行移除或者卸载
HOME BREW 安装的软件包保存在 /opt/home-brew
目录下
这个是可选项,有正常的互联网代理的话最好就不更换了。
HOME BREW 的软件源完全是依赖 GIT 来管理的,它会通过GIT仓库和远端源进行映射来设置软件的下载地址,BREW 使用的 repo
HOME: brew --repo HOME-CORE: brew --repo homebrew/core HOME-CASK: brew --repo homebrew/cask
查看软件源信息
brew config
# 查看 brew.git 当前源 $ cd "$(brew --repo)" && git remote -v origin https://github.com/Homebrew/brew.git (fetch) origin https://github.com/Homebrew/brew.git (push) # 查看 homebrew-core.git 当前源 $ cd "$(brew --repo homebrew/core)" && git remote -v origin https://github.com/Homebrew/homebrew-core.git (fetch) origin https://github.com/Homebrew/homebrew-core.git (push) # 修改 brew.git 为阿里源 $ git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git # 修改 homebrew-core.git 为阿里源 $ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git # zsh 替换 brew bintray 镜像 $ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc $ source ~/.zshrc # bash 替换 brew bintray 镜像 $ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile $ source ~/.bash_profile # 刷新源 $ brew update
# 替换各个源 $ git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git $ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git $ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git # zsh 替换 brew bintray 镜像 $ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc $ source ~/.zshrc # bash 替换 brew bintray 镜像 $ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile $ source ~/.bash_profile # 刷新源 $ brew update
# 替换各个源 $ git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git $ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git $ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git # zsh 替换 brew bintray 镜像 $ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc $ source ~/.zshrc # bash 替换 brew bintray 镜像 $ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile $ source ~/.bash_profile # 刷新源 $ brew update
# 重置 brew.git 为官方源 $ git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git # 重置 homebrew-core.git 为官方源 $ git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git # 重置 homebrew-cask.git 为官方源 $ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask # zsh 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置 $ vi ~/.zshrc # export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx # bash 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置 $ vi ~/.bash_profile # export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx # 刷新源 $ brew update