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
diff --git a/prebuilt/common/bin/backuptool.sh b/prebuilt/common/bin/backuptool.sh
index 9853eed..2f14522 100755
--- a/prebuilt/common/bin/backuptool.sh
+++ b/prebuilt/common/bin/backuptool.sh
@@ -29,12 +29,13 @@
if [ ! -f /tmp/build.prop ]; then
# this will block any backups made before 8 cause file was not copied before
echo "Not restoring files from incompatible version: $V"
- exit 127
+ return 0
fi
if ( ! grep -q "^ro.build.version.release=$V.*" /tmp/build.prop ); then
echo "Not restoring files from incompatible version: $V"
- exit 127
+ return 0
fi
+ return 1
}
# Execute /system/addon.d/*.sh scripts with $1 parameter
@@ -81,7 +82,10 @@
cp $S/build.prop /tmp
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
@@ -91,7 +95,10 @@
restore)
cp $S/bin/backuptool.functions /tmp
mount_system
- check_prereq
+ if ! check_prereq; then
+ unmount_system
+ exit 127
+ end
run_stage pre-restore
run_stage restore
run_stage post-restore
diff --git a/prebuilt/common/bin/backuptool_ab.sh b/prebuilt/common/bin/backuptool_ab.sh
index 2a8c3d9..d542700 100755
--- a/prebuilt/common/bin/backuptool_ab.sh
+++ b/prebuilt/common/bin/backuptool_ab.sh
@@ -50,10 +50,11 @@
return 0
fi
-grep -q "^ro.omni.version=$V.*" /product/build.prop && return 1
-
-echo "Not backing up files from incompatible version: $V"
-return 0
+if ! grep -q "^ro.omni.version=$V.*" /product/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
@@ -78,10 +79,8 @@
case "$1" in
backup)
mkdir -p $C
- if check_prereq; then
- if check_whitelist postinstall/system; then
- exit 127
- fi
+ if ! check_prereq; then
+ exit 127
fi
log -t "update_engine" "backuptool_ab.sh backup"
@@ -91,10 +90,8 @@
run_stage post-backup
;;
restore)
- if check_prereq; then
- if check_whitelist postinstall/tmp; then
- exit 127
- fi
+ if ! check_prereq; then
+ exit 127
fi
log -t "update_engine" "backuptool_ab.sh restore"