OSDN Git Service

build: Add "installrecovery" command
authorSteve Kondik <shade@chemlab.org>
Wed, 24 Oct 2012 23:40:42 +0000 (16:40 -0700)
committerSteve Kondik <steve@cyngn.com>
Sun, 4 Sep 2016 04:47:36 +0000 (21:47 -0700)
 * Similar to "installboot", add an "installrecovery" command which
   writes the recovery image to the correct partition of a running
   device.

Change-Id: I1dcca44fd0d8afa08ece9e99cd914547acb99c83

envsetup.sh

index d9239a8..eee7b1e 100644 (file)
@@ -28,6 +28,8 @@ Invoke ". build/envsetup.sh" from your shell to add the following functions to y
 - cmrebase:  Rebase a Gerrit change and push it again
 - mka:       Builds using SCHED_BATCH on all processors
 - reposync:  Parallel repo sync using ionice and SCHED_BATCH
+- installboot: Installs a boot.img to the connected device.
+- installrecovery: Installs a recovery.img to the connected device.
 - repodiff:  Diff 2 different branches or tags within the same repo
 
 Environment options:
@@ -1702,6 +1704,39 @@ function installboot()
     fi
 }
 
+function installrecovery()
+{
+    if [ ! -e "$OUT/recovery/root/etc/recovery.fstab" ];
+    then
+        echo "No recovery.fstab found. Build recovery first."
+        return 1
+    fi
+    if [ ! -e "$OUT/recovery.img" ];
+    then
+        echo "No recovery.img found. Run make recoveryimage first."
+        return 1
+    fi
+    PARTITION=`grep "^\/recovery" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}`
+    if [ -z "$PARTITION" ];
+    then
+        echo "Unable to determine recovery partition."
+        return 1
+    fi
+    adb start-server
+    adb root
+    sleep 1
+    adb wait-for-device
+    adb remount
+    adb wait-for-device
+    if (adb shell cat /system/build.prop | grep -q "ro.cm.device=$CM_BUILD");
+    then
+        adb push $OUT/recovery.img /cache/
+        adb shell dd if=/cache/recovery.img of=$PARTITION
+        echo "Installation complete."
+    else
+        echo "The connected device does not appear to be $CM_BUILD, run away!"
+    fi
+}
 
 function makerecipe() {
   if [ -z "$1" ]