mirror of
https://gitee.com/ineo6/homebrew-install.git
synced 2025-06-18 02:49:16 +08:00
feat: 合并代码
This commit is contained in:
parent
2b20edf840
commit
0b66d2850a
@ -73,7 +73,7 @@ ohai() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
warn() {
|
warn() {
|
||||||
printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")"
|
printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if script is run non-interactively (e.g. CI)
|
# Check if script is run non-interactively (e.g. CI)
|
||||||
@ -304,6 +304,7 @@ check_run_command_as_root() {
|
|||||||
|
|
||||||
# Allow Azure Pipelines/GitHub Actions/Docker/Concourse/Kubernetes to do everything as root (as it's normal there)
|
# Allow Azure Pipelines/GitHub Actions/Docker/Concourse/Kubernetes to do everything as root (as it's normal there)
|
||||||
[[ -f /.dockerenv ]] && return
|
[[ -f /.dockerenv ]] && return
|
||||||
|
[[ -f /run/.containerenv ]] && return
|
||||||
[[ -f /proc/1/cgroup ]] && grep -E "azpl_job|actions_job|docker|garden|kubepods" -q /proc/1/cgroup && return
|
[[ -f /proc/1/cgroup ]] && grep -E "azpl_job|actions_job|docker|garden|kubepods" -q /proc/1/cgroup && return
|
||||||
|
|
||||||
abort "Don't run this as root!"
|
abort "Don't run this as root!"
|
||||||
@ -384,7 +385,12 @@ test_git() {
|
|||||||
|
|
||||||
local git_version_output
|
local git_version_output
|
||||||
git_version_output="$("$1" --version 2>/dev/null)"
|
git_version_output="$("$1" --version 2>/dev/null)"
|
||||||
version_ge "$(major_minor "${git_version_output##* }")" "$(major_minor "${REQUIRED_GIT_VERSION}")"
|
if [[ "${git_version_output}" =~ "git version "([^ ]*).* ]]
|
||||||
|
then
|
||||||
|
version_ge "$(major_minor "${BASH_REMATCH[1]}")" "$(major_minor "${REQUIRED_GIT_VERSION}")"
|
||||||
|
else
|
||||||
|
abort "Unexpected Git version: '${git_version_output}'!"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Search for the given executable in PATH (avoids a dependency on the `which` command)
|
# Search for the given executable in PATH (avoids a dependency on the `which` command)
|
||||||
@ -405,7 +411,10 @@ find_tool() {
|
|||||||
local executable
|
local executable
|
||||||
while read -r executable
|
while read -r executable
|
||||||
do
|
do
|
||||||
if "test_$1" "${executable}"
|
if [[ "${executable}" != /* ]]
|
||||||
|
then
|
||||||
|
warn "Ignoring ${executable} (relative paths don't work)"
|
||||||
|
elif "test_$1" "${executable}"
|
||||||
then
|
then
|
||||||
echo "${executable}"
|
echo "${executable}"
|
||||||
break
|
break
|
||||||
@ -447,65 +456,6 @@ fi
|
|||||||
cd "/usr" || exit 1
|
cd "/usr" || exit 1
|
||||||
|
|
||||||
####################################################################### script
|
####################################################################### script
|
||||||
USABLE_GIT="$(command -v git)"
|
|
||||||
if [[ -z "${USABLE_GIT}" ]]
|
|
||||||
then
|
|
||||||
abort "$(
|
|
||||||
cat <<EOABORT
|
|
||||||
You must install Git before installing Homebrew. See:
|
|
||||||
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
|
|
||||||
EOABORT
|
|
||||||
)"
|
|
||||||
elif [[ -n "${HOMEBREW_ON_LINUX-}" ]]
|
|
||||||
then
|
|
||||||
USABLE_GIT="$(find_tool git)"
|
|
||||||
if [[ -z "${USABLE_GIT}" ]]
|
|
||||||
then
|
|
||||||
abort "$(
|
|
||||||
cat <<EOABORT
|
|
||||||
The version of Git that was found does not satisfy requirements for Homebrew.
|
|
||||||
Please install Git ${REQUIRED_GIT_VERSION} or newer and add it to your PATH.
|
|
||||||
EOABORT
|
|
||||||
)"
|
|
||||||
elif [[ "${USABLE_GIT}" != /usr/bin/git ]]
|
|
||||||
then
|
|
||||||
export HOMEBREW_GIT_PATH="${USABLE_GIT}"
|
|
||||||
ohai "Found Git: ${HOMEBREW_GIT_PATH}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v curl >/dev/null
|
|
||||||
then
|
|
||||||
abort "$(
|
|
||||||
cat <<EOABORT
|
|
||||||
You must install cURL before installing Homebrew. See:
|
|
||||||
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
|
|
||||||
EOABORT
|
|
||||||
)"
|
|
||||||
elif [[ -n "${HOMEBREW_ON_LINUX-}" ]]
|
|
||||||
then
|
|
||||||
USABLE_CURL="$(find_tool curl)"
|
|
||||||
if [[ -z "${USABLE_CURL}" ]]
|
|
||||||
then
|
|
||||||
abort "$(
|
|
||||||
cat <<EOABORT
|
|
||||||
The version of cURL that was found does not satisfy requirements for Homebrew.
|
|
||||||
Please install cURL ${REQUIRED_CURL_VERSION} or newer and add it to your PATH.
|
|
||||||
EOABORT
|
|
||||||
)"
|
|
||||||
elif [[ "${USABLE_CURL}" != /usr/bin/curl ]]
|
|
||||||
then
|
|
||||||
export HOMEBREW_CURL_PATH="${USABLE_CURL}"
|
|
||||||
ohai "Found cURL: ${HOMEBREW_CURL_PATH}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set HOMEBREW_DEVELOPER on Linux systems where usable Git/cURL is not in /usr/bin
|
|
||||||
if [[ -n "${HOMEBREW_ON_LINUX-}" && (-n "${HOMEBREW_CURL_PATH-}" || -n "${HOMEBREW_GIT_PATH-}") ]]
|
|
||||||
then
|
|
||||||
ohai "Setting HOMEBREW_DEVELOPER to use Git/cURL not in /usr/bin"
|
|
||||||
export HOMEBREW_DEVELOPER=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
ohai 'Checking for `sudo` access (which may request your password)...'
|
ohai 'Checking for `sudo` access (which may request your password)...'
|
||||||
@ -883,6 +833,68 @@ EOABORT
|
|||||||
)"
|
)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
USABLE_GIT="$(command -v git)"
|
||||||
|
if [[ -z "${USABLE_GIT}" ]]
|
||||||
|
then
|
||||||
|
abort "$(
|
||||||
|
cat <<EOABORT
|
||||||
|
You must install Git before installing Homebrew. See:
|
||||||
|
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
|
||||||
|
EOABORT
|
||||||
|
)"
|
||||||
|
elif [[ -n "${HOMEBREW_ON_LINUX-}" ]]
|
||||||
|
then
|
||||||
|
suitable_git="$(find_tool git)"
|
||||||
|
if [[ -z "${suitable_git}" ]]
|
||||||
|
then
|
||||||
|
abort "$(
|
||||||
|
cat <<EOABORT
|
||||||
|
The version of Git that was found does not satisfy requirements for Homebrew.
|
||||||
|
Please install Git ${REQUIRED_GIT_VERSION} or newer and add it to your PATH.
|
||||||
|
EOABORT
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
USABLE_GIT="${suitable_git}"
|
||||||
|
if [[ "${USABLE_GIT}" != /usr/bin/git ]]
|
||||||
|
then
|
||||||
|
export HOMEBREW_GIT_PATH="${USABLE_GIT}"
|
||||||
|
ohai "Found Git: ${HOMEBREW_GIT_PATH}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v curl >/dev/null
|
||||||
|
then
|
||||||
|
abort "$(
|
||||||
|
cat <<EOABORT
|
||||||
|
You must install cURL before installing Homebrew. See:
|
||||||
|
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
|
||||||
|
EOABORT
|
||||||
|
)"
|
||||||
|
elif [[ -n "${HOMEBREW_ON_LINUX-}" ]]
|
||||||
|
then
|
||||||
|
USABLE_CURL="$(find_tool curl)"
|
||||||
|
if [[ -z "${USABLE_CURL}" ]]
|
||||||
|
then
|
||||||
|
abort "$(
|
||||||
|
cat <<EOABORT
|
||||||
|
The version of cURL that was found does not satisfy requirements for Homebrew.
|
||||||
|
Please install cURL ${REQUIRED_CURL_VERSION} or newer and add it to your PATH.
|
||||||
|
EOABORT
|
||||||
|
)"
|
||||||
|
elif [[ "${USABLE_CURL}" != /usr/bin/curl ]]
|
||||||
|
then
|
||||||
|
export HOMEBREW_CURL_PATH="${USABLE_CURL}"
|
||||||
|
ohai "Found cURL: ${HOMEBREW_CURL_PATH}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set HOMEBREW_DEVELOPER on Linux systems where usable Git/cURL is not in /usr/bin
|
||||||
|
if [[ -n "${HOMEBREW_ON_LINUX-}" && (-n "${HOMEBREW_CURL_PATH-}" || -n "${HOMEBREW_GIT_PATH-}") ]]
|
||||||
|
then
|
||||||
|
ohai "Setting HOMEBREW_DEVELOPER to use Git/cURL not in /usr/bin"
|
||||||
|
export HOMEBREW_DEVELOPER=1
|
||||||
|
fi
|
||||||
|
|
||||||
ohai "Downloading and installing Homebrew..."
|
ohai "Downloading and installing Homebrew..."
|
||||||
(
|
(
|
||||||
cd "${HOMEBREW_REPOSITORY}" >/dev/null || return
|
cd "${HOMEBREW_REPOSITORY}" >/dev/null || return
|
||||||
|
136
install.sh
136
install.sh
@ -74,7 +74,7 @@ ohai() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
warn() {
|
warn() {
|
||||||
printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")"
|
printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
checkExecute() {
|
checkExecute() {
|
||||||
@ -336,6 +336,7 @@ check_run_command_as_root() {
|
|||||||
|
|
||||||
# Allow Azure Pipelines/GitHub Actions/Docker/Concourse/Kubernetes to do everything as root (as it's normal there)
|
# Allow Azure Pipelines/GitHub Actions/Docker/Concourse/Kubernetes to do everything as root (as it's normal there)
|
||||||
[[ -f /.dockerenv ]] && return
|
[[ -f /.dockerenv ]] && return
|
||||||
|
[[ -f /run/.containerenv ]] && return
|
||||||
[[ -f /proc/1/cgroup ]] && grep -E "azpl_job|actions_job|docker|garden|kubepods" -q /proc/1/cgroup && return
|
[[ -f /proc/1/cgroup ]] && grep -E "azpl_job|actions_job|docker|garden|kubepods" -q /proc/1/cgroup && return
|
||||||
|
|
||||||
abort "Don't run this as root!"
|
abort "Don't run this as root!"
|
||||||
@ -416,7 +417,12 @@ test_git() {
|
|||||||
|
|
||||||
local git_version_output
|
local git_version_output
|
||||||
git_version_output="$("$1" --version 2>/dev/null)"
|
git_version_output="$("$1" --version 2>/dev/null)"
|
||||||
version_ge "$(major_minor "${git_version_output##* }")" "$(major_minor "${REQUIRED_GIT_VERSION}")"
|
if [[ "${git_version_output}" =~ "git version "([^ ]*).* ]]
|
||||||
|
then
|
||||||
|
version_ge "$(major_minor "${BASH_REMATCH[1]}")" "$(major_minor "${REQUIRED_GIT_VERSION}")"
|
||||||
|
else
|
||||||
|
abort "Unexpected Git version: '${git_version_output}'!"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Search for the given executable in PATH (avoids a dependency on the `which` command)
|
# Search for the given executable in PATH (avoids a dependency on the `which` command)
|
||||||
@ -437,7 +443,10 @@ find_tool() {
|
|||||||
local executable
|
local executable
|
||||||
while read -r executable
|
while read -r executable
|
||||||
do
|
do
|
||||||
if "test_$1" "${executable}"
|
if [[ "${executable}" != /* ]]
|
||||||
|
then
|
||||||
|
warn "Ignoring ${executable} (relative paths don't work)"
|
||||||
|
elif "test_$1" "${executable}"
|
||||||
then
|
then
|
||||||
echo "${executable}"
|
echo "${executable}"
|
||||||
break
|
break
|
||||||
@ -479,65 +488,6 @@ fi
|
|||||||
cd "/usr" || exit 1
|
cd "/usr" || exit 1
|
||||||
|
|
||||||
####################################################################### script
|
####################################################################### script
|
||||||
USABLE_GIT="$(command -v git)"
|
|
||||||
if [[ -z "${USABLE_GIT}" ]]
|
|
||||||
then
|
|
||||||
abort "$(
|
|
||||||
cat <<EOABORT
|
|
||||||
You must install Git before installing Homebrew. See:
|
|
||||||
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
|
|
||||||
EOABORT
|
|
||||||
)"
|
|
||||||
elif [[ -n "${HOMEBREW_ON_LINUX-}" ]]
|
|
||||||
then
|
|
||||||
USABLE_GIT="$(find_tool git)"
|
|
||||||
if [[ -z "${USABLE_GIT}" ]]
|
|
||||||
then
|
|
||||||
abort "$(
|
|
||||||
cat <<EOABORT
|
|
||||||
The version of Git that was found does not satisfy requirements for Homebrew.
|
|
||||||
Please install Git ${REQUIRED_GIT_VERSION} or newer and add it to your PATH.
|
|
||||||
EOABORT
|
|
||||||
)"
|
|
||||||
elif [[ "${USABLE_GIT}" != /usr/bin/git ]]
|
|
||||||
then
|
|
||||||
export HOMEBREW_GIT_PATH="${USABLE_GIT}"
|
|
||||||
ohai "Found Git: ${HOMEBREW_GIT_PATH}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v curl >/dev/null
|
|
||||||
then
|
|
||||||
abort "$(
|
|
||||||
cat <<EOABORT
|
|
||||||
You must install cURL before installing Homebrew. See:
|
|
||||||
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
|
|
||||||
EOABORT
|
|
||||||
)"
|
|
||||||
elif [[ -n "${HOMEBREW_ON_LINUX-}" ]]
|
|
||||||
then
|
|
||||||
USABLE_CURL="$(find_tool curl)"
|
|
||||||
if [[ -z "${USABLE_CURL}" ]]
|
|
||||||
then
|
|
||||||
abort "$(
|
|
||||||
cat <<EOABORT
|
|
||||||
The version of cURL that was found does not satisfy requirements for Homebrew.
|
|
||||||
Please install cURL ${REQUIRED_CURL_VERSION} or newer and add it to your PATH.
|
|
||||||
EOABORT
|
|
||||||
)"
|
|
||||||
elif [[ "${USABLE_CURL}" != /usr/bin/curl ]]
|
|
||||||
then
|
|
||||||
export HOMEBREW_CURL_PATH="${USABLE_CURL}"
|
|
||||||
ohai "Found cURL: ${HOMEBREW_CURL_PATH}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set HOMEBREW_DEVELOPER on Linux systems where usable Git/cURL is not in /usr/bin
|
|
||||||
if [[ -n "${HOMEBREW_ON_LINUX-}" && (-n "${HOMEBREW_CURL_PATH-}" || -n "${HOMEBREW_GIT_PATH-}") ]]
|
|
||||||
then
|
|
||||||
ohai "Setting HOMEBREW_DEVELOPER to use Git/cURL not in /usr/bin"
|
|
||||||
export HOMEBREW_DEVELOPER=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
ohai 'Checking for `sudo` access (which may request your password)...'
|
ohai 'Checking for `sudo` access (which may request your password)...'
|
||||||
@ -949,6 +899,68 @@ EOABORT
|
|||||||
)"
|
)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
USABLE_GIT="$(command -v git)"
|
||||||
|
if [[ -z "${USABLE_GIT}" ]]
|
||||||
|
then
|
||||||
|
abort "$(
|
||||||
|
cat <<EOABORT
|
||||||
|
You must install Git before installing Homebrew. See:
|
||||||
|
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
|
||||||
|
EOABORT
|
||||||
|
)"
|
||||||
|
elif [[ -n "${HOMEBREW_ON_LINUX-}" ]]
|
||||||
|
then
|
||||||
|
suitable_git="$(find_tool git)"
|
||||||
|
if [[ -z "${suitable_git}" ]]
|
||||||
|
then
|
||||||
|
abort "$(
|
||||||
|
cat <<EOABORT
|
||||||
|
The version of Git that was found does not satisfy requirements for Homebrew.
|
||||||
|
Please install Git ${REQUIRED_GIT_VERSION} or newer and add it to your PATH.
|
||||||
|
EOABORT
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
USABLE_GIT="${suitable_git}"
|
||||||
|
if [[ "${USABLE_GIT}" != /usr/bin/git ]]
|
||||||
|
then
|
||||||
|
export HOMEBREW_GIT_PATH="${USABLE_GIT}"
|
||||||
|
ohai "Found Git: ${HOMEBREW_GIT_PATH}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v curl >/dev/null
|
||||||
|
then
|
||||||
|
abort "$(
|
||||||
|
cat <<EOABORT
|
||||||
|
You must install cURL before installing Homebrew. See:
|
||||||
|
${tty_underline}https://docs.brew.sh/Installation${tty_reset}
|
||||||
|
EOABORT
|
||||||
|
)"
|
||||||
|
elif [[ -n "${HOMEBREW_ON_LINUX-}" ]]
|
||||||
|
then
|
||||||
|
USABLE_CURL="$(find_tool curl)"
|
||||||
|
if [[ -z "${USABLE_CURL}" ]]
|
||||||
|
then
|
||||||
|
abort "$(
|
||||||
|
cat <<EOABORT
|
||||||
|
The version of cURL that was found does not satisfy requirements for Homebrew.
|
||||||
|
Please install cURL ${REQUIRED_CURL_VERSION} or newer and add it to your PATH.
|
||||||
|
EOABORT
|
||||||
|
)"
|
||||||
|
elif [[ "${USABLE_CURL}" != /usr/bin/curl ]]
|
||||||
|
then
|
||||||
|
export HOMEBREW_CURL_PATH="${USABLE_CURL}"
|
||||||
|
ohai "Found cURL: ${HOMEBREW_CURL_PATH}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set HOMEBREW_DEVELOPER on Linux systems where usable Git/cURL is not in /usr/bin
|
||||||
|
if [[ -n "${HOMEBREW_ON_LINUX-}" && (-n "${HOMEBREW_CURL_PATH-}" || -n "${HOMEBREW_GIT_PATH-}") ]]
|
||||||
|
then
|
||||||
|
ohai "Setting HOMEBREW_DEVELOPER to use Git/cURL not in /usr/bin"
|
||||||
|
export HOMEBREW_DEVELOPER=1
|
||||||
|
fi
|
||||||
|
|
||||||
ohai "Downloading and installing Homebrew..."
|
ohai "Downloading and installing Homebrew..."
|
||||||
(
|
(
|
||||||
cd "${HOMEBREW_REPOSITORY}" >/dev/null || return
|
cd "${HOMEBREW_REPOSITORY}" >/dev/null || return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user