forked from GaloisInc/OpenUxAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_prerequisites.sh
executable file
·240 lines (204 loc) · 8.36 KB
/
install_prerequisites.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/bin/bash
# Copyright © 2017 Government of the United States of America, as represented by the Secretary of the Air Force.
# No copyright is claimed in the United States under Title 17, U. S. Code. All Other Rights Reserved.
# Copyright 2017 University of Cincinnati. All rights reserved. See LICENSE.md file at:
# https://github.com/afrl-rq/OpenUxAS
# Additional copyright may be held by others, as reflected in the commit history.
set -e
# from the README.md, 2017-05-11:
# references:
# * http://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux/17072017#17072017
# * https://serverfault.com/questions/501230/can-not-seem-to-get-expr-substr-to-work
# Confirm shell
[ "`ps -o comm= $$`" = bash ] || { echo "`ps -o comm= $$` is not bash"; exit 1; }
# Confirm non-root user
[ $USER = root ] && { echo "Do not run this script as root"; exit 1; }
# Preauthorize sudo
sudo -k && sudo -v || { echo "sudo not authenticated"; exit 1; }
while true; do sudo -n true; sleep 60; kill -s 0 $$ || exit; done 2>/dev/null &
if [ "$(uname)" == "Darwin" ]; then
echo "The Mac/Darwin portion of this script is out of date."
echo "Please update using the Fedora section as a guide."
exit 1
## FIXME:
echo "Install Prerequisites on Mac OS X"
echo " "
echo "Install XCode"
echo "* Get yourself a developer account and grab the file from: https://developer.apple.com/xcode/"
echo " (This cannot be downloaded automatically due to the need to agree to license &etc. terms.)"
echo " (So, download from website manually and install the .dmg file.)"
echo "Once you've done this..."
echo "Press any key to continue..."
# as of 2017-05-08, this is: ????.dmg
# ref: https://superuser.com/questions/689315/run-safari-from-terminal-with-given-url-address-without-open-command
# ref: https://www.macissues.com/2014/09/18/how-to-launch-and-quit-applications-in-os-x-using-the-terminal/
/Applications/Safari.app/Contents/MacOS/Safari & sleep 1 && osascript -e 'tell application "Safari" to open location "https://developer.apple.com/xcode/"'
#echo "* Install .dmg"
read -rs -p " " -n 1 # reference: https://ss64.com/bash/read.html
echo " "
# Enable commandline tools: in terminal
xcode-select --install
# Install homebrew (must be administrator): in terminal
sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Add homebrew to path: in terminal
echo `export PATH="/usr/local/bin:$PATH"` >> ~/.bash_profile
source ~/.bash_profile # bash
brew tap caskroom/cask
# Install git: in terminal
brew install git
# Install unique ID library: in terminal
brew install ossp-uuid
# Install Boost library and configure it in a fresh shell: in terminal
brew install boost
echo 'export BOOST_ROOT=/usr/local' >> ~/.bash_profile
source ~/.bash_profile # bash
# Install pip3: in terminal
brew install python3
curl -O https://bootstrap.pypa.io/get-pip.py
sudo -H python3 get-pip.py
# Install ninja build system: in terminal
brew install cmake
brew install pkg-config
sudo -H pip3 install scikit-build
sudo -H pip3 install ninja
# Install meson build configuration: in terminal
sudo -H pip3 install meson==0.42.1
# Install python plotting capabilities (optional): in terminal
sudo -H pip3 install matplotlib
sudo -H pip3 install pandas
# Install Oracle JDK
brew cask install java
# Install ant for command line build of java programs
brew install ant
echo "Dependencies installed!"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
if [ -n "$(which apt 2>/dev/null)" ]; then
echo "Installing Prerequisite Tools on Ubuntu Linux"
# run an 'apt update' check without sudo
# ref: https://askubuntu.com/questions/391983/software-updates-from-terminal-without-sudo
##aptdcon --refresh
NUMBER_UPGRADEABLE=`apt-get -s upgrade | grep "upgraded," | cut -d' ' -f1`
if [ $NUMBER_UPGRADEABLE -gt 0 ]
then
echo "Some packages require updating, running apt update-upgrade as sudo now..."
sudo apt -y update
sudo apt -y upgrade
echo "Done with apt update-upgrade!"
fi
# Install pkg-config for finding link arguments
sudo apt -y install pkg-config
# Install git
sudo apt -y install git
sudo apt -y install gitk
# Install ed
sudo apt -y install ed
# Install opengl development headers
sudo apt -y install libglu1-mesa-dev
# Install unique ID creation library
sudo apt -y install uuid-dev
# Install Boost libraries (**optional but recommended**; see external dependencies section): in terminal
sudo apt-get -y install libboost-filesystem-dev libboost-regex-dev libboost-system-dev
# Install pip3: in terminal
sudo apt -y install python3-pip
##sudo -H pip3 install --upgrade pip
# Install tkinter
sudo apt -y install python3-tk
# Install ant for command line build of java programs
sudo apt -y install ant
# We probably have xterm; be certain.
sudo apt -y install xterm
# Install ninja build system
sudo -H pip3 install ninja
# Install meson build configuration
sudo -H pip3 install meson==0.42.1
# Install python plotting capabilities (optional)
sudo -H pip3 install matplotlib
sudo -H pip3 install pandas
# Install Java
sudo apt -y install default-jre
# Install ant for command line build of java programs
sudo apt -y install ant
# Remove any other version of ZMQ
# If another exists meson will point at it and then
# you'll get compile errors.
echo "HEY: I'm uninstalling your ZMQ packages so meson will use it's native copy."
sudo apt remove libzmq3-dev
sudo apt remove libzmq5
# Extend paths for pip --user option
source ./path.sh
# Pinning meson is understandable for now; the API is in flux.
[ -n "$PYTHONUSERBASE" ] || { echo "PYTHONUSERBASE is not set"; exit 1; }
mkdir -p $PYTHONUSERBASE
pip3 install --user meson==0.42.1
fi # have apt; must be Ubuntu
# IMPORTANT: This Fedora installation is the model for all other platforms.
if [ -n "$(which dnf 2>/dev/null)" ]; then
echo "Installing Prerequisite packages on Fedora Linux"
# These should be the same packages (perhaps with different names) as above
sudo dnf -y install pkgconf git gitk ed mesa-libGLU-devel uuid-devel \
boost-devel python3-pip python3-tkinter ant xterm redhat-rpm-config \
gcc-c++ python3-devel ninja-build python3-matplotlib python3-pandas \
java-1.8.0-openjdk-devel
# Extend paths for pip --user option
source ./path.sh
# Pinning meson is understandable for now; the API is in flux.
[ -n "$PYTHONUSERBASE" ] || { echo "PYTHONUSERBASE is not set"; exit 1; }
mkdir -p $PYTHONUSERBASE
pip3 install --user meson==0.42.1
fi # have dnf; must be Fedora
echo "Dependencies installed!"
else
echo "Unsupported platform! Only Ubuntu Linux and Mac OSX supported"
exit 1
fi
echo "Configuring UxAS"
#check to see if already in OpenUxAS
current_directory=${PWD##*/}
git_directory=$PWD'/.git'
if [ $current_directory != "OpenUxAS" ] || [ ! -d $git_directory ]; then
echo "Checking out OpenUxAS ..."
git clone -b develop --single-branch https://github.com/afrl-rq/OpenUxAS.git
fi
# ensure one directory above OpenUxAS
if [ $current_directory == "OpenUxAS" ] && [ -d $git_directory ]; then
cd ..
fi
if [ ! -d LmcpGen ]; then
echo "Checking out LmcpGen ..."
git clone https://github.com/afrl-rq/LmcpGen.git
fi
cd LmcpGen
ant -q jar
cd ..
if [ ! -d OpenAMASE ]; then
echo "Checkout out OpenAMASE..."
git clone https://github.com/afrl-rq/OpenAMASE.git
fi
cd OpenAMASE/OpenAMASE
ant -q jar
cd ../..
echo "Configuring UxAS plotting utilities ..."
cd OpenUxAS/src/Utilities/localcoords
sudo python3 setup.py install
cd ../../..
echo "Preparing UxAS build ..."
rm -rf build_release build_debug
python3 prepare
sh RunLmcpGen.sh
( cd src/separate_compilation && sh RunLmcpGen.sh )
meson build_release --buildtype=release
meson build_debug --buildtype=debug
echo "Performing initial UxAS build ..."
ninja -C build_debug
ninja -C build_release
# Alias the debug build
ln -s build_debug build
cat <<'EOF'
================================================================
DONE!
Subsequent builds are done using:
$ ninja -C build_debug
and
$ ninja -C build_release
EOF
# --eof--