目 录CONTENT

文章目录

OS系列08-MacOS中的brew包管理器的安装方法

cplinux98
2022-08-30 / 0 评论 / 0 点赞 / 57 阅读 / 339 字 / 正在检测是否收录...

00:文章简介

本文介绍了MacOS中的brew包管理器的安装方法!

01:安装brew

国外的太慢,使用清华大学的源https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

1.1:安装xcode-select依赖

#命令行输入 
xcode-select --install

1.2:设置清华源变量

if [[ "$(uname -s)" == "Linux" ]]; then BREW_TYPE="linuxbrew"; else BREW_TYPE="homebrew"; fi
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/${BREW_TYPE}-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/${BREW_TYPE}-bottles"

1.3:使用清华源安装brew

# 从清华大学镜像下载安装脚本并安装 Homebrew / Linuxbrew 
git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install 
/bin/bash brew-install/install.sh

1.4:使用清华源安装brew替换现有仓库上游

git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

BREW_TAPS="$(brew tap)"
for tap in core cask{,-fonts,-drivers,-versions}; do
    if echo "$BREW_TAPS" | grep -qE "^homebrew/${tap}\$"; then
        git -C "$(brew --repo homebrew/${tap})" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git
        git -C "$(brew --repo homebrew/${tap})" config homebrew.forceautoupdate true
    else
        brew tap --force-auto-update homebrew/${tap} https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git
    fi
done

1.5:重新设置git仓库HEAD

brew update-reset
0

评论区