Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: build/linux/sysroot_scripts/build_and_upload.py

Issue 2567123002: Sysroot: Add build_and_upload.py (Closed)
Patch Set: Return non-zero exit code if any sysroot builds failed Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/linux/sysroot_scripts/install-sysroot.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Automates running BuildPackageLists, BuildSysroot, and
7 UploadSysroot for each supported arch of each sysroot creator.
8 """
9
10 import glob
11 import hashlib
12 import json
13 import multiprocessing
14 import os
15 import re
16 import string
17 import subprocess
18 import sys
19
20 def run_script(args):
21 fnull = open(os.devnull, 'w')
22 subprocess.check_call(args, stdout=fnull, stderr=fnull)
23
24 def sha1sumfile(filename):
25 sha1 = hashlib.sha1()
26 with open(filename, 'rb') as f:
27 while True:
28 data = f.read(65536)
29 if not data:
30 break
31 sha1.update(data)
32 return sha1.hexdigest()
33
34 def get_proc_output(args):
35 return subprocess.check_output(args).strip()
36
37 def build_and_upload(script_path, distro, release, arch, lock):
38 # TODO(thomasanderson): Find out which revision 'git-cl upload' uses to
39 # calculate the diff against and use that instead of HEAD.
40 script_dir = os.path.dirname(os.path.realpath(__file__))
41 revision = get_proc_output(['git', '-C', script_dir, 'rev-parse', 'HEAD'])
42
43 run_script([script_path, 'UpdatePackageLists%s' % arch])
44 run_script([script_path, 'BuildSysroot%s' % arch])
45 run_script([script_path, 'UploadSysroot%s' % arch, revision])
46
47 tarball = '%s_%s_%s_sysroot.tgz' % (distro, release, arch.lower())
48 tgz_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
49 "..", "..", "..", "out", "sysroot-build",
50 release, tarball)
51 sha1sum = sha1sumfile(tgz_path)
52 sysroot_dir = '%s_%s_%s-sysroot' % (distro, release, arch.lower())
53
54 sysroot_metadata = {
55 'Revision': revision,
56 'Tarball': tarball,
57 'Sha1Sum': sha1sum,
58 'SysrootDir': sysroot_dir
59 }
60 with lock:
61 with open('sysroots.json', 'rw+') as f:
62 sysroots = json.load(f)
63 sysroots["%s_%s" % (release, arch.lower())] = sysroot_metadata
64 f.seek(0)
65 f.truncate()
66 f.write(json.dumps(sysroots, sort_keys=True, indent=4,
67 separators=(',', ': ')))
68 f.write('\n')
69
70 def main():
71 script_dir = os.path.dirname(os.path.realpath(__file__))
72 procs = []
73 lock = multiprocessing.Lock()
74 for filename in glob.glob(os.path.join(script_dir, 'sysroot-creator-*.sh')):
75 script_path = os.path.join(script_dir, filename)
76 distro = get_proc_output([script_path, 'PrintDistro'])
77 release = get_proc_output([script_path, 'PrintRelease'])
78 architectures = get_proc_output([script_path, 'PrintArchitectures'])
79 for arch in architectures.split('\n'):
80 proc = multiprocessing.Process(target=build_and_upload,
81 args=(script_path, distro, release, arch,
82 lock))
83 procs.append(("%s %s (%s)" % (distro, release, arch), proc))
84 proc.start()
85 for _, proc in procs:
86 proc.join()
87
88 print "SYSROOT CREATION SUMMARY"
89 failures = 0
90 for name, proc in procs:
91 if proc.exitcode:
92 failures += 1
93 status = "FAILURE" if proc.exitcode else "SUCCESS"
94 print "%s sysroot creation\t%s" % (name, status)
95 return failures
96
97 if __name__ == '__main__':
98 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/linux/sysroot_scripts/install-sysroot.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698