-
Notifications
You must be signed in to change notification settings - Fork 6
/
buildTAK.sh
executable file
·179 lines (141 loc) · 4.48 KB
/
buildTAK.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
#!/bin/bash
# Verbose output
#set -x
# Stop on Error
set -e
PREBUILD=0
CLEAN=0
newTAK=
SKIP=0
usage() { printf "Usage: $0 [-pcs ] -f flavor\n\t-p\tJust run prebuild\n\t-c\tclean everything\n\t-s\tskip build pre-requistes\n\n" 1>&2; exit 1; }
while getopts "scpf:" options;
do
case "${options}" in
p)
PREBUILD=1
;;
c)
CLEAN=1
;;
f)
newTAK=${OPTARG}
;;
s)
SKIP=1
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z ${newTAK} ];
then
usage
fi
PWD=`pwd`
export ANDROID_NDK_HOME=${PWD}/android-ndk-r12b
export ANDROID_NDK=${PWD}/android-ndk-r12b
export ANDROID_SDK_ROOT=${PWD}/sdk
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
ANDROID_SDK_ROOT=${PWD}/sdk
CMAKE_DIR=${PWD}/cmake-3.14.7-Linux-x86_64
PATH=${PATH}:${CMAKE_DIR}/bin
if [ ${SKIP} == 0 ];
then
# Install the pre-requisites to build the system
sudo apt -y install git git-lfs python3-pip dos2unix cmake build-essential tcl ninja-build libxml2-dev \
libssl-dev sqlite3 zlib1g-dev ant openjdk-8-jdk automake autoconf libtool swig cmake apg g++ \
make tcl patch libogdi-dev
sudo pip3 install conan
fi
if [ ! -d ${ANDROID_NDK_HOME} ];
then
wget https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip
unzip -q android-ndk-r12b-linux-x86_64.zip
fi
if [ ! -d ${ANDROID_SDK_ROOT} ];
then
wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
unzip -q commandlinetools-linux-8512546_latest.zip
echo "y" | ./cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT} --licenses
echo "y" | ./cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT} --install "platforms;android-29"
fi
if [ ! -d cmake-3.14.7-Linux-x86_64 ];
then
wget https://cmake.org/files/v3.14/cmake-3.14.7-Linux-x86_64.tar.gz
tar -zxpf cmake-3.14.7-Linux-x86_64.tar.gz
fi
if [ ! -d ${newTAK} ];
then
git clone https://github.com/deptofdefense/AndroidTacticalAssaultKit-CIV.git ${newTAK}
cd ${newTAK}
git lfs install --local
git lfs fetch
git lfs checkout
git submodule update --init --recursive
cp ../prebuild.sh scripts
cp ../build.gradle atak
cd scripts
./prebuild.sh
cd ../atak
### Changes the output APK name
# sed -i "s/ATAK-/${newTAK}-/" ATAK/app/build.gradle
else
cd ${newTAK}
# If the user wants a clean then whack everything
if [ ${CLEAN} == 1 ];
then
cd atak; ./gradlew clean; cd ../
rm -rf assimp gdal takengine/thirdparty libLAS LASzip
fi
# If the user just wants to run prebuild then exit
if [ ${PREBUILD} == 1 ];
then
cp ../prebuild.sh scripts
cd scripts
./prebuild.sh
printf "Finished building ATAK requirements\n"
exit
fi
cd atak
fi
KEYFILE="`pwd`/${newTAK}.keystore"
if [ -f ${KEYFILE} ];
then
rm -f ${KEYFILE}
fi
STOREPASSWORD="1qazxsw2${newTAK}"
KEYPASSWORD="1qazxsw2${newTAK}"
keytool -keystore ${newTAK}.keystore -genkey -noprompt -keyalg RSA -alias debug -dname "CN=Unknown, OU=Unknown, O=\"Vertex Geospatial, Inc.\", L=New Hartford, ST=New York, C=US" -storepass ${STOREPASSWORD} -keypass ${KEYPASSWORD}
keytool -keystore ${newTAK}.keystore -genkey -noprompt -keyalg RSA -alias release -dname "CN=Unknown, OU=Unknown, O=\"Vertex Geospatial, Inc.\", L=New Hartford, ST=New York, C=US" -storepass ${STOREPASSWORD} -keypass ${KEYPASSWORD}
if [ ! -f android_keystore ];
then
ln -s ${KEYFILE} android_keystore
fi
cp ../../template_local.properties local.properties
sed -i "s#{NDKDIR}#${ANDROID_NDK_HOME}#g" local.properties
sed -i "s#{SDKDIR}#${ANDROID_SDK_ROOT}#g" local.properties
sed -i "s#{CMAKEDIR}#${CMAKE_DIR}#g" local.properties
sed -i "s#{KEYFILE}#${KEYFILE}#g" local.properties
sed -i "s/{KEYPASSWORD}/${KEYPASSWORD}/g" local.properties
sed -i "s/{STOREPASSWORD}/${STOREPASSWORD}/g" local.properties
export takRepoConanUrl=
export takRepoUsername=
export takRepoPassword=
# Do NOT Stop on Error
set +e
./gradlew generateJniHeaders assembleCivRelease
cd ../scripts
# Khronos
cp khronos-conanfile.py ../khronos/conanfile.py
pushd ../khronos
conan export-pkg . -f
popd
cd ../atak
./gradlew assembleCivRelease
mkdir ../release
ATAKAPK=`ls ATAK/app/build/outputs/apk/civ/release/ATAK*.apk`
BASEAPKNAME=`basename ${ATAKAPK}`
NEWAPKNAME=`echo ${BASEAPKNAME} | sed "s/ATAK/${newTAK}/"`
mv ATAK/app/build/outputs/apk/civ/release/ATAK*.apk ../${NEWAPKNAME}