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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/linux/sysroot_scripts/install-sysroot.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/linux/sysroot_scripts/build_and_upload.py
diff --git a/build/linux/sysroot_scripts/build_and_upload.py b/build/linux/sysroot_scripts/build_and_upload.py
new file mode 100755
index 0000000000000000000000000000000000000000..20f60d3dc00d5ec257a0d7afb995f1b78f3ff3cb
--- /dev/null
+++ b/build/linux/sysroot_scripts/build_and_upload.py
@@ -0,0 +1,92 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Automates running BuildPackageLists, BuildSysroot, and
+UploadSysroot for each supported arch of each sysroot creator.
+"""
+
+import hashlib
+import json
+import multiprocessing
+import os
+import random
+import re
+import string
+import subprocess
+import sys
+
+def rand_string_32():
+ return ''.join(random.choice(string.hexdigits) for _ in range(32))
+
+def run_script(args):
+ fnull = open(os.devnull, 'w')
+ subprocess.check_call(args, stdout=fnull, stderr=fnull)
+
+def sha1sumfile(filename):
+ sha1 = hashlib.sha1()
+ with open(filename, 'rb') as f:
+ while True:
+ data = f.read(65536)
+ if not data:
+ break
+ sha1.update(data)
+ return sha1.hexdigest()
+
+def build_and_upload(script_path, distro, release, arch):
+ 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.
+ run_script([script_path, 'UpdatePackageLists%s' % arch])
+ run_script([script_path, 'BuildSysroot%s' % arch])
+ run_script([script_path, 'UploadSysroot%s' % arch, revision])
+
+ tarball = '%s_%s_%s_sysroot.tgz' % (distro, release, arch.lower())
+ tgz_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ "..", "..", "..", "out", "sysroot-build",
+ release, tarball)
+ sha1sum = sha1sumfile(tgz_path)
+ sysroot_dir = '%s_%s_%s-sysroot' % (distro, release, arch.lower())
+
+ sysroot_metadata = {
+ 'Revision': revision,
+ 'Tarball': tarball,
+ 'Sha1Sum': sha1sum,
+ 'SysrootDir': sysroot_dir
+ }
+ with open('sysroot.%s.%s' % (release, arch.lower()), 'w') as f:
+ f.write(json.dumps(sysroot_metadata, sort_keys=True, indent=4))
+ f.write('\n')
+ f.close()
+
+def get_proc_output(args):
+ fnull = open(os.devnull, 'w')
+ p = subprocess.Popen(args, stderr=fnull, stdout=subprocess.PIPE)
+ (stdout, _) = p.communicate()
+ 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.
+
+def build_and_upload_all():
+ script_dir = os.path.dirname(os.path.realpath(__file__))
+ procs = []
+ for filename in os.listdir(script_dir):
+ if (not os.path.isfile(os.path.join(script_dir, filename)) or
+ not re.search(r'sysroot-creator-.+\.sh', filename)):
+ continue
+ script_path = os.path.join(script_dir, filename)
+ distro = get_proc_output([script_path, 'PrintDistro'])
+ release = get_proc_output([script_path, 'PrintRelease'])
+ architectures = get_proc_output([script_path, 'PrintArchitectures'])
+ for arch in architectures.split('\n'):
+ proc = multiprocessing.Process(target=build_and_upload,
+ args=(script_path, distro, release, arch))
+ procs.append(("%s %s (%s)" % (distro, release, arch), proc))
+ proc.start()
+ for (_, proc) in procs:
+ 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
+
+ print "SYSROOT CREATION SUMMARY"
+ for (name, proc) in procs:
+ status = "FAILURE" if proc.exitcode else "SUCCESS"
+ print "%s sysroot creation\t%s" % (name, status)
+
+if __name__ == '__main__':
+ build_and_upload_all()
« 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