install.py continues if adb uninstall fails
authorKalle Raita <kraita@google.com>
Fri, 16 Dec 2016 17:45:41 +0000 (09:45 -0800)
committerKalle Raita <kraita@google.com>
Thu, 29 Dec 2016 22:19:18 +0000 (22:19 +0000)
ADB uninstall fails with non-zero return code if the package to be
uninstalled does not exist. To allow the installation proceed when
there's no previous package, the non-zero return value should be ignored
for the uninstall step.

There are historical reasons for not relying on -r -d for
install (replace, allow downgrade), which I can't recall right now.

Test: Installed succesfully on device without deqp package.
Bug: 33961937
Change-Id: I401f3861f8d68f352747c041bd60cd372b48134b

android/scripts/common.py
android/scripts/install.py

index ef52764..87aad8a 100644 (file)
@@ -110,7 +110,7 @@ def execArgs (args):
        if retcode != 0:
                raise Exception("Failed to execute '%s', got %d" % (str(args), retcode))
 
-def execArgsInDirectory (args, cwd, linePrefix=""):
+def execArgsInDirectory (args, cwd, linePrefix="", failOnNonZeroExit=True):
 
        def readApplyPrefixAndPrint (source, prefix, sink):
                while True:
@@ -125,7 +125,7 @@ def execArgsInDirectory (args, cwd, linePrefix=""):
        stdoutJob.start()
        stderrJob.start()
        retcode = process.wait()
-       if retcode != 0:
+       if failOnNonZeroExit and retcode != 0:
                raise Exception("Failed to execute '%s', got %d" % (str(args), retcode))
 
 def serialApply(f, argsList):
index 6c9ff0f..5545cbb 100644 (file)
@@ -33,7 +33,7 @@ def install (buildRoot, extraArgs = [], printPrefix=""):
        common.execArgsInDirectory([common.ADB_BIN] + extraArgs + [
                        'uninstall',
                        'com.drawelements.deqp'
-               ], buildRoot, printPrefix)
+               ], buildRoot, printPrefix, failOnNonZeroExit=False)
        print printPrefix + "Remove complete\n",
 
        print printPrefix + "Installing dEQP Package from %s...\n" %(buildRoot),