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

Unified Diff: tools/download_prebuilt_sdk.py

Issue 2541123006: Fuchsia: Adds a script to download the prebuilt SDK (Closed)
Patch Set: Fix python script 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 | « runtime/tools/create_archive.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/download_prebuilt_sdk.py
diff --git a/tools/download_prebuilt_sdk.py b/tools/download_prebuilt_sdk.py
new file mode 100755
index 0000000000000000000000000000000000000000..f3c43853347aaff7d3f8e6f513109b28809e6853
--- /dev/null
+++ b/tools/download_prebuilt_sdk.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# Copyright 2016 The Dart project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import subprocess
+import sys
+import tarfile
+import urllib
+import utils
+
+HOST_OS = utils.GuessOS()
+HOST_ARCH = utils.GuessArchitecture()
+SCRIPT_DIR = os.path.dirname(sys.argv[0])
+DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
+
+BUCKET_NAME = 'dart-dependencies'
+
+def host_os_for_sdk(host_os):
+ if host_os.startswith('macos'):
+ return 'mac'
+ if host_os.startswith('win'):
+ return 'win'
+ return host_os
+
+def main(argv):
+ host_os = host_os_for_sdk(HOST_OS)
+ sdk_path = os.path.join(DART_ROOT, 'tools', 'sdks', host_os)
+ stamp_path = os.path.join(sdk_path, 'dart-sdk.tar.gz.stamp')
+ sha_path = os.path.join(sdk_path, 'dart-sdk.tar.gz.sha1')
+ tgz_path = os.path.join(sdk_path, 'dart-sdk.tar.gz')
+
+ stamp = ''
+ if os.path.isfile(stamp_path):
+ with open(stamp_path, 'r') as fp:
+ stamp = fp.read()
+
+ with open(sha_path, 'r') as fp:
+ sha = fp.read()
+
+ if stamp != sha:
+ url = ('https://%s.storage.googleapis.com/%s' % (BUCKET_NAME, sha))
+ print 'Downloading prebuilt Dart SDK from: ' + url
+ urllib.urlretrieve(url, tgz_path)
+ with tarfile.open(tgz_path) as tar:
+ tar.extractall(sdk_path)
+ with open(stamp_path, 'w') as fp:
+ fp.write(sha)
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
« no previous file with comments | « runtime/tools/create_archive.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698