-
Notifications
You must be signed in to change notification settings - Fork 3
/
install-mac.command
executable file
·159 lines (138 loc) · 3.85 KB
/
install-mac.command
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env bash
dir=${0%/*}; if [ "$dir" = "$0" ]; then dir="."; fi; cd "$dir";
# Library functions
function uncomment {
[ -z "$1" ] && return || local m="$1";
[[ $m =~ ^(.*)(#.*) ]]; # Remove comment string
[ ! -z "${BASH_REMATCH[2]}" ] && local m="${BASH_REMATCH[1]}";
echo "$m";
}
function pp {
echo;
echo -e "\e[96m[svgop] $1";
echo;
}
function pins {
pp "Installing $1...";
}
function pup {
info "Updating $1...";
}
function pok {
echo;
echo -e "\e[92m[madcow] $1";
echo;
}
function perr {
echo;
echo -e "\e[91m[madcow][ERROR] $1";
echo;
exit;
}
function pwarn {
echo;
echo -e "\e[91m[madcow][ATTENTION] $1";
echo;
}
function insbrew {
if [ ! -x "$(which brew)" ]; then
pins "brew";
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)";
fi;
}
function pkgbrew {
# Install package if not installed
# $ pkgbrew go
[ -z "$1" ] && return || local pkg="$1";
insbrew;
if [ -x "$(touch $(brew --prefix)/var/testX6mg87lk)" ]; then
pwarn "`brew` needs to fix permissions, enter your administrator password:"
sudo chown -R $(whoami) $(brew --prefix)/*;
sudo chown $(whoami) $(brew --prefix)/*;
brew list -1 | while read pkg; do brew unlink "$pkg"; brew link "$pkg"; done
else
rm "$(brew --prefix)/var/testX6mg87lk";
fi;
if brew ls --versions "$pkg" >/dev/null; then
pup "brew:$pkg"; HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade "$pkg";
else
pins "brew:$pkg"; HOMEBREW_NO_AUTO_UPDATE=1 brew install "$pkg"
fi
}
function needbrew {
# $ needbrew package # if command=package
# $ needbrew command package # if command!=package
[ -z "$1" ] && return || local cmd="$1";
[ -z "$2" ] && local pkg="$cmd" || local pkg="$2";
if [ ! -x "$(which $cmd)" ]; then
pkgbrew "$pkg";
fi;
}
function needbrewpy2 {
if [ ! -x "$(which python2)" ]; then
needbrew python2 python@2;
brew link --overwrite python@2;
fi;
}
function needbrewpy3 {
if [ ! -x "$(which python3)" ]; then
needbrew python3 python;
brew link --overwrite python;
fi;
}
function needgo {
# $ needgo command github.com/author/repo [args...]
[ -z "$1" ] && return || local cmd="$1";
[ -z "$2" ] && return || local pkg="$2";
needbrew go;
if [ ! -x "$(which $cmd)" ]; then
pins "go:$pkg"; go get -u "$pkg" "${@:3}";
fi;
}
function needrust {
# $ needrust command --git https://github.com/author/repo [args...]
[ -z "$1" ] && return || local cmd="$1";
[ -z "$2" ] && return || local pkg="$2";
needbrew cargo rust;
if [ ! -x "$(which $cmd)" ]; then
pins "rust:$pkg"; cargo install "$pkg" "${@:3}";
fi;
}
function needpy2 {
# $ needpy2 command package [package...]
[ -z "$1" ] && return || local cmd="$1";
[ -z "$2" ] && return || local pkg="$2";
needbrewpy2;
if [ ! -x "$(which $cmd)" ]; then
pins "py2:$pkg"; python2 -m pip install --user --upgrade "$pkg" "${@:3}";
fi;
}
function needpy3 {
# $ needpy3 command package [package...]
[ -z "$1" ] && return || local cmd="$1";
[ -z "$2" ] && return || local pkg="$2";
needbrewpy3;
if [ ! -x "$(which $cmd)" ]; then
pins "py3:$pkg"; python3 -m pip install --user --upgrade "$pkg" "${@:3}";
fi;
}
function neednode {
# $ neednode package # if command=package
# $ neednode command package [package...] # if command!=package
[ -z "$1" ] && return || local cmd="$1";
[ -z "$2" ] && local pkg="$cmd" || local pkg="$2";
needbrew npm node;
if [ ! -x "$(which $cmd)" ]; then
pins "node:$pkg";npm i -g npm "$pkg" "${@:3}";
fi;
}
function install {
needbrew node;
needbrew qjs quickjs;
neednode pkg;
neednode webpack;
}
install;
cd src;
npm i;
make all;