mirror of
https://github.com/tuna/mirror-web.git
synced 2025-12-25 20:32:46 +00:00
Update docs for Homebrew on ARM-based Macs
This commit is contained in:
parent
19ee3a8dd8
commit
5090294a8a
|
|
@ -4,13 +4,16 @@ layout: help
|
|||
mirrorid: homebrew
|
||||
---
|
||||
|
||||
## Homebrew/Linuxbrew 镜像使用帮助
|
||||
## Homebrew / Linuxbrew 镜像使用帮助
|
||||
|
||||
**注:该镜像是 Homebrew/Linuxbrew 源程序以及 formula/cask 索引的镜像(即 `brew update` 时所更新内容)。本镜像站同时提供相应的二进制预编译包的镜像,请参考 [Homebrew bottles 镜像使用帮助](https://{{ site.hostname }}/help/homebrew-bottles/) 和 [Linuxbrew bottles 镜像使用帮助](https://{{ site.hostname }}/help/linuxbrew-bottles/)。**
|
||||
**注:该镜像是 Homebrew / Linuxbrew 源程序以及 formula/cask 索引的镜像(即 `brew update` 时所更新内容)。本镜像站同时提供相应的二进制预编译包的镜像,请参考 [Homebrew bottles 镜像使用帮助](https://{{ site.hostname }}/help/homebrew-bottles/) 和 [Linuxbrew bottles 镜像使用帮助](https://{{ site.hostname }}/help/linuxbrew-bottles/)。**
|
||||
|
||||
### 首次安装 Homebrew / Linuxbrew
|
||||
|
||||
首先,需要确保系统中安装了 git 和 curl。其中 macOS 系统自带,而 Linux 用户安装 git 即可(curl 为 git 的依赖项会自动安装)。
|
||||
首先,需要确保系统中安装了 bash、git 和 curl,对于 macOS 用户需额外要求安装 Command Line Tools (CLT) for Xcode。
|
||||
|
||||
- 对于 macOS 用户,系统自带 bash、git 和 curl,在命令行输入 `xcode-select --install` 安装 CLT for Xcode 即可。
|
||||
- 对于 Linux 用户,系统自带 bash,仅需额外安装 git 即可(curl 为 git 的依赖项会自动安装)。
|
||||
|
||||
接着,在终端输入以下两行命令设置环境变量:
|
||||
|
||||
|
|
@ -23,15 +26,15 @@ export HOMEBREW_BOTTLE_DOMAIN="https://{{ site.hostname }}/homebrew-bottles"
|
|||
# export HOMEBREW_BOTTLE_DOMAIN="https://{{ site.hostname }}/linuxbrew-bottles"
|
||||
```
|
||||
|
||||
最后,在终端运行以下命令以安装 Homebrew/Linuxbrew:
|
||||
最后,在终端运行以下命令以安装 Homebrew / Linuxbrew:
|
||||
|
||||
```bash
|
||||
# 从本镜像下载安装脚本,修改其中的仓库源并安装 Homebrew/Linuxbrew
|
||||
# 从本镜像下载安装脚本,修改其中的仓库源并安装 Homebrew / Linuxbrew
|
||||
git clone --depth=1 https://{{ site.hostname }}/git/homebrew/install.git brew-install
|
||||
/bin/bash -c "$(sed 's|^BREW_REPO=.*$|BREW_REPO="https://{{ site.hostname }}/git/homebrew/brew.git"|g' brew-install/install.sh)"
|
||||
rm -rf brew-install
|
||||
|
||||
# 也可从 GitHub 获取官方安装脚本,修改其中的仓库源,运行以安装 Homebrew/Linuxbrew
|
||||
# 也可从 GitHub 获取官方安装脚本,修改其中的仓库源,运行以安装 Homebrew / Linuxbrew
|
||||
/bin/bash -c "$(
|
||||
curl -fsSL https://github.com/Homebrew/install/raw/master/install.sh |
|
||||
sed 's|^BREW_REPO=.*$|BREW_REPO="https://{{ site.hostname }}/git/homebrew/brew.git"|g'
|
||||
|
|
@ -40,27 +43,42 @@ rm -rf brew-install
|
|||
|
||||
这样在首次安装的时候也可以使用镜像。
|
||||
|
||||
_* Linux 用户需要注意,安装 Linuxbrew 后请将相关路径加入自己的环境变量中:_
|
||||
_* 安装成功后需将 brew 程序的相关路径加入到环境变量中:_
|
||||
|
||||
```bash
|
||||
test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)"
|
||||
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
||||
test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.bash_profile
|
||||
test -r ~/.profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.profile
|
||||
test -r ~/.zshrc && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.zshrc
|
||||
```
|
||||
- _以下针对基于 Apple Silicon CPU 设备上的 macOS 系统(命令行运行 `uname -m` 应输出 `arm64`)上的 Homebrew:_
|
||||
|
||||
_参考了 [https://docs.brew.sh/Homebrew-on-Linux](https://docs.brew.sh/Homebrew-on-Linux)。_
|
||||
```bash
|
||||
grep -qF '/opt/homebrew/bin' /etc/paths || sudo sed -i "" '1i \
|
||||
/opt/homebrew/bin
|
||||
' /etc/paths
|
||||
grep -qF '/opt/homebrew/share/man' /etc/manpaths || sudo sed -i "" '1i \
|
||||
/opt/homebrew/share/man
|
||||
' /etc/manpaths
|
||||
```
|
||||
|
||||
_对基于 Intel CPU 设备上的 macOS 系统(命令行运行 `uname -m` 应输出 `x86_64`)的用户可跳过本步。_
|
||||
|
||||
- _以下针对 Linux 系统上的 Linuxbrew:_
|
||||
|
||||
```bash
|
||||
test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)"
|
||||
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
||||
test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.bash_profile
|
||||
test -r ~/.profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.profile
|
||||
test -r ~/.zshrc && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >>~/.zshrc
|
||||
```
|
||||
|
||||
_参考了 [https://docs.brew.sh/Homebrew-on-Linux](https://docs.brew.sh/Homebrew-on-Linux)。_
|
||||
|
||||
### 替换现有仓库上游
|
||||
|
||||
替换 brew 程序本身的源,Homebrew/Linuxbrew 相同:
|
||||
替换 brew 程序本身的源,Homebrew / Linuxbrew 相同:
|
||||
|
||||
```bash
|
||||
git -C "$(brew --repo)" remote set-url origin https://{{ site.hostname }}/git/homebrew/brew.git
|
||||
```
|
||||
|
||||
以下针对 macOS 系统上的 Homebrew
|
||||
以下针对 macOS 系统上的 Homebrew:
|
||||
|
||||
```bash
|
||||
# 手动设置
|
||||
|
|
@ -101,7 +119,7 @@ brew update-reset
|
|||
_(感谢 Snowonion Lee 提供说明)_
|
||||
|
||||
```bash
|
||||
# brew 程序本身,Homebrew/Linuxbrew 相同
|
||||
# brew 程序本身,Homebrew / Linuxbrew 相同
|
||||
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
|
||||
|
||||
# 以下针对 macOS 系统上的 Homebrew
|
||||
|
|
|
|||
Loading…
Reference in New Issue