X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=brew%2Finstall.sh;h=1b7ca3240c87a731f72630e40650137f7401989f;hb=4edf137e5d6b65f9ac847db6694ac387c7e91f3e;hp=e95a5726a89f0b3bda548da5a39d482556e1b296;hpb=5e0debf4c54c1e55476c1bc533c26db2b54d2f77;p=webi-installers%2F.git diff --git a/brew/install.sh b/brew/install.sh index e95a572..1b7ca32 100644 --- a/brew/install.sh +++ b/brew/install.sh @@ -1,14 +1,63 @@ #!/bin/bash -# title: Homebrew -# homepage: https://brew.sh -# tagline: The Missing Package Manager for macOS (or Linux) -# description: | -# Homebrew installs the stuff you need that Apple (or your Linux system) didn’t. -# examples: | -# ```bash -# brew install node -# ``` - -# Straight from https://brew.sh -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" +set -e +set -u + +function _install_brew() { + # Straight from https://brew.sh + #/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + + if [[ -n "$(uname -a | grep -i darwin)" ]]; then + needs_xcode="$(/usr/bin/xcode-select -p > /dev/null 2> /dev/null || echo "true")" + if [[ -n ${needs_xcode} ]]; then + echo "" + echo "" + echo "ERROR: Run this command to install XCode Command Line Tools first:" + echo "" + echo " xcode-select --install" + echo "" + echo "After the install, close this terminal, open a new one, and try again." + echo "" + fi + else + if [ -z "$(command -v gcc)" ]; then + echo >&2 "Warning: to install 'gcc' et al on Linux use the built-in package manager." + echo >&2 " For example, try: sudo apt install -y build-essential" + fi + if [ -z "$(command -v git)" ]; then + echo >&2 "Error: to install 'git' on Linux use the built-in package manager." + echo >&2 " For example, try: sudo apt install -y git" + exit 1 + fi + fi + + # From Straight from https://brew.sh + if ! [ -d "$HOME/.local/opt/brew" ]; then + echo "Installing to '$HOME/.local/opt/brew'" + echo "" + echo "If you prefer to have brew installed to '/usr/local' cancel now and do the following:" + echo " rm -rf '$HOME/.local/opt/brew'" + echo ' /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"' + echo "" + sleep 3 + git clone --depth=1 https://github.com/Homebrew/brew "$HOME/.local/opt/brew" + fi + + webi_path_add "$HOME/.local/opt/brew/bin" + export PATH="$HOME/.local/opt/brew/bin:$PATH" + + echo "Updating brew..." + brew update + + webi_path_add "$HOME/.local/opt/brew/sbin" + export PATH="$HOME/.local/opt/brew/sbin:$PATH" + + echo "Installed 'brew' to '$HOME/.local/opt/brew'" + echo "" + echo "If you prefer to have brew installed to '/usr/local' do the following:" + echo " mv '$HOME/.local/opt/brew' '$HOME/.local/opt/brew.$(date '+%F_%H-%M-%S').bak'" + echo ' /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"' + echo "" +} + +_install_brew