-
Notifications
You must be signed in to change notification settings - Fork 587
/
do
executable file
·87 lines (71 loc) · 2.56 KB
/
do
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
#!/usr/bin/env bash
# You may redistribute this program and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
CMAKE_DOWNLOAD=http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
CMAKE_SHA256=2b59897864d6220ff20aa8eac64cac8994e004898a1c0f899c8cb4d7b7570b46
# get a sha256sum implementation.
getsha256sum() {
local testhash=4ee73c05d5158b0fdfec9f5e52cab3fa85b98d6992a221bbff28fdbd935e8afc
local testfile=test/$testhash
local program
for program in 'sha256sum' 'gsha256sum' 'shasum -a 256' 'openssl sha256'; do
if $program $testfile 2>/dev/null | grep -qs "$testhash"; then
SHA256SUM=$program
return 0
fi
done
echo "Couldn't find a working sha256 tool."
return 1
}
cd "$(dirname "$0")"
mkdir -p build
cd build
CMAKE=$PWD/cmake-build/bin/cmake
if [ ! -x "$CMAKE" ]; then
CMAKE=$(which cmake)
fi
if ! { [ -x "$CMAKE" ] && "$CMAKE" --version |
egrep 'version 2\.8\.([2-9]|[1-9][0-9]+)(\.|$)'; }; then
set -e # exit if a command fails
rm -rf cmake-build
mkdir cmake-build
cd cmake-build
getsha256sum
if which wget >&/dev/null; then
wget "$CMAKE_DOWNLOAD" -O cmake.tar.gz
elif which curl >&/dev/null; then
curl "$CMAKE_DOWNLOAD" -o cmake.tar.gz
else
echo "Please download the following file to 'cmake.tar.gz'"
echo " $CMAKE_DOWNLOAD"
exit 1
fi
if ! $SHA256SUM cmake.tar.gz | grep -qs "$CMAKE_SHA256"; then
echo "Checksum of cmake.tar.gz incorrect"
exit 1
fi
tar -xf cmake.tar.gz
find . -mindepth 1 -maxdepth 1 -type d -exec mv {} build \;
build/configure
make
CMAKE="$PWD/bin/cmake"
cd ..
set +e
fi
set -e
$CMAKE ..
make
# I'm not drunk enough to understand this.
make test || rm cjdroute &&
[ -f admin/angel/cjdroute2 ] && [ ! -f ../cjdroute ] || rm ../cjdroute && cp admin/angel/cjdroute2 ../cjdroute &&
[ -f admin/angel/cjdns ] && [ ! -f ../cjdns ] || rm ../cjdns && cp admin/angel/cjdns ../ &&
echo -e "\033[1;32mBuild completed successfully, type ./cjdroute to begin setup.\033[0m"