backuptool: Support seamless backup and restore to extra partitions

For scripts declaring ADDOND_VERSION=3 automatically mount
vendor, product, system_ext and others (when they're dedicated partitions).

Also expose the get_output_path() function to get the path to where
a file is mounted in case it lives in a dedicated partition.

ab exapmles:
get_output_path "system/product/priv-app/MyApp.apk"  = "/postinstall/product/priv-app/MyApk.apk"
get_output_path "system/app/MySystemApp.apk"         = "/postinstall/system/app/MySystemApp.apk"

a-only examples:
get_output_path "/mnt/system/system/product/priv-app/MyApp.apk" = "/mnt/system/system/product/priv-app/MyApp.apk"

******************************************************************
Instead of cycling all scripts for each stage, run
pre-backup -> backup -> post-backup in quick succession
(and likewise for restore), to ensure backwards compatibility
with scripts that wrongly assumed their environment not to
change between steps.
This is needed because we want to undo any mounting done for V3
scripts when executing V2 scripts. If a V2 script did mounting in
pre-restore and expected things to still be mounted in restore,
we would break their (yes incorrect) assumption.

Change-Id: I73fbad6f45824fed99e4482128769435348588f5
This commit is contained in:
Alessandro Astone
2020-12-29 18:38:28 +01:00
committed by Paul Keith
parent 6245873019
commit c63fa8441b
4 changed files with 226 additions and 29 deletions

View File

@@ -34,10 +34,15 @@ restore_file() {
if [ ! -d "$DIR" ]; then
mkdir -p "$DIR";
fi
copy_file "$C/$DIR/$FILE" "$1";
copy_file "$C/$DIR/$FILE" $(get_output_path "$1");
if [ -n "$2" ]; then
echo "Deleting obsolete file $2"
rm "$2";
rm $(get_output_path "$2");
fi
fi
}
get_output_path() {
# In recovery we mounted all partitions in the right place, so we can rely on symlinks
echo "$1"
}