refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / brew / install.sh
index 93220ddb246fd61e72959745bb80f08792ea0f0f..1b7ca3240c87a731f72630e40650137f7401989f 100644 (file)
@@ -3,10 +3,34 @@
 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'"
@@ -35,3 +59,5 @@ set -u
     echo '        /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"'
     echo ""
 }
+
+_install_brew