Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 96 lines (76 sloc) 2.663 kB
1f80d31 add python build script hard coded for memcached. should provide bas…
Christian Carey authored
1 #!/usr/bin/env python
2 import os, sys, tarfile, shutil
3 import subprocess as proc
4 import warnings
5
6 warnings.filterwarnings('ignore','.*apt API not stable yet.*')
7 import apt
8
44bc6a3 add script to start memcached and a test to make sure it's running
Christian Carey authored
9 TOOLS_BIN_FOLDER = 'tmp/tar/dolomite-env/bin'
10
e9e53ba refactor directory create
Christian Carey authored
11 def create_dir(name):
12 if not os.path.exists(name):
44bc6a3 add script to start memcached and a test to make sure it's running
Christian Carey authored
13 #os.mkdir(name)
14 os.makedirs(name)
e9e53ba refactor directory create
Christian Carey authored
15
1f80d31 add python build script hard coded for memcached. should provide bas…
Christian Carey authored
16 def dependenciesMet(packages):
17 met = True
18 cache = apt.Cache()
19 for package in packages:
20 pkg = cache[package]
21 if not pkg.isInstalled:
22 print("%s package is not installed." % package)
23 met = False
24 return met
32310df convert build script to configured build
Christian Carey authored
25
26 def copy_built_files(files, build_dir):
0865fd5 correct issue with the copy built files list check.
Christian Carey authored
27 if type(files) is list:
48a42d7 correct issue with build file copy when only one file exists
Christian Carey authored
28 for f in files:
44bc6a3 add script to start memcached and a test to make sure it's running
Christian Carey authored
29 shutil.copy('tmp/%s/%s' % (build_dir, f), TOOLS_BIN_FOLDER)
48a42d7 correct issue with build file copy when only one file exists
Christian Carey authored
30 else:
44bc6a3 add script to start memcached and a test to make sure it's running
Christian Carey authored
31 shutil.copy('tmp/%s/%s' % (build_dir, files), TOOLS_BIN_FOLDER)
32310df convert build script to configured build
Christian Carey authored
32
33 def usage():
34 print("Usage: %s component_name" % sys.argv[0])
1f80d31 add python build script hard coded for memcached. should provide bas…
Christian Carey authored
35
32310df convert build script to configured build
Christian Carey authored
36 def get_config(component):
37 config_file = open("%s-conf" % component)
38 config = { }
39 for setting in config_file:
40 if len(setting.split('=')) > 1:
41 if (len(setting.split(' '))) > 1:
42 config[setting.split('=')[0]] = setting.rstrip('\n').split('=')[1].split(' ')
43 else:
44 config[setting.split('=')[0]] = setting.rstrip('\n').split('=')[1]
45 return config
46
1f80d31 add python build script hard coded for memcached. should provide bas…
Christian Carey authored
47 def main():
32310df convert build script to configured build
Christian Carey authored
48 if len(sys.argv) != 2:
49 usage()
50 sys.exit(1)
51 component = sys.argv[1]
52
53 print("building %s" % component)
54
55 config = get_config(component)
56
44bc6a3 add script to start memcached and a test to make sure it's running
Christian Carey authored
57 create_dir(TOOLS_BIN_FOLDER)
e9e53ba refactor directory create
Christian Carey authored
58
1f80d31 add python build script hard coded for memcached. should provide bas…
Christian Carey authored
59 os.chdir('tmp')
60
61 print("checking build depedencies...")
32310df convert build script to configured build
Christian Carey authored
62 if not dependenciesMet(config['BUILDDEP']):
63 print("install dependencies using the following command and try again")
64 print("sudo apt-get install %s" % " ".join(config['BUILDDEP']))
1f80d31 add python build script hard coded for memcached. should provide bas…
Christian Carey authored
65 sys.exit(1)
66
67 print("downloading source...")
68 try:
32310df convert build script to configured build
Christian Carey authored
69 proc.check_call(['wget','-c', '%s/%s' % (config['SOURCEPATH'], config['SOURCETARFILE'])])
1f80d31 add python build script hard coded for memcached. should provide bas…
Christian Carey authored
70 except proc.CalledProcessError:
71 sys.exit(1)
72
73 print("extracting tar ball...")
32310df convert build script to configured build
Christian Carey authored
74 memcached = tarfile.open(name=config['SOURCETARFILE'], mode='r:gz')
1f80d31 add python build script hard coded for memcached. should provide bas…
Christian Carey authored
75 memcached.extractall()
76
77 print("configuring...")
32310df convert build script to configured build
Christian Carey authored
78 os.chdir(config['BUILDDIR'])
1f80d31 add python build script hard coded for memcached. should provide bas…
Christian Carey authored
79 try:
80 proc.check_call(['./configure'])
81 except proc.CalledProcessError:
82 sys.exit(1)
83
84 print("building...")
85 try:
86 proc.check_call(['make'])
87 except proc.CalledProcessError:
88 sys.exit(1)
89
90 print("copying built files...")
91 os.chdir('../..')
32310df convert build script to configured build
Christian Carey authored
92 copy_built_files(config['INSTALLFILES'], config['BUILDDIR'])
1f80d31 add python build script hard coded for memcached. should provide bas…
Christian Carey authored
93
94 if __name__ == "__main__":
95 main()
Something went wrong with that request. Please try again.