summaryrefslogtreecommitdiff
path: root/scripts/install_cmake.py
blob: fef8be0e7bcbeba6d2613f74a3734a589c7ef683 (plain)
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
import sys
import os
import os.path

import sh
from sh import git, cd, make, rm, sudo, cp, chmod, mkdir

def write_output(line):
	sys.stdout.write(line)

curl = sh.Command("curl")
tar = sh.Command("tar")

install_env = os.environ.copy()
install_env['CC'] = "gcc"

directory = os.path.dirname(os.path.realpath(__file__))

# Download it
cd(directory)
curl(
	"-L",
	"http://www.cmake.org/files/v3.2/cmake-3.2.2-Linux-x86_64.sh",
	_out="cmake_installer.sh"
)

# Set up the installer
installer_path = os.path.join(directory, "cmake_installer.sh")
chmod("a+x", installer_path)
cmake_installer = sh.Command(installer_path)

# Verify the download
sum_str = sh.Command("openssl").sha1(installer_path)
expected_sum = "925e6185e94b717760453427b857fc4f2a4c2149"
if sum_str.split()[1] != expected_sum:
	raise Exception

# Install it
print("Installing...")
if os.environ.get("XMAP_TRAVIS_BUILD", None):
	print("Travis CI build, installing to /opt")
	with sudo:
		cmake_installer(prefix="/opt", exclude_subdir=True)
else:
	prefix = os.path.join(directory, "cmake")
	mkdir(prefix)
	print("Installing to {}".format(prefix))
	cmake_installer(prefix=prefix, exclude_subdir=True)

print("Done.")