Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dmccaffery committed Nov 24, 2020
1 parent 3a697b6 commit b420dd9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
55 changes: 46 additions & 9 deletions src/sh/install/darwin.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,67 @@
#!/usr/bin/env sh

set -e

__am_prompt_ensure_rosetta() {

# determine if we are on x86
if [ "$(uname -m)" = "x86_64" ]; then

# install homebrew using defaults
__am_prompt_install_darwin

# move on immediately
return $?
fi

# install rosetta 2
softwareupdate --install-rosetta --agree-to-license

# create the homebrew directory
if [ ! -d "/opt/homebrew" ]; then

# create the homebrew path
sudo mkdir -p /opt/homebrew

# chown the path
sudo chown /opt/homebrew $(whoami):staff
fi

# install homebrew in rosetta
__am_prompt_install_darwin x86_64 /usr/local

# install homebrew for apple silicon
__am_prompt_ensure_rosetta $(uname -m) /opt/homebrew
}

__am_prompt_install_darwin() {
local BREWS='openssl git go nvm python'
local ARCH=${1:-"x86-64"}
local HOMEBREW_PREFIX="${2:-/usr/local}"
local BREW_CMD="${HOMEBREW_PREFIX}/bin/brew"

if ! type brew 1>/dev/null 2>&1; then
if ! type "${BREW_CMD}" 1>/dev/null 2>&1; then
$ECHO "${CLR_SUCCESS}installing homebrew...${CLR_CLEAR}"
bash -c "CI=true $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh) && brew config"
arch -${ARCH} /bin/bash -c "HOMEBREW_PREFIX=${HOMEBREW_PREFIX} CI=true $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh) && ${BREW_CMD} config"
fi

$ECHO "${CLR_SUCCESS}updating homebrew...${CLR_CLEAR}"
brew update
${BREW_CMD} update

set +e

for pkg in $BREWS; do
if brew list --formula -1 | grep -q "^${pkg}\$"; then
if ${BREW_CMD} list --formula -1 | grep -q "^${pkg}\$"; then
$ECHO "${CLR_SUCCESS}upgrading: $pkg...${CLR_CLEAR}"
brew upgrade $pkg 2>/dev/null
brew link --overwrite $pkg 2>/dev/null
${BREW_CMD} upgrade $pkg 2>/dev/null
${BREW_CMD} link --overwrite $pkg 2>/dev/null
else
$ECHO "${CLR_SUCCESS}installing: $pkg...${CLR_CLEAR}"
brew install $pkg
${BREW_CMD} install $pkg
fi
done

local NVM_PATH=$(brew --prefix nvm)
local NVM_PATH=$(${BREW_CMD} --prefix nvm)

if [ -f "$NVM_PATH/nvm.sh" ]; then
$ECHO "${CLR_SUCCESS}setting up nvm...${CLR_CLEAR}"
Expand All @@ -38,4 +75,4 @@ __am_prompt_install_darwin() {
git config --system credential.helper osxkeychain
}

__am_prompt_install_darwin
__am_prompt_ensure_rosetta
3 changes: 2 additions & 1 deletion src/sh/scripts/use-shell
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ __am_prompt_use_shell() {
echo "${CLR_SUCCESS}"
echo "##############################################################################"
echo "##############################################################################"
echo " PLEASE RUN: exec -l \$SHELL # ($SHELL)"
echo " # \$SHELL will be $SHELL"
echo " PLEASE RUN: exec -l \$SHELL"
echo "##############################################################################"
echo "##############################################################################"
echo "${CLR_CLEAR}"
Expand Down

0 comments on commit b420dd9

Please sign in to comment.