This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
install_dependencies.sh
executable file
·132 lines (103 loc) · 2.56 KB
/
install_dependencies.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
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
#! /bin/sh
cd "${0%/*}"
set -o pipefail
mkdir build > /dev/null 2>&1
exe() { echo "\$ ${@/eval/}" ; "$@" ; }
verify() {
if [ ! $(which $1) ]; then
echo 'ERROR: $1 still not installed. Aborting'
exit 1
fi
}
# Bundle
install_bundle() {
echo 'Installing bundle'
# Bundle install
if ! which bundle > /dev/null; then
exe gem install bundler
fi
if bundle check > /dev/null; then
echo " -> bundle dependencies already installed"
return
fi
exe bundle install
if ! bundle check > /dev/null; then
echo "ERROR: bundle still not installed. Aborting"
exit 1
fi
}
# Websocket server
install_websocket() {
echo 'Installing Python requirements'
if [ ! -f venv/bin/activate ]; then
if which virtualenv > /dev/null; then
echo 'Creating virtual env'
exe virtualenv -p python3 "$(pwd)/venv"
else
echo ' -> virtualenv not installed.'
fi
fi
if [ -f venv/bin/activate ]; then
exe source venv/bin/activate
else
echo ' -> Virtual env not found. Attempting to install anyway'
fi
if [ "$(pip3 freeze)" = "$(cat requirements.txt)" ]; then
echo ' -> requirements already installed'
return
fi
if ! which pip3 > /dev/null; then
echo 'Installing pip'
exe easy_install --user pip && export PATH=/Users/travis/Library/Python/2.7/bin:${PATH}
fi
echo 'Installing requirements'
exe pip3 install -r requirements.txt
}
# Homebrew
install_homebrew() {
if ! which homebrew > /dev/null; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
}
# Swiftlint
install_swiftlint() {
echo 'Installing swiftlint'
if which swiftlint > /dev/null; then
echo ' -> Swiftlint already installed'
return
fi
install_homebrew
exe brew install swiftlint
verify "swiftlint"
}
# Carthage
install_carthage() {
echo 'Installing Carthage'
if which carthage > /dev/null; then
echo ' -> Carthage already installed'
return
fi
install_homebrew
exe brew install carthage
}
xcode_error() {
if [[ ! -z "$XCODE_VERSION_MAJOR" ]]; then
echo "$(pwd)/Classes/RxWebSocket.swift:$1: "
else
echo ""
fi
}
if [[ "$1" == 'verify' ]]; then
if [ ! -f build/.deps ] && [ "$CARTHAGE" != "YES" ]; then
echo `xcode_error 1` "error: Dependencies not installed"
echo `xcode_error 2` "error: Run \`$(pwd)/install_dependencies.sh\` to install all required dependencies"
exit 2
fi
exit 0
fi
install_bundle
install_websocket
install_swiftlint
install_carthage
echo 'Success! All requirements are installed'
touch build/.deps