mirror of
https://gitee.com/ineo6/homebrew-install.git
synced 2025-04-06 03:58:05 +08:00
feat: 更新install
配置core镜像
This commit is contained in:
parent
79edc96097
commit
de8d9feea3
83
install.sh
83
install.sh
@ -36,6 +36,8 @@ if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
|||||||
HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}/Homebrew"
|
HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}/Homebrew"
|
||||||
fi
|
fi
|
||||||
HOMEBREW_CACHE="${HOME}/Library/Caches/Homebrew"
|
HOMEBREW_CACHE="${HOME}/Library/Caches/Homebrew"
|
||||||
|
#changed HOMEBREW_CORE_GIT_REMOTE="https://github.com/Homebrew/homebrew-core"
|
||||||
|
HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git/"
|
||||||
|
|
||||||
STAT="stat -f"
|
STAT="stat -f"
|
||||||
CHOWN="/usr/sbin/chown"
|
CHOWN="/usr/sbin/chown"
|
||||||
@ -47,6 +49,8 @@ else
|
|||||||
# and ~/.linuxbrew (which is unsupported) if run interactively.
|
# and ~/.linuxbrew (which is unsupported) if run interactively.
|
||||||
HOMEBREW_PREFIX_DEFAULT="/home/linuxbrew/.linuxbrew"
|
HOMEBREW_PREFIX_DEFAULT="/home/linuxbrew/.linuxbrew"
|
||||||
HOMEBREW_CACHE="${HOME}/.cache/Homebrew"
|
HOMEBREW_CACHE="${HOME}/.cache/Homebrew"
|
||||||
|
#changed HOMEBREW_CORE_GIT_REMOTE="https://github.com/Homebrew/linuxbrew-core"
|
||||||
|
HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git/"
|
||||||
|
|
||||||
STAT="stat --printf"
|
STAT="stat --printf"
|
||||||
CHOWN="/bin/chown"
|
CHOWN="/bin/chown"
|
||||||
@ -54,7 +58,8 @@ else
|
|||||||
GROUP="$(id -gn)"
|
GROUP="$(id -gn)"
|
||||||
TOUCH="/bin/touch"
|
TOUCH="/bin/touch"
|
||||||
fi
|
fi
|
||||||
BREW_REPO="https://mirrors.ustc.edu.cn/brew.git"
|
#changed HOMEBREW_BREW_GIT_REMOTE="https://github.com/Homebrew/brew"
|
||||||
|
HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
|
||||||
|
|
||||||
# TODO: bump version when new macOS is released or announced
|
# TODO: bump version when new macOS is released or announced
|
||||||
MACOS_NEWEST_UNSUPPORTED="12.0"
|
MACOS_NEWEST_UNSUPPORTED="12.0"
|
||||||
@ -176,10 +181,6 @@ major_minor() {
|
|||||||
echo "${1%%.*}.$(x="${1#*.}"; echo "${x%%.*}")"
|
echo "${1%%.*}.$(x="${1#*.}"; echo "${x%%.*}")"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
|
||||||
macos_version="$(major_minor "$(/usr/bin/sw_vers -productVersion)")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
version_gt() {
|
version_gt() {
|
||||||
[[ "${1%.*}" -gt "${2%.*}" ]] || [[ "${1%.*}" -eq "${2%.*}" && "${1#*.}" -gt "${2#*.}" ]]
|
[[ "${1%.*}" -gt "${2%.*}" ]] || [[ "${1%.*}" -eq "${2%.*}" && "${1#*.}" -gt "${2#*.}" ]]
|
||||||
}
|
}
|
||||||
@ -232,7 +233,7 @@ file_not_grpowned() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Please sync with 'test_ruby()' in 'Library/Homebrew/utils/ruby.sh' from Homebrew/brew repository.
|
# Please sync with 'test_ruby()' in 'Library/Homebrew/utils/ruby.sh' from Homebrew/brew repository.
|
||||||
test_ruby () {
|
test_ruby() {
|
||||||
if [[ ! -x $1 ]]
|
if [[ ! -x $1 ]]
|
||||||
then
|
then
|
||||||
return 1
|
return 1
|
||||||
@ -307,10 +308,10 @@ EOABORT
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
||||||
have_sudo_access
|
have_sudo_access
|
||||||
else
|
else
|
||||||
if [[ -n "${NONINTERACTIVE-}" ]] ||
|
if [[ -n "${NONINTERACTIVE-}" ]] ||
|
||||||
[[ -w "$HOMEBREW_PREFIX_DEFAULT" ]] ||
|
[[ -w "${HOMEBREW_PREFIX_DEFAULT}" ]] ||
|
||||||
[[ -w "/home/linuxbrew" ]] ||
|
[[ -w "/home/linuxbrew" ]] ||
|
||||||
[[ -w "/home" ]]; then
|
[[ -w "/home" ]]; then
|
||||||
HOMEBREW_PREFIX="$HOMEBREW_PREFIX_DEFAULT"
|
HOMEBREW_PREFIX="$HOMEBREW_PREFIX_DEFAULT"
|
||||||
@ -331,10 +332,11 @@ else
|
|||||||
fi
|
fi
|
||||||
HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}/Homebrew"
|
HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}/Homebrew"
|
||||||
fi
|
fi
|
||||||
|
HOMEBREW_CORE="${HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-core"
|
||||||
|
|
||||||
if [[ "${EUID:-${UID}}" == "0" ]]; then
|
if [[ "${EUID:-${UID}}" == "0" ]]; then
|
||||||
abort "Don't run this as root!"
|
abort "Don't run this as root!"
|
||||||
elif [[ -d "$HOMEBREW_PREFIX" && ! -x "$HOMEBREW_PREFIX" ]]; then
|
elif [[ -d "${HOMEBREW_PREFIX}" && ! -x "${HOMEBREW_PREFIX}" ]]; then
|
||||||
abort "$(cat <<EOABORT
|
abort "$(cat <<EOABORT
|
||||||
The Homebrew prefix, ${HOMEBREW_PREFIX}, exists but is not searchable.
|
The Homebrew prefix, ${HOMEBREW_PREFIX}, exists but is not searchable.
|
||||||
If this is not intentional, please restore the default permissions and
|
If this is not intentional, please restore the default permissions and
|
||||||
@ -351,12 +353,20 @@ if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# On Linux, support only 64-bit Intel
|
# On Linux, support only 64-bit Intel
|
||||||
if [[ "$UNAME_MACHINE" != "x86_64" ]]; then
|
if [[ "$UNAME_MACHINE" == "arm64" ]]; then
|
||||||
abort "Homebrew is only supported on Intel processors!"
|
abort "$(cat <<EOABORT
|
||||||
|
Homebrew on Linux is not supported on ARM processors.
|
||||||
|
You can try an alternate installation method instead:
|
||||||
|
${tty_underline}https://docs.brew.sh/Homebrew-on-Linux#arm${tty_reset}
|
||||||
|
EOABORT
|
||||||
|
)"
|
||||||
|
elif [[ "$UNAME_MACHINE" != "x86_64" ]]; then
|
||||||
|
abort "Homebrew on Linux is only supported on Intel processors!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
||||||
|
macos_version="$(major_minor "$(/usr/bin/sw_vers -productVersion)")"
|
||||||
if version_lt "$macos_version" "10.7"; then
|
if version_lt "$macos_version" "10.7"; then
|
||||||
abort "$(cat <<EOABORT
|
abort "$(cat <<EOABORT
|
||||||
Your Mac OS X version is too old. See:
|
Your Mac OS X version is too old. See:
|
||||||
@ -382,8 +392,8 @@ EOABORT
|
|||||||
This installation may not succeed.
|
This installation may not succeed.
|
||||||
After installation, you will encounter build failures with some formulae.
|
After installation, you will encounter build failures with some formulae.
|
||||||
Please create pull requests instead of asking for help on Homebrew\'s GitHub,
|
Please create pull requests instead of asking for help on Homebrew\'s GitHub,
|
||||||
Discourse, Twitter or IRC. You are responsible for resolving any issues you
|
Twitter or IRC. You are responsible for resolving any issues you experience
|
||||||
experience while you are running this ${what}.
|
while you are running this ${what}.
|
||||||
EOS
|
EOS
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
@ -598,14 +608,14 @@ ohai "Downloading and installing Homebrew..."
|
|||||||
execute "git" "init" "-q"
|
execute "git" "init" "-q"
|
||||||
|
|
||||||
# "git remote add" will fail if the remote is defined in the global config
|
# "git remote add" will fail if the remote is defined in the global config
|
||||||
execute "git" "config" "remote.origin.url" "${BREW_REPO}"
|
execute "git" "config" "remote.origin.url" "${HOMEBREW_BREW_GIT_REMOTE}"
|
||||||
execute "git" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*"
|
execute "git" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*"
|
||||||
|
|
||||||
# ensure we don't munge line endings on checkout
|
# ensure we don't munge line endings on checkout
|
||||||
execute "git" "config" "core.autocrlf" "false"
|
execute "git" "config" "core.autocrlf" "false"
|
||||||
|
|
||||||
execute "git" "fetch" "origin" "--force"
|
execute "git" "fetch" "--force" "origin"
|
||||||
execute "git" "fetch" "origin" "--tags" "--force"
|
execute "git" "fetch" "--force" "--tags" "origin"
|
||||||
|
|
||||||
execute "git" "reset" "--hard" "origin/master"
|
execute "git" "reset" "--hard" "origin/master"
|
||||||
|
|
||||||
@ -613,7 +623,25 @@ ohai "Downloading and installing Homebrew..."
|
|||||||
execute "ln" "-sf" "${HOMEBREW_REPOSITORY}/bin/brew" "${HOMEBREW_PREFIX}/bin/brew"
|
execute "ln" "-sf" "${HOMEBREW_REPOSITORY}/bin/brew" "${HOMEBREW_PREFIX}/bin/brew"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
execute "${HOMEBREW_PREFIX}/bin/brew" "update" "--force"
|
if [[ ! -d "${HOMEBREW_CORE}" ]]; then
|
||||||
|
ohai "Tapping homebrew/core"
|
||||||
|
(
|
||||||
|
execute "/bin/mkdir" "-p" "${HOMEBREW_CORE}"
|
||||||
|
cd "${HOMEBREW_CORE}" >/dev/null || return
|
||||||
|
|
||||||
|
execute "git" "init" "-q"
|
||||||
|
execute "git" "config" "remote.origin.url" "${HOMEBREW_CORE_GIT_REMOTE}"
|
||||||
|
execute "git" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*"
|
||||||
|
execute "git" "config" "core.autocrlf" "false"
|
||||||
|
execute "git" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master"
|
||||||
|
execute "git" "remote" "set-head" "origin" "--auto" >/dev/null
|
||||||
|
execute "git" "reset" "--hard" "origin/master"
|
||||||
|
|
||||||
|
cd "${HOMEBREW_REPOSITORY}" >/dev/null || return
|
||||||
|
) || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
execute "${HOMEBREW_PREFIX}/bin/brew" "update" "--force" "--quiet"
|
||||||
) || exit 1
|
) || exit 1
|
||||||
|
|
||||||
if [[ ":${PATH}:" != *":${HOMEBREW_PREFIX}/bin:"* ]]; then
|
if [[ ":${PATH}:" != *":${HOMEBREW_PREFIX}/bin:"* ]]; then
|
||||||
@ -652,11 +680,7 @@ EOS
|
|||||||
) || exit 1
|
) || exit 1
|
||||||
|
|
||||||
ohai "Next steps:"
|
ohai "Next steps:"
|
||||||
echo "- Run \`brew help\` to get started"
|
if [[ "$UNAME_MACHINE" == "arm64" ]] || [[ -n "${HOMEBREW_ON_LINUX-}" ]]; then
|
||||||
echo "- Further documentation: "
|
|
||||||
echo " ${tty_underline}https://docs.brew.sh${tty_reset}"
|
|
||||||
|
|
||||||
if [[ -n "${HOMEBREW_ON_LINUX-}" ]]; then
|
|
||||||
case "$SHELL" in
|
case "$SHELL" in
|
||||||
*/bash*)
|
*/bash*)
|
||||||
if [[ -r "$HOME/.bash_profile" ]]; then
|
if [[ -r "$HOME/.bash_profile" ]]; then
|
||||||
@ -673,6 +697,18 @@ if [[ -n "${HOMEBREW_ON_LINUX-}" ]]; then
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
cat <<EOS
|
||||||
|
- Add Homebrew to your ${tty_bold}PATH${tty_reset} in ${tty_underline}${shell_profile}${tty_reset}:
|
||||||
|
echo 'eval \$(${HOMEBREW_PREFIX}/bin/brew shellenv)' >> ${shell_profile}
|
||||||
|
eval \$(${HOMEBREW_PREFIX}/bin/brew shellenv)
|
||||||
|
EOS
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "- Run \`brew help\` to get started"
|
||||||
|
echo "- Further documentation: "
|
||||||
|
echo " ${tty_underline}https://docs.brew.sh${tty_reset}"
|
||||||
|
|
||||||
|
if [[ -n "${HOMEBREW_ON_LINUX-}" ]]; then
|
||||||
echo "- Install the Homebrew dependencies if you have sudo access:"
|
echo "- Install the Homebrew dependencies if you have sudo access:"
|
||||||
|
|
||||||
if [[ $(command -v apt-get) ]]; then
|
if [[ $(command -v apt-get) ]]; then
|
||||||
@ -687,9 +723,6 @@ if [[ -n "${HOMEBREW_ON_LINUX-}" ]]; then
|
|||||||
|
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
See ${tty_underline}https://docs.brew.sh/linux${tty_reset} for more information
|
See ${tty_underline}https://docs.brew.sh/linux${tty_reset} for more information
|
||||||
- Add Homebrew to your ${tty_bold}PATH${tty_reset} in ${tty_underline}${shell_profile}${tty_reset}:
|
|
||||||
echo 'eval \$(${HOMEBREW_PREFIX}/bin/brew shellenv)' >> ${shell_profile}
|
|
||||||
eval \$(${HOMEBREW_PREFIX}/bin/brew shellenv)
|
|
||||||
- We recommend that you install GCC:
|
- We recommend that you install GCC:
|
||||||
brew install gcc
|
brew install gcc
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user