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

Side by Side Diff: build/android/play_services/update.py

Issue 1418573010: Enable downloading Google Play services via deps hook (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 ''' 6 '''
7 Script to help uploading and downloading the Google Play services client 7 Script to help uploading and downloading the Google Play services client
8 library to and from a Google Cloud storage. 8 library to and from a Google Cloud storage.
9 ''' 9 '''
10 10
(...skipping 11 matching lines...) Expand all
22 from devil.utils import cmd_helper 22 from devil.utils import cmd_helper
23 from play_services import utils 23 from play_services import utils
24 from pylib import constants 24 from pylib import constants
25 25
26 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, 'build')) 26 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, 'build'))
27 import find_depot_tools # pylint: disable=import-error,unused-import 27 import find_depot_tools # pylint: disable=import-error,unused-import
28 import breakpad 28 import breakpad
29 import download_from_google_storage 29 import download_from_google_storage
30 import upload_to_google_storage 30 import upload_to_google_storage
31 31
32 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, 'tools'))
33 import yes_no # pylint: disable=import-error
34
35 32
36 # Directory where the SHA1 files for the zip and the license are stored 33 # Directory where the SHA1 files for the zip and the license are stored
37 # It should be managed by git to provided information about new versions. 34 # It should be managed by git to provided information about new versions.
38 SHA1_DIRECTORY = os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'android', 35 SHA1_DIRECTORY = os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'android',
39 'play_services') 36 'play_services')
40 37
41 # Default bucket used for storing the files. 38 # Default bucket used for storing the files.
42 GMS_CLOUD_STORAGE = 'chrome-sdk-extras' 39 GMS_CLOUD_STORAGE = 'chrome-sdk-extras'
43 40
44 # Path to the default configuration file. It exposes the currently installed 41 # Path to the default configuration file. It exposes the currently installed
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 os.makedirs(paths.package) 166 os.makedirs(paths.package)
170 167
171 # download license file from bucket/{version_number}/license.sha1 168 # download license file from bucket/{version_number}/license.sha1
172 new_license = os.path.join(tmp_root, LICENSE_FILE_NAME) 169 new_license = os.path.join(tmp_root, LICENSE_FILE_NAME)
173 old_license = os.path.join(paths.package, LICENSE_FILE_NAME) 170 old_license = os.path.join(paths.package, LICENSE_FILE_NAME)
174 171
175 license_sha1 = os.path.join(SHA1_DIRECTORY, LICENSE_FILE_NAME + '.sha1') 172 license_sha1 = os.path.join(SHA1_DIRECTORY, LICENSE_FILE_NAME + '.sha1')
176 _DownloadFromBucket(bucket_path, license_sha1, new_license, 173 _DownloadFromBucket(bucket_path, license_sha1, new_license,
177 args.verbose, args.dry_run) 174 args.verbose, args.dry_run)
178 if not _CheckLicenseAgreement(new_license, old_license): 175 if not _CheckLicenseAgreement(new_license, old_license):
179 logging.warning('Your version of the Google Play services library is ' 176 logging.warning(utils.EmphasizeMessage(
180 'not up to date. You might run into issues building ' 177 'Your version of the Google Play services library is not up to '
181 'or running the app. Please run `%s download` to ' 178 'date. You might run into issues building or running the app. '
182 'retry downloading it.', __file__) 179 'Please run `%s download` to retry downloading it.'), __file__)
183 return 0 180 return 0
184 181
185 new_lib_zip = os.path.join(tmp_root, LIBRARY_FILE_NAME) 182 new_lib_zip = os.path.join(tmp_root, LIBRARY_FILE_NAME)
186 _DownloadFromBucket(bucket_path, new_lib_zip_sha1, new_lib_zip, 183 _DownloadFromBucket(bucket_path, new_lib_zip_sha1, new_lib_zip,
187 args.verbose, args.dry_run) 184 args.verbose, args.dry_run)
188 185
189 # We remove only the library itself. Users having a SDK manager installed 186 # We remove only the library itself. Users having a SDK manager installed
190 # library before will keep the documentation and samples from it. 187 # library before will keep the documentation and samples from it.
191 shutil.rmtree(paths.lib, ignore_errors=True) 188 shutil.rmtree(paths.lib, ignore_errors=True)
192 os.makedirs(paths.lib) 189 os.makedirs(paths.lib)
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 ''' 382 '''
386 Checks that the new license is the one already accepted by the user. If it 383 Checks that the new license is the one already accepted by the user. If it
387 isn't, it prompts the user to accept it. Returns whether the expected license 384 isn't, it prompts the user to accept it. Returns whether the expected license
388 has been accepted. 385 has been accepted.
389 ''' 386 '''
390 387
391 if utils.FileEquals(expected_license_path, actual_license_path): 388 if utils.FileEquals(expected_license_path, actual_license_path):
392 return True 389 return True
393 390
394 with open(expected_license_path) as license_file: 391 with open(expected_license_path) as license_file:
395 print license_file.read().replace('\\n', os.linesep) 392 # The output is buffered when running as part of gclient hooks. We split
393 # the text here and flush is explicitely to avoid having part of it dropped
jbudorick 2015/10/28 14:08:25 nit: explicitly
dgn 2015/10/28 16:32:58 Addressed in https://codereview.chromium.org/14185
394 # out.
395 for license_part in license_file.read().split('\\n'):
jbudorick 2015/10/28 14:08:25 nit: splitlines()
dgn 2015/10/28 16:32:58 Addressed in https://codereview.chromium.org/14185
396 print license_part
397 sys.stdout.flush()
396 398
397 return yes_no.YesNo('Do you accept the license? [y/n]: ') 399 # Need to put the prompt on a separate line otherwise the gclient hook buffer
dgn 2015/10/28 13:54:33 Didn't work very well from inside the hook runner.
jbudorick 2015/10/28 14:08:25 That's odd. Does that still happen when printing l
dgn 2015/10/28 14:27:13 Yes. In both cases it outputs something like: ```
jbudorick 2015/10/28 14:28:53 yikes, that seems like a bug.
400 # only prints it after we received an input.
401 print 'Do you accept the license? [y/n]: '
402 sys.stdout.flush()
403 return raw_input('> ') in ('Y', 'y')
398 404
399 405
400 def _VerifyBucketPathFormat(bucket_name, version_number, is_dry_run): 406 def _VerifyBucketPathFormat(bucket_name, version_number, is_dry_run):
401 ''' 407 '''
402 Formats and checks the download/upload path depending on whether we are 408 Formats and checks the download/upload path depending on whether we are
403 running in dry run mode or not. Returns a supposedly safe path to use with 409 running in dry run mode or not. Returns a supposedly safe path to use with
404 Gsutil. 410 Gsutil.
405 ''' 411 '''
406 412
407 if is_dry_run: 413 if is_dry_run:
(...skipping 28 matching lines...) Expand all
436 logging.debug('Calling command "%s"', str(args)) 442 logging.debug('Calling command "%s"', str(args))
437 return cmd_helper.GetCmdStatusOutputAndError(args) 443 return cmd_helper.GetCmdStatusOutputAndError(args)
438 444
439 def check_call(self, *args): 445 def check_call(self, *args):
440 logging.debug('Calling command "%s"', str(args)) 446 logging.debug('Calling command "%s"', str(args))
441 return cmd_helper.GetCmdStatusOutputAndError(args) 447 return cmd_helper.GetCmdStatusOutputAndError(args)
442 448
443 449
444 if __name__ == '__main__': 450 if __name__ == '__main__':
445 sys.exit(Main()) 451 sys.exit(Main())
OLDNEW
« no previous file with comments | « DEPS ('k') | build/android/play_services/utils.py » ('j') | build/android/play_services/utils.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698