forked from anandbagmar/AppiumJavaSample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_mac.sh
executable file
·150 lines (134 loc) · 5.52 KB
/
setup_mac.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env bash
set -e
arch_name="$(uname -m)"
if [ "${arch_name}" = "x86_64" ]; then
if [ "$(sysctl -in sysctl.proc_translated)" = "1" ]; then
echo "Running on Rosetta 2"
else
echo "Running on native Intel"
fi
elif [ "${arch_name}" = "arm64" ]; then
echo "Running on ARM"
else
echo "Unknown architecture: ${arch_name}"
fi
function brewCaskInstall() {
echo "Installing $1"
echo "On platform: $arch_name"
if "brew ls --versions $1" >/dev/null; then
echo "- $1 already installed"
else
if [ "${arch_name}" = "arm64" ]; then
"arch -arm64 brew install --cask $1"
else
"brew install --cask $1"
fi
fi
}
function brewInstall() {
echo "Installing $1"
echo "On platform: $arch_name"
if brew ls --versions "$1" >/dev/null; then
echo "- $1 already installed"
else
if [ "${arch_name}" = "arm64" ]; then
arch -arm64 brew install "$1"
else
brew install "$1"
fi
fi
}
CURRENT_DIR=$("pwd")
echo "============================================================"
echo "Prerequisites: Install JDK and set JAVA_HOME environment variable. Also set ANDROID_HOME environment variable pointing to a directory where Android SDK should be installed"
echo "============================================================"
echo "CURRENT_DIR - $CURRENT_DIR"
echo "JAVA_HOME - $JAVA_HOME"
echo "ANDROID_HOME - $ANDROID_HOME"
echo "On platform: $arch_name"
echo "============================================================"
[ -z "$JAVA_HOME" ] && echo "JAVA_HOME is NOT SET AS AN ENVIRONMENT VARIABLE. Set it first then rerun the script" && exit 1
[ -z "$ANDROID_HOME" ] && echo "ANDROID_HOME is NOT SET AS AN ENVIRONMENT VARIABLE. Set it first then rerun the script" && exit 1
brewInstall node
brewInstall coreutils
brewInstall wget
brewInstall cmake
brewInstall carthage
brewInstall ruby
brewInstall ffmpeg
brewInstall mp4box
brewInstall ideviceinstaller
brewInstall libimobiledevice
brewInstall lyft/formulae/set-simulator-location
brew tap wix/brew
brewInstall applesimutils
brewInstall gstreamer
brewInstall gst-plugins-base
brewInstall gst-plugins-good
brewInstall gst-plugins-bad
brewInstall gst-plugins-ugly
brewInstall gst-libav
if ! [ -d "$ANDROID_HOME" ]; then
mkdir -pv ./temp
DOWNLOADED_ZIP="./temp/tools.zip"
echo "ANDROID_HOME ($ANDROID_HOME) directory NOT present. Setting it up now"
mkdir -pv "$ANDROID_HOME"
chmod 777 "$ANDROID_HOME"
echo "Downloading android sdk"
rm -f "$DOWNLOADED_ZIP" 2>/dev/null
wget https://dl.google.com/android/repository/commandlinetools-mac-8092744_latest.zip -O "$DOWNLOADED_ZIP"
unzip "$DOWNLOADED_ZIP" -d "$ANDROID_HOME"
sleep 5
else
echo "ANDROID_HOME ($ANDROID_HOME) directory present. already set. IF YOU WANT TO REINSTALL, delete directory - $ANDROID_HOME and run the ./setup_mac.sh script again"
fi
echo "Setup android sdk"
cd "$ANDROID_HOME/cmdline-tools/latest/bin"
pwd
BUILD_TOOLS_VERSION=32.0.0
echo "Installing ./sdkmanager --sdk_root=$ANDROID_HOME tools build-tools;$BUILD_TOOLS_VERSION cmdline-tools;latest platforms;android-32 platforms;android-31" "system-images;android-30;google_apis_playstore;arm64-v8a"
pwd
./sdkmanager --sdk_root="$ANDROID_HOME" "tools" "build-tools;$BUILD_TOOLS_VERSION" "cmdline-tools;latest" "platforms;android-32" "platforms;android-31" "system-images;android-30;google_apis_playstore;arm64-v8a" "system-images;android-32;google_apis_playstore;arm64-v8a"
echo "Install Android system images to allow creating emulators"
if [ "${arch_name}" = "arm64" ]; then
echo "./sdkmanager --sdk_root=$ANDROID_HOME system-images;android-30;google_apis_playstore;arm64-v8a system-images;android-31;google_apis_playstore;arm64-v8a system-images;android-32;google_apis_playstore;arm64-v8a"
./sdkmanager --sdk_root="$ANDROID_HOME" "system-images;android-30;google_apis_playstore;arm64-v8a" "system-images;android-31;google_apis_playstore;arm64-v8a" "system-images;android-32;google_apis_playstore;arm64-v8a"
else
echo "./sdkmanager --sdk_root=$ANDROID_HOME system-images;android-29;google_apis_playstore;x86 system-images;android-29;google_apis_playstore;x86_64 system-images;android-30;google_apis_playstore;x86 system-images;android-30;google_apis_playstore;x86_64"
./sdkmanager --sdk_root="$ANDROID_HOME" "system-images;android-29;google_apis_playstore;x86" "system-images;android-29;google_apis_playstore;x86_64" "system-images;android-30;google_apis_playstore;x86" "system-images;android-30;google_apis_playstore;x86_64"
fi
sleep 5
echo "Done installing Android SDK in $ANDROID_HOME"
if ! [ -d "$ANDROID_HOME/bundle-tool" ]; then
echo "Setup bundletool"
cd "$ANDROID_HOME"
mkdir -pv bundle-tool
cd bundle-tool
wget https://github.com/google/bundletool/releases/download/1.8.0/bundletool-all-1.8.0.jar -O bundletool.jar
chmod +x bundletool.jar
else
echo "$ANDROID_HOME/bundle-tool already setup"
fi
cd "$CURRENT_DIR"
pwd
# echo "Install flick ruby gem"
# sudo gem install flick
# echo "Install opencv4nodejs"
# npm install -g opencv4nodejs
echo "Installed node version"
node -v
#echo "Install ios-deploy"
#npm install -g ios-deploy
echo "Install node modules - appium"
npm install -g appium
sleep 5
echo "Install node modules - appium-doctor"
npm install -g appium-doctor
sleep 5
echo "Run appium-doctor"
appium-doctor
echo "PLEASE ENSURE"
echo "-- ANDROID_HOME is set to $ANDROID_HOME"
echo "-- Update PATH:"
echo "---- 'export PATH=\$PATH:\$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION:\$ANDROID_HOME/bundle-tools:\$ANDROID_HOME/cmdline-tools\latest\bin:\$ANDROID_HOME/emulator:\$ANDROID_HOME/platform-tools:\$ANDROID_HOME/tools:\$ANDROID_HOME/tools/bin'"
pwd