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
5 # found in the LICENSE file.
16 from util
import build_utils
17 from util
import md5_check
19 BUILD_ANDROID_DIR
= os
.path
.join(os
.path
.dirname(__file__
), '..')
20 sys
.path
.append(BUILD_ANDROID_DIR
)
22 from pylib
import android_commands
25 parser
= optparse
.OptionParser()
26 parser
.add_option('--android-sdk-tools',
27 help='Path to Android SDK tools.')
28 parser
.add_option('--apk-path',
29 help='Path to .apk to install.')
30 parser
.add_option('--stamp',
31 help='Path to touch on success.')
32 options
, _
= parser
.parse_args()
34 # TODO(cjhopman): Should this install to all devices/be configurable?
36 os
.path
.join(options
.android_sdk_tools
, 'adb'),
40 serial_number
= android_commands
.AndroidCommands().Adb().GetSerialNumber()
41 md5_stamp
= '%s.%s.md5' % (options
.apk_path
, serial_number
)
43 md5_checker
= md5_check
.Md5Checker(
44 stamp
=md5_stamp
, inputs
=[options
.apk_path
], command
=install_cmd
)
45 if md5_checker
.IsStale():
46 build_utils
.CheckCallDie(install_cmd
)
50 build_utils
.Touch(options
.stamp
)
53 if __name__
== '__main__':
54 sys
.exit(main(sys
.argv
))