-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathprerequisites-macOS.sh
executable file
·138 lines (111 loc) · 4.34 KB
/
prerequisites-macOS.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
#!/usr/bin/env bash
echo "
The Hercules build process will require a number of basic tools and
packages which are not installed by default on MacOS. This script
will attempt to determine if they are missing, and install them
automatically.
These are:
- Xcode command line tools
- HomeBrew package manager
You may be asked to supply your sudo password.
Press Ctrl+C at any prompt if you wish to quit the process.
"
uname -a
uname_system="$( (uname -s) 2>/dev/null)" || uname_system="unknown"
if [ "$uname_system" == "Darwin" ]; then
version_distro="darwin"
fi
version_id="darwin"
# version_str=$(uname -r)
version_str=$(sw_vers -productVersion)
echo "VERSION_ID : $version_id"
echo "VERSION_STR : $version_str"
version_major=$(echo $version_str | cut -f1 -d.)
echo "VERSION_MAJOR : $version_major"
version_minor=$(echo $version_str | cut -f2 -d.)
echo "VERSION_MINOR : $version_minor"
version_build=$(echo $version_str | cut -f3 -d.)
echo "VERSION_BUILD : $version_build"
if [[ $version_major -eq 10 && $version_minor -eq 12 ]]; then
os_is_supported=true
echo "Apple macOS version $version_str (Sierra) found"
elif [[ $version_major -eq 10 && $version_minor -eq 13 ]]; then
os_is_supported=true
echo "Apple macOS version $version_str (High Sierra) found"
elif [[ $version_major -eq 10 && $version_minor -eq 14 ]]; then
os_is_supported=true
echo "Apple macOS version $version_str (Mojave) found"
elif [[ $version_major -eq 10 && $version_minor -eq 15 ]]; then
os_is_supported=true
echo "Apple macOS version $version_str (Catalina) found"
elif [[ $version_major -eq 11 ]]; then
os_is_supported=true
if [[ "$(uname -m)" =~ ^arm64 ]]; then
echo "Apple macOS version $os_version_str (Big Sur) on ARM CPU found"
else
echo "Apple macOS version $os_version_str (Big Sur) found"
fi
elif [[ $version_major -eq 12 ]]; then
os_is_supported=true
if [[ "$(uname -m)" =~ ^arm64 ]]; then
echo "Apple macOS version $os_version_str (Monterey) on ARM CPU found"
else
echo "Apple macOS version $os_version_str (Monterey) found"
fi
elif [[ $version_major -eq 13 ]]; then
os_is_supported=true
if [[ "$(uname -m)" =~ ^arm64 ]]; then
echo "Apple macOS version $os_version_str (Ventura) on ARM CPU found"
else
echo "Apple macOS version $os_version_str (Ventura) found"
fi
else
os_is_supported=false
echo "Apple macOS version $version_major.$version_minor found, is unsupported"
fi
echo # print a newline
echo "Checking for Xcode command line tools"
xcode-select -p 2>/dev/null
if [[ $? == 2 ]] ; then
echo "Requesting installation of Xcode command line tools"
read -p "Hit return to continue (Ctrl+C to abort)"
xcode-select --install
else
echo "Command line tools appear to be installed"
if (cc --version 2>&1 | head -n 1 | grep -Fiqe "xcrun: error: invalid active developer path"); then
echo "But the C compiler does not work"
echo "$(cc --version 2>&1)"
echo # print a newline
echo "Attempting xcode-select --install"
xcode-select --install
else
echo "compiler: $(cc --version 2>&1 | head -n 1)"
fi
fi
echo # print a newline
which -s brew
if [[ $? != 0 ]] ; then
echo "Installing Homebrew"
read -p "Hit return to continue (Ctrl+C to abort)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
echo "Updating Homebrew"
read -p "Hit return to continue (Ctrl+C to abort)"
brew update
fi
echo # print a newline
# Install Bash 4 if desired
if false ; then
if ((BASH_VERSINFO[0] >= 4)); then
echo "Bash version 4+ is already installed"
else
echo "Bash version 4+ is required"
fi
echo "Installing Bash via Homebrew"
read -p "Hit return to continue (Ctrl+C to abort)"
brew install bash
sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells'
chsh -s /usr/local/bin/bash
ln -s /usr/local/bin/bash /usr/local/bin/bash-terminal-app
which -a bash
fi