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

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

Issue 2567123002: Sysroot: Add build_and_upload.py (Closed)
Patch Set: 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 hashlib
11 import json
12 import multiprocessing
13 import os
14 import random
15 import re
16 import string
17 import subprocess
18 import sys
19
20 def rand_string_32():
21 return ''.join(random.choice(string.hexdigits) for _ in range(32))
22
23 def run_script(args):
24 fnull = open(os.devnull, 'w')
25 subprocess.check_call(args, stdout=fnull, stderr=fnull)
26
27 def sha1sumfile(filename):
28 sha1 = hashlib.sha1()
29 with open(filename, 'rb') as f:
30 while True:
31 data = f.read(65536)
32 if not data:
33 break
34 sha1.update(data)
35 return sha1.hexdigest()
36
37 def build_and_upload(script_path, distro, release, arch):
38 revision = rand_string_32()
Tom (Use chromium acct) 2016/12/12 18:49:57 The revision can really be any string, but maybe i
Sam Clegg 2016/12/12 19:18:00 The revision we've been using previously has been
Tom (Use chromium acct) 2016/12/12 21:19:34 Done.
39 run_script([script_path, 'UpdatePackageLists%s' % arch])
40 run_script([script_path, 'BuildSysroot%s' % arch])
41 run_script([script_path, 'UploadSysroot%s' % arch, revision])
42
43 tarball = '%s_%s_%s_sysroot.tgz' % (distro, release, arch.lower())
44 tgz_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
45 "..", "..", "..", "out", "sysroot-build",
46 release, tarball)
47 sha1sum = sha1sumfile(tgz_path)
48 sysroot_dir = '%s_%s_%s-sysroot' % (distro, release, arch.lower())
49
50 sysroot_metadata = {
51 'Revision': revision,
52 'Tarball': tarball,
53 'Sha1Sum': sha1sum,
54 'SysrootDir': sysroot_dir
55 }
56 with open('sysroot.%s.%s' % (release, arch.lower()), 'w') as f:
57 f.write(json.dumps(sysroot_metadata, sort_keys=True, indent=4))
58 f.write('\n')
59 f.close()
60
61 def get_proc_output(args):
62 fnull = open(os.devnull, 'w')
63 p = subprocess.Popen(args, stderr=fnull, stdout=subprocess.PIPE)
64 (stdout, _) = p.communicate()
65 return stdout.strip()
Sam Clegg 2016/12/12 19:18:00 You probably don't want to throw away stderr do yo
Tom (Use chromium acct) 2016/12/12 21:19:34 Done.
66
67 def build_and_upload_all():
68 script_dir = os.path.dirname(os.path.realpath(__file__))
69 procs = []
70 for filename in os.listdir(script_dir):
71 if (not os.path.isfile(os.path.join(script_dir, filename)) or
72 not re.search(r'sysroot-creator-.+\.sh', filename)):
73 continue
74 script_path = os.path.join(script_dir, filename)
75 distro = get_proc_output([script_path, 'PrintDistro'])
76 release = get_proc_output([script_path, 'PrintRelease'])
77 architectures = get_proc_output([script_path, 'PrintArchitectures'])
78 for arch in architectures.split('\n'):
79 proc = multiprocessing.Process(target=build_and_upload,
80 args=(script_path, distro, release, arch))
81 procs.append(("%s %s (%s)" % (distro, release, arch), proc))
82 proc.start()
83 for (_, proc) in procs:
84 proc.join()
Sam Clegg 2016/12/12 19:17:59 Is multiprocessing really helpful here? I imagine
Tom (Use chromium acct) 2016/12/12 21:19:34 It is helpful. I created this test script: #! /b
85
86 print "SYSROOT CREATION SUMMARY"
87 for (name, proc) in procs:
88 status = "FAILURE" if proc.exitcode else "SUCCESS"
89 print "%s sysroot creation\t%s" % (name, status)
90
91 if __name__ == '__main__':
92 build_and_upload_all()
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