From 74114f1e69b38aab019fb599d83b1f9078c22640 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Thu, 10 Sep 2020 01:23:32 +0000 Subject: [PATCH] envsetup.sh: add 'syswrite' function This function: - disables verity on the device - reboots the device only if it is needed - remounts partitions on the device Bug: 167697453 Test: syswrite Change-Id: I23c3e88daaa2b334233f4faf7fe8f8244cd56225 --- envsetup.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/envsetup.sh b/envsetup.sh index e98103497..c5619e65c 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -34,6 +34,7 @@ Invoke ". build/envsetup.sh" from your shell to add the following functions to y - gomod: Go to the directory containing a module. - pathmod: Get the directory containing a module. - refreshmod: Refresh list of modules for allmod/gomod/pathmod. +- syswrite: Remount partitions (e.g. system.img) as writable, rebooting if necessary. Environment options: - SANITIZE_HOST: Set to 'address' to use ASAN for all host modules. @@ -857,6 +858,18 @@ function qpid() { fi } +# syswrite - disable verity, reboot if needed, and remount image +# +# Easy way to make system.img/etc writable +function syswrite() { + adb wait-for-device && adb root || return 1 + if [[ $(adb disable-verity | grep "reboot") ]]; then + echo "rebooting" + adb reboot && adb wait-for-device && adb root || return 1 + fi + adb wait-for-device && adb remount || return 1 +} + # coredump_setup - enable core dumps globally for any process # that has the core-file-size limit set correctly #