OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Installs an APK. | 7 """Installs an APK. |
8 | 8 |
9 """ | 9 """ |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 metadata = GetNewMetadata(device, apk_package) | 48 metadata = GetNewMetadata(device, apk_package) |
49 if not metadata: | 49 if not metadata: |
50 raise Exception('APK install failed unexpectedly.') | 50 raise Exception('APK install failed unexpectedly.') |
51 | 51 |
52 with open(metadata_path, 'w') as outfile: | 52 with open(metadata_path, 'w') as outfile: |
53 outfile.write(metadata) | 53 outfile.write(metadata) |
54 | 54 |
55 | 55 |
56 def main(argv): | 56 def main(argv): |
57 parser = optparse.OptionParser() | 57 parser = optparse.OptionParser() |
58 parser.add_option('--android-sdk-tools', | |
59 help='path to the Android SDK build tools folder') | |
58 parser.add_option('--apk-path', | 60 parser.add_option('--apk-path', |
59 help='Path to .apk to install.') | 61 help='Path to .apk to install.') |
60 parser.add_option('--install-record', | 62 parser.add_option('--install-record', |
61 help='Path to install record (touched only when APK is installed).') | 63 help='Path to install record (touched only when APK is installed).') |
62 parser.add_option('--build-device-configuration', | 64 parser.add_option('--build-device-configuration', |
63 help='Path to build device configuration.') | 65 help='Path to build device configuration.') |
64 parser.add_option('--stamp', | 66 parser.add_option('--stamp', |
65 help='Path to touch on success.') | 67 help='Path to touch on success.') |
66 parser.add_option('--configuration-name', | 68 parser.add_option('--configuration-name', |
67 help='The build CONFIGURATION_NAME') | 69 help='The build CONFIGURATION_NAME') |
68 options, _ = parser.parse_args() | 70 options, _ = parser.parse_args() |
69 | 71 |
70 device = build_device.GetBuildDeviceFromPath( | 72 device = build_device.GetBuildDeviceFromPath( |
71 options.build_device_configuration) | 73 options.build_device_configuration) |
72 if not device: | 74 if not device: |
73 return | 75 return |
74 | 76 |
75 constants.SetBuildType(options.configuration_name) | 77 constants.SetBuildType(options.configuration_name) |
76 | 78 |
77 serial_number = device.GetSerialNumber() | 79 serial_number = device.GetSerialNumber() |
78 apk_package = apk_helper.GetPackageName(options.apk_path) | 80 apk_package = apk_helper.GetPackageName(options.android_sdk_tools, |
frankf
2014/02/14 21:59:19
I don't see the benefit of passing in the android-
Nico
2014/02/14 22:16:56
Yes, I'm pretty on the fence here too. I went with
| |
81 options.apk_path) | |
79 | 82 |
80 metadata_path = '%s.%s.device.time.stamp' % (options.apk_path, serial_number) | 83 metadata_path = '%s.%s.device.time.stamp' % (options.apk_path, serial_number) |
81 | 84 |
82 # If the APK on the device does not match the one that was last installed by | 85 # If the APK on the device does not match the one that was last installed by |
83 # the build, then the APK has to be installed (regardless of the md5 record). | 86 # the build, then the APK has to be installed (regardless of the md5 record). |
84 force_install = HasInstallMetadataChanged(device, apk_package, metadata_path) | 87 force_install = HasInstallMetadataChanged(device, apk_package, metadata_path) |
85 | 88 |
86 def Install(): | 89 def Install(): |
87 device.Install(options.apk_path, reinstall=True) | 90 device.Install(options.apk_path, reinstall=True) |
88 RecordInstallMetadata(device, apk_package, metadata_path) | 91 RecordInstallMetadata(device, apk_package, metadata_path) |
89 build_utils.Touch(options.install_record) | 92 build_utils.Touch(options.install_record) |
90 | 93 |
91 | 94 |
92 record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number) | 95 record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number) |
93 md5_check.CallAndRecordIfStale( | 96 md5_check.CallAndRecordIfStale( |
94 Install, | 97 Install, |
95 record_path=record_path, | 98 record_path=record_path, |
96 input_paths=[options.apk_path], | 99 input_paths=[options.apk_path], |
97 force=force_install) | 100 force=force_install) |
98 | 101 |
99 if options.stamp: | 102 if options.stamp: |
100 build_utils.Touch(options.stamp) | 103 build_utils.Touch(options.stamp) |
101 | 104 |
102 | 105 |
103 if __name__ == '__main__': | 106 if __name__ == '__main__': |
104 sys.exit(main(sys.argv)) | 107 sys.exit(main(sys.argv)) |
OLD | NEW |