From 5fcec47c6d33502e29655f3d6612dffc46374b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laurent?= <francois.laurent@posteo.net> Date: Tue, 28 May 2024 18:57:06 +0200 Subject: [PATCH] Homebrew install made lazy --- scripts/install.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index ec46293..b4d96e3 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +[ -d "`pwd`" ] || cd + if [ -z "$BIN_DIR" ]; then BIN_DIR=~/.local/bin fi @@ -31,16 +33,19 @@ if ! command -v curl 1>/dev/null 2>&1; then echo "Command curl required; aborting" else -if [ "`uname`" = "Darwin" ]; then - # macOS - if ! command -v brew 1>/dev/null 2>&1; then - echo "Installing Homebrew; admin rights will be requested" - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +check_brew() { + if [ "`uname`" = "Darwin" ]; then + # macOS + if ! command -v brew 1>/dev/null 2>&1; then + echo "Installing Homebrew; admin rights will be requested" + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + fi fi -fi +} if ! command -v realpath 1>/dev/null 2>&1; then # macOS + check_brew if command -v brew 1>/dev/null 2>&1; then brew install coreutils fi @@ -71,11 +76,14 @@ if [ -n "$WITH_DEFAULT_BACKEND" ]; then if ! command -v python3.8 1>/dev/null 2>&1; then if command -v pyenv 1>/dev/null 2>&1; then pyenv install 3.8 - elif command -v brew 1>/dev/null 2>&1; then - brew install python@3.8 else - echo "WARNING: command python3.8 not found" - echo "if under Ubuntu, consider running: sudo apt install python3.8 python3.8-venv" + check_brew + if command -v brew 1>/dev/null 2>&1; then + brew install python@3.8 + else + echo "WARNING: command python3.8 not found" + echo "if under Ubuntu, consider running: sudo apt install python3.8 python3.8-venv" + fi fi fi if ! command -v poetry 1>/dev/null 2>&1; then -- GitLab