mirror of
https://gitee.com/ineo6/homebrew-install.git
synced 2025-04-05 19:41:45 +08:00
feat: 更新脚本
This commit is contained in:
parent
0b60dd95d5
commit
e615dc5bc1
4
install
4
install
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
STDERR.print <<EOS
|
||||
Warning: The Ruby Homebrew installer is now deprecated and has been rewritten in
|
||||
Bash. Please migrate to the following command:
|
||||
Warning: Ruby版本Homebrew安装脚本已被废弃,新版脚本使用Bash重写。
|
||||
请使用以下命令:
|
||||
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"
|
||||
|
||||
EOS
|
||||
|
73
install.sh
73
install.sh
@ -7,20 +7,34 @@ if [[ ! -t 0 || -n "${CI-}" ]]; then
|
||||
NONINTERACTIVE=1
|
||||
fi
|
||||
|
||||
# First check if the OS is Linux.
|
||||
if [[ "$(uname)" = "Linux" ]]; then
|
||||
abort() {
|
||||
printf "%s\n" "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# First check OS.
|
||||
OS="$(uname)"
|
||||
if [[ "$OS" == "Linux" ]]; then
|
||||
HOMEBREW_ON_LINUX=1
|
||||
elif [[ "$OS" != "Darwin" ]]; then
|
||||
abort "Homebrew is only supported on macOS and Linux."
|
||||
fi
|
||||
|
||||
# On macOS, this script installs to /usr/local only.
|
||||
# On Linux, it installs to /home/linuxbrew/.linuxbrew if you have sudo access
|
||||
# and ~/.linuxbrew otherwise.
|
||||
# To install elsewhere (which is unsupported)
|
||||
UNAME_MACHINE="$(uname -m)"
|
||||
|
||||
# Required installation paths. To install elsewhere (which is unsupported)
|
||||
# you can untar https://github.com/Homebrew/brew/tarball/master
|
||||
# anywhere you like.
|
||||
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
||||
HOMEBREW_PREFIX="/usr/local"
|
||||
HOMEBREW_REPOSITORY="/usr/local/Homebrew"
|
||||
if [[ "$UNAME_MACHINE" == "arm64" ]]; then
|
||||
# On ARM macOS, this script installs to /opt/homebrew only
|
||||
HOMEBREW_PREFIX="/opt/homebrew"
|
||||
HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}"
|
||||
else
|
||||
# On Intel macOS, this script installs to /usr/local only
|
||||
HOMEBREW_PREFIX="/usr/local"
|
||||
HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}/Homebrew"
|
||||
fi
|
||||
HOMEBREW_CACHE="${HOME}/Library/Caches/Homebrew"
|
||||
|
||||
STAT="stat -f"
|
||||
@ -29,6 +43,8 @@ if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
||||
GROUP="admin"
|
||||
TOUCH="/usr/bin/touch"
|
||||
else
|
||||
# On Linux, it installs to /home/linuxbrew/.linuxbrew if you have sudo access
|
||||
# and ~/.linuxbrew (which is unsupported) if run interactively.
|
||||
HOMEBREW_PREFIX_DEFAULT="/home/linuxbrew/.linuxbrew"
|
||||
HOMEBREW_CACHE="${HOME}/.cache/Homebrew"
|
||||
|
||||
@ -117,11 +133,6 @@ warn() {
|
||||
printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")"
|
||||
}
|
||||
|
||||
abort() {
|
||||
printf "%s\n" "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
execute() {
|
||||
if ! "$@"; then
|
||||
abort "$(printf "Failed during: %s" "$(shell_join "$@")")"
|
||||
@ -333,21 +344,16 @@ EOABORT
|
||||
)"
|
||||
fi
|
||||
|
||||
UNAME_MACHINE="$(uname -m)"
|
||||
|
||||
if [[ -z "${HOMEBREW_ON_LINUX-}" ]] && [[ "$UNAME_MACHINE" == "arm64" ]]; then
|
||||
abort "$(cat <<EOABORT
|
||||
Homebrew is not (yet) supported on ARM processors!
|
||||
Rerun the Homebrew installer under Rosetta 2.
|
||||
If you really know what you are doing and are prepared for a very broken
|
||||
experience you can use another installation option for installing on ARM:
|
||||
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
|
||||
EOABORT
|
||||
)"
|
||||
fi
|
||||
|
||||
if [[ "$UNAME_MACHINE" != "x86_64" ]]; then
|
||||
abort "Homebrew is only supported on Intel processors!"
|
||||
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
||||
# On macOS, support 64-bit Intel and ARM
|
||||
if [[ "$UNAME_MACHINE" != "arm64" ]] && [[ "$UNAME_MACHINE" != "x86_64" ]]; then
|
||||
abort "Homebrew is only supported on Intel and ARM processors!"
|
||||
fi
|
||||
else
|
||||
# On Linux, support only 64-bit Intel
|
||||
if [[ "$UNAME_MACHINE" != "x86_64" ]]; then
|
||||
abort "Homebrew is only supported on Intel processors!"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
||||
@ -419,7 +425,7 @@ done
|
||||
directories=(bin etc include lib sbin share var opt
|
||||
share/zsh share/zsh/site-functions
|
||||
var/homebrew var/homebrew/linked
|
||||
Cellar Caskroom Homebrew Frameworks)
|
||||
Cellar Caskroom Frameworks)
|
||||
mkdirs=()
|
||||
for dir in "${directories[@]}"; do
|
||||
if ! [[ -d "${HOMEBREW_PREFIX}/${dir}" ]]; then
|
||||
@ -518,6 +524,11 @@ if [[ "${#mkdirs[@]}" -gt 0 ]]; then
|
||||
execute_sudo "$CHGRP" "$GROUP" "${mkdirs[@]}"
|
||||
fi
|
||||
|
||||
if ! [[ -d "${HOMEBREW_REPOSITORY}" ]]; then
|
||||
execute_sudo "/bin/mkdir" "-p" "${HOMEBREW_REPOSITORY}"
|
||||
fi
|
||||
execute_sudo "$CHOWN" "$USER:$GROUP" "${HOMEBREW_REPOSITORY}"
|
||||
|
||||
if ! [[ -d "${HOMEBREW_CACHE}" ]]; then
|
||||
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
|
||||
execute_sudo "/bin/mkdir" "-p" "${HOMEBREW_CACHE}"
|
||||
@ -598,7 +609,9 @@ ohai "Downloading and installing Homebrew..."
|
||||
|
||||
execute "git" "reset" "--hard" "origin/master"
|
||||
|
||||
execute "ln" "-sf" "${HOMEBREW_REPOSITORY}/bin/brew" "${HOMEBREW_PREFIX}/bin/brew"
|
||||
if [[ "${HOMEBREW_REPOSITORY}" != "${HOMEBREW_PREFIX}" ]]; then
|
||||
execute "ln" "-sf" "${HOMEBREW_REPOSITORY}/bin/brew" "${HOMEBREW_PREFIX}/bin/brew"
|
||||
fi
|
||||
|
||||
execute "${HOMEBREW_PREFIX}/bin/brew" "update" "--force"
|
||||
) || exit 1
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
STDERR.print <<EOS
|
||||
Warning: The Ruby Homebrew uninstaller is now deprecated and has been rewritten in
|
||||
Bash. Please migrate to the following command:
|
||||
Warning: Ruby版本Homebrew安装脚本已被废弃,新版脚本使用Bash重写。
|
||||
请使用以下命令:
|
||||
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/uninstall.sh)"
|
||||
|
||||
EOS
|
||||
|
@ -170,7 +170,7 @@ Usage: $0 [options]
|
||||
Skips removal of HOMEBREW_CACHE and HOMEBREW_LOGS.
|
||||
-f, --force Uninstall without prompting.
|
||||
-q, --quiet Suppress all output.
|
||||
-d, --dry-run Simulate uninstall but don't remove anything.
|
||||
-n, --dry-run Simulate uninstall but don't remove anything.
|
||||
-h, --help Display this message.
|
||||
EOS
|
||||
exit "${1:-0}"
|
||||
@ -183,7 +183,7 @@ while [[ $# -gt 0 ]]; do
|
||||
--skip-cache-and-logs) opt_skip_cache_and_logs=1;;
|
||||
-f|--force) opt_force=1;;
|
||||
-q|--quiet) opt_quiet=1;;
|
||||
-d|--dry-run) opt_dry_run=1;;
|
||||
-d|-n|--dry-run) opt_dry_run=1;;
|
||||
-h|--help) usage;;
|
||||
*) warn "Unrecognized option: '$1'"; usage 1;;
|
||||
esac
|
||||
|
Loading…
x
Reference in New Issue
Block a user