-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·54 lines (40 loc) · 1.05 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
#inspired by thoughtbot laptop script
fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\n$fmt\n" "$@"
}
brew_install_or_upgrade() {
if brew_is_installed "$1"; then
if brew_is_upgradable "$1"; then
fancy_echo "Upgrading %s ..." "$1"
brew upgrade "$@"
else
fancy_echo "Already using the latest version of %s. Skipping ..." "$1"
fi
else
fancy_echo "Installing %s ..." "$1"
brew install "$@"
fi
}
brew_is_installed() {
local name="$(brew_expand_alias "$1")"
brew list -1 | grep -Fqx "$name"
}
brew_is_upgradable() {
local name="$(brew_expand_alias "$1")"
! brew outdated --quiet "$name" >/dev/null
}
brew_expand_alias() {
brew info "$1" 2>/dev/null | head -1 | awk '{gsub(/:/, ""); print $1}'
}
brew_install_or_upgrade 'ocaml'
brew_install_or_upgrade 'opam'
opam init
opam switch system
eval `opam config env`
opam update --use-internal-solver
opam install camlp4 core ounit
fancy_echo "Installation complete. Refresh your source, then run make to build
the project"