backuptool: Properly unmount system partition

For non AB devices system partition should be unmounted
if check_prereq function fails.

This patch also refactors backuptool a bit for AB devices
in order to look same as backuptool for non AB devices.

Change-Id: Ia1f4ae95c9e4dae4df844853e81c264bc838f177
This commit is contained in:
z3DD3r
2020-03-04 12:42:10 +03:00
parent e43d699cfe
commit fa8a442ba2
2 changed files with 23 additions and 12 deletions

View File

@@ -33,12 +33,13 @@ restore_addon_d() {
check_prereq() {
# If there is no build.prop file the partition is probably empty.
if [ ! -r $S/build.prop ]; then
exit 127
return 0
fi
if ! grep -q "^ro.lineage.version=$V.*" $S/build.prop; then
echo "Not backing up files from incompatible version: $V"
exit 127
return 0
fi
return 1
}
# Execute /system/addon.d/*.sh scripts with $1 parameter
@@ -80,7 +81,10 @@ case "$1" in
backup)
mount_system
mkdir -p $C
check_prereq
if ! check_prereq; then
unmount_system
exit 127
end
preserve_addon_d
run_stage pre-backup
run_stage backup
@@ -89,7 +93,10 @@ case "$1" in
;;
restore)
mount_system
check_prereq
if ! check_prereq; then
unmount_system
exit 127
end
run_stage pre-restore
run_stage restore
run_stage post-restore

View File

@@ -47,13 +47,13 @@ restore_addon_d() {
check_prereq() {
# If there is no build.prop file the partition is probably empty.
if [ ! -r /system/build.prop ]; then
exit 127
return 0
fi
grep -q "^ro.lineage.version=$V.*" /system/build.prop && return 1
echo "Not backing up files from incompatible version: $V"
exit 127
if ! grep -q "^ro.lineage.version=$V.*" /system/build.prop; then
echo "Not backing up files from incompatible version: $V"
return 0
fi
return 1
}
# Execute /system/addon.d/*.sh scripts with $1 parameter
@@ -74,14 +74,18 @@ fi
case "$1" in
backup)
mkdir -p $C
check_prereq
if ! check_prereq; then
exit 127
fi
preserve_addon_d
run_stage pre-backup
run_stage backup
run_stage post-backup
;;
restore)
check_prereq
if ! check_prereq; then
exit 127
fi
run_stage pre-restore
run_stage restore
run_stage post-restore