aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorz3DD3r <z3dd3r@gmail.com>2020-03-04 12:42:10 +0300
committerz3DD3r <z3dd3r@gmail.com>2020-03-04 12:42:10 +0300
commitfa8a442ba233df8ff5c683bf0ee770f7b57549d8 (patch)
treecf05f8851316ab937e2c282ae074e4f43d66f464
parente43d699cfe07196c08a18141160791ae187c1d70 (diff)
downloadvendor_lineage-fa8a442ba233df8ff5c683bf0ee770f7b57549d8.tar.gz
vendor_lineage-fa8a442ba233df8ff5c683bf0ee770f7b57549d8.tar.bz2
vendor_lineage-fa8a442ba233df8ff5c683bf0ee770f7b57549d8.zip
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
-rwxr-xr-xprebuilt/common/bin/backuptool.sh15
-rwxr-xr-xprebuilt/common/bin/backuptool_ab.sh20
2 files changed, 23 insertions, 12 deletions
diff --git a/prebuilt/common/bin/backuptool.sh b/prebuilt/common/bin/backuptool.sh
index d925eb5d..97ef414d 100755
--- a/prebuilt/common/bin/backuptool.sh
+++ b/prebuilt/common/bin/backuptool.sh
@@ -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
diff --git a/prebuilt/common/bin/backuptool_ab.sh b/prebuilt/common/bin/backuptool_ab.sh
index 86bf67a2..079d69d4 100755
--- a/prebuilt/common/bin/backuptool_ab.sh
+++ b/prebuilt/common/bin/backuptool_ab.sh
@@ -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