2018-02-22 04:15:49 +00:00
|
|
|
#!/bin/bash
|
2018-04-12 18:07:33 +00:00
|
|
|
# Description: Package manager - Homebrew on OSX, Linuxbrew on Linux
|
2018-02-27 05:15:14 +00:00
|
|
|
set -e
|
2018-02-22 04:15:49 +00:00
|
|
|
|
|
|
|
function _brew {
|
|
|
|
local pkg=$1
|
|
|
|
if ! brew ls $pkg >/dev/null 2>&1; then
|
|
|
|
_run "[brew] Install $pkg" brew install $@
|
|
|
|
else
|
|
|
|
echo "[brew] $pkg is already installed, skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-02-23 15:19:52 +00:00
|
|
|
function _brew_cask {
|
|
|
|
local pkg=$1
|
|
|
|
if ! brew cask list $pkg >/dev/null 2>&1; then
|
|
|
|
_run "[brew cask] Install $pkg" brew cask install $@
|
|
|
|
else
|
|
|
|
echo "[brew cask] $pkg is already installed, skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-04-23 17:49:26 +00:00
|
|
|
function _brew_tap {
|
|
|
|
local tap=$1
|
|
|
|
if ! brew tap | grep "^$tap$" >/dev/null 2>&1; then
|
|
|
|
_run "[brew tap] Tap repository $tap" brew tap $@
|
|
|
|
else
|
|
|
|
echo "[brew tap] $tap is already present, skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-02-23 14:50:30 +00:00
|
|
|
case "$(uname -s)" in
|
|
|
|
Darwin)
|
|
|
|
if ! which brew >/dev/null; then
|
|
|
|
_run "Install brew" /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_recipe _apt
|
|
|
|
_recipe _path
|
|
|
|
|
|
|
|
for pkg in build-essential curl file gawk git python-setuptools; do
|
|
|
|
_apt $pkg
|
|
|
|
done
|
|
|
|
if ! [ -d ~/.linuxbrew ]; then
|
|
|
|
_run "Install brew" git clone -q https://github.com/Linuxbrew/brew.git ~/.linuxbrew
|
|
|
|
fi
|
2018-02-23 21:18:41 +00:00
|
|
|
_path "$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin"
|
2018-02-23 14:50:30 +00:00
|
|
|
;;
|
|
|
|
esac
|