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

Side by Side Diff: build/android/gyp/apk_install.py

Issue 23936004: This fixes the component build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/gyp/create_device_library_links.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 import optparse 11 import optparse
12 import os 12 import os
13 import re 13 import re
14 import subprocess 14 import subprocess
15 import sys 15 import sys
16 16
17 from util import build_device 17 from util import build_device
18 from util import build_utils 18 from util import build_utils
19 from util import md5_check 19 from util import md5_check
20 20
21 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') 21 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..')
22 sys.path.append(BUILD_ANDROID_DIR) 22 sys.path.append(BUILD_ANDROID_DIR)
23 23
24 from pylib import constants
24 from pylib.utils import apk_helper 25 from pylib.utils import apk_helper
25 26
26 def GetNewMetadata(device, apk_package): 27 def GetNewMetadata(device, apk_package):
27 """Gets the metadata on the device for the apk_package apk.""" 28 """Gets the metadata on the device for the apk_package apk."""
28 output = device.RunShellCommand('ls -l /data/app/') 29 output = device.RunShellCommand('ls -l /data/app/')
29 # Matches lines like: 30 # Matches lines like:
30 # -rw-r--r-- system system 7376582 2013-04-19 16:34 org.chromium.chrome.t estshell.apk 31 # -rw-r--r-- system system 7376582 2013-04-19 16:34 org.chromium.chrome.t estshell.apk
31 # -rw-r--r-- system system 7376582 2013-04-19 16:34 org.chromium.chrome.t estshell-1.apk 32 # -rw-r--r-- system system 7376582 2013-04-19 16:34 org.chromium.chrome.t estshell-1.apk
32 apk_matcher = lambda s: re.match('.*%s(-[0-9]*)?.apk$' % apk_package, s) 33 apk_matcher = lambda s: re.match('.*%s(-[0-9]*)?.apk$' % apk_package, s)
33 matches = filter(apk_matcher, output) 34 matches = filter(apk_matcher, output)
(...skipping 21 matching lines...) Expand all
55 def main(argv): 56 def main(argv):
56 parser = optparse.OptionParser() 57 parser = optparse.OptionParser()
57 parser.add_option('--apk-path', 58 parser.add_option('--apk-path',
58 help='Path to .apk to install.') 59 help='Path to .apk to install.')
59 parser.add_option('--install-record', 60 parser.add_option('--install-record',
60 help='Path to install record (touched only when APK is installed).') 61 help='Path to install record (touched only when APK is installed).')
61 parser.add_option('--build-device-configuration', 62 parser.add_option('--build-device-configuration',
62 help='Path to build device configuration.') 63 help='Path to build device configuration.')
63 parser.add_option('--stamp', 64 parser.add_option('--stamp',
64 help='Path to touch on success.') 65 help='Path to touch on success.')
66 parser.add_option('--configuration-name',
67 help='The build CONFIGURATION_NAME')
65 options, _ = parser.parse_args() 68 options, _ = parser.parse_args()
66 69
67 device = build_device.GetBuildDeviceFromPath( 70 device = build_device.GetBuildDeviceFromPath(
68 options.build_device_configuration) 71 options.build_device_configuration)
69 if not device: 72 if not device:
70 return 73 return
71 74
75 constants.SetBuildType(options.configuration_name)
76
72 serial_number = device.GetSerialNumber() 77 serial_number = device.GetSerialNumber()
73 apk_package = apk_helper.GetPackageName(options.apk_path) 78 apk_package = apk_helper.GetPackageName(options.apk_path)
74 79
75 metadata_path = '%s.%s.device.time.stamp' % (options.apk_path, serial_number) 80 metadata_path = '%s.%s.device.time.stamp' % (options.apk_path, serial_number)
76 81
77 # If the APK on the device does not match the one that was last installed by 82 # If the APK on the device does not match the one that was last installed by
78 # the build, then the APK has to be installed (regardless of the md5 record). 83 # the build, then the APK has to be installed (regardless of the md5 record).
79 force_install = HasInstallMetadataChanged(device, apk_package, metadata_path) 84 force_install = HasInstallMetadataChanged(device, apk_package, metadata_path)
80 85
81 def Install(): 86 def Install():
82 device.Install(options.apk_path, reinstall=True) 87 device.Install(options.apk_path, reinstall=True)
83 RecordInstallMetadata(device, apk_package, metadata_path) 88 RecordInstallMetadata(device, apk_package, metadata_path)
84 build_utils.Touch(options.install_record) 89 build_utils.Touch(options.install_record)
85 90
86 91
87 record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number) 92 record_path = '%s.%s.md5.stamp' % (options.apk_path, serial_number)
88 md5_check.CallAndRecordIfStale( 93 md5_check.CallAndRecordIfStale(
89 Install, 94 Install,
90 record_path=record_path, 95 record_path=record_path,
91 input_paths=[options.apk_path], 96 input_paths=[options.apk_path],
92 force=force_install) 97 force=force_install)
93 98
94 if options.stamp: 99 if options.stamp:
95 build_utils.Touch(options.stamp) 100 build_utils.Touch(options.stamp)
96 101
97 102
98 if __name__ == '__main__': 103 if __name__ == '__main__':
99 sys.exit(main(sys.argv)) 104 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | build/android/gyp/create_device_library_links.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698