diff --git a/install.sh b/install.sh index 0ee6fd7..79c374f 100755 --- a/install.sh +++ b/install.sh @@ -39,27 +39,17 @@ then abort 'Bash must not run in POSIX mode. Please unset POSIXLY_CORRECT and try again.' fi -usage() { - cat </dev/null)" + if [[ -n "${BREW_NO_INSTALL}" ]] + then + abort "Homebrew cannot be installed because ${BREW_NO_INSTALL}." + else + abort "Homebrew cannot be installed because /etc/homebrew/brew.no_install exists!" + fi +fi # string formatters if [[ -t 1 ]] @@ -99,6 +89,28 @@ warn() { printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")" >&2 } +usage() { + cat </dev/null)" curl_name_and_version="${curl_version_output%% (*}" @@ -580,18 +617,9 @@ then abort "Homebrew is only supported on Intel and ARM processors!" fi else - # On Linux, support only 64-bit Intel - if [[ "${UNAME_MACHINE}" == "aarch64" ]] + if [[ "${UNAME_MACHINE}" != "x86_64" ]] && [[ "${UNAME_MACHINE}" != "aarch64" ]] then - abort "$( - cat </dev/null LATEST_GIT_TAG="$("${USABLE_GIT}" tag --list --sort="-version:refname" | head -n1)" @@ -1084,7 +1119,7 @@ ohai "Downloading and installing Homebrew..." then abort "Failed to query latest Homebrew/brew Git tag." fi - execute "${USABLE_GIT}" "checkout" "--force" "-B" "stable" "${LATEST_GIT_TAG}" + execute "${USABLE_GIT}" "checkout" "--quiet" "--force" "-B" "stable" "${LATEST_GIT_TAG}" if [[ "${HOMEBREW_REPOSITORY}" != "${HOMEBREW_PREFIX}" ]] then @@ -1110,7 +1145,8 @@ ohai "Downloading and installing Homebrew..." execute "${USABLE_GIT}" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" execute "${USABLE_GIT}" "config" "--bool" "core.autocrlf" "false" execute "${USABLE_GIT}" "config" "--bool" "core.symlinks" "true" - execute "${USABLE_GIT}" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" + retry 5 "${USABLE_GIT}" "fetch" "--force" "${quiet_progress[@]}" \ + "origin" "refs/heads/master:refs/remotes/origin/master" execute "${USABLE_GIT}" "remote" "set-head" "origin" "--auto" >/dev/null execute "${USABLE_GIT}" "reset" "--hard" "origin/master" @@ -1118,54 +1154,40 @@ ohai "Downloading and installing Homebrew..." ) || exit 1 fi - if [[ -n "${HOMEBREW_NO_INSTALL_FROM_API-}" && ! -d "${HOMEBREW_CASK}" ]] - then - # Always use single-quoted strings with `exp` expressions - # shellcheck disable=SC2016 - ohai 'Tapping homebrew/cask because `$HOMEBREW_NO_INSTALL_FROM_API` is set.' - ( - execute "${MKDIR[@]}" "${HOMEBREW_CASK}" - cd "${HOMEBREW_CASK}" >/dev/null || return - - execute "${USABLE_GIT}" "-c" "init.defaultBranch=master" "init" "--quiet" - execute "${USABLE_GIT}" "config" "remote.origin.url" "${HOMEBREW_CASK_GIT_REMOTE}" - execute "${USABLE_GIT}" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" - execute "${USABLE_GIT}" "config" "--bool" "core.autocrlf" "false" - execute "${USABLE_GIT}" "config" "--bool" "core.symlinks" "true" - execute "${USABLE_GIT}" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" - execute "${USABLE_GIT}" "remote" "set-head" "origin" "--auto" >/dev/null - execute "${USABLE_GIT}" "reset" "--hard" "origin/master" - - cd "${HOMEBREW_REPOSITORY}" >/dev/null || return - ) || exit 1 - fi - - if [[ ! -d "${HOMEBREW_SERVICES}" ]] - then - # Always use single-quoted strings with `exp` expressions - # shellcheck disable=SC2016 - ohai 'Tapping homebrew/services' - ( - execute "${MKDIR[@]}" "${HOMEBREW_SERVICES}" - cd "${HOMEBREW_SERVICES}" >/dev/null || return - - execute "${USABLE_GIT}" "-c" "init.defaultBranch=master" "init" "--quiet" - execute "${USABLE_GIT}" "config" "remote.origin.url" "${HOMEBREW_SERVICES_DEFAULT_GIT_REMOTE}" - execute "${USABLE_GIT}" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" - execute "${USABLE_GIT}" "config" "--bool" "core.autocrlf" "false" - execute "${USABLE_GIT}" "config" "--bool" "core.symlinks" "true" - execute "${USABLE_GIT}" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" - execute "${USABLE_GIT}" "remote" "set-head" "origin" "--auto" >/dev/null - execute "${USABLE_GIT}" "reset" "--hard" "origin/master" - - cd "${HOMEBREW_REPOSITORY}" >/dev/null || return - ) || exit 1 - fi execute "${HOMEBREW_PREFIX}/bin/brew" "update" "--force" "--quiet" ) || exit 1 +if [[ ":${PATH}:" != *":${HOMEBREW_PREFIX}/bin:"* ]] +then + warn "${HOMEBREW_PREFIX}/bin is not in your PATH. + Instructions on how to configure your shell for Homebrew + can be found in the 'Next steps' section below." +fi + +ohai "Installation successful!" +echo + ring_bell +# Use an extra newline and bold to avoid this being missed. +ohai "Homebrew has enabled anonymous aggregate formulae and cask analytics." +echo "$( + cat </dev/null || return execute "${USABLE_GIT}" "config" "--replace-all" "homebrew.analyticsmessage" "true" @@ -1256,6 +1278,9 @@ then if [[ -x "$(command -v apt-get)" ]] then echo " sudo apt-get install build-essential" + elif [[ -x "$(command -v dnf)" ]] + then + echo " sudo dnf group install development-tools" elif [[ -x "$(command -v yum)" ]] then echo " sudo yum groupinstall 'Development Tools'"