summaryrefslogtreecommitdiffstats
path: root/prebuilt
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-09-03 11:04:58 +0200
committerMichael Bestas <mikeioannina@gmail.com>2015-09-15 16:02:45 +0300
commit9cfe968a73841d33c266990fa27f20257d1a5c67 (patch)
tree9c645aae7072a67f562c6f5807c3285ef6c6b24a /prebuilt
parentc6d40c01f7b9cf12b4a2cd61ed72d62c681fe742 (diff)
downloadvendor_replicant-9cfe968a73841d33c266990fa27f20257d1a5c67.zip
vendor_replicant-9cfe968a73841d33c266990fa27f20257d1a5c67.tar.gz
vendor_replicant-9cfe968a73841d33c266990fa27f20257d1a5c67.tar.bz2
backuptool: Add checks if it makes sense to execute commands
Change-Id: Ic83fc1168ac459b1bba5cef97d184ce2a9db4c68
Diffstat (limited to 'prebuilt')
-rwxr-xr-xprebuilt/common/bin/backuptool.sh28
1 files changed, 19 insertions, 9 deletions
diff --git a/prebuilt/common/bin/backuptool.sh b/prebuilt/common/bin/backuptool.sh
index fa29ad2..e2759ed 100755
--- a/prebuilt/common/bin/backuptool.sh
+++ b/prebuilt/common/bin/backuptool.sh
@@ -12,19 +12,27 @@ cp -f /tmp/install/bin/backuptool.functions /tmp
# Preserve /system/addon.d in /tmp/addon.d
preserve_addon_d() {
- mkdir -p /tmp/addon.d/
- cp -a /system/addon.d/* /tmp/addon.d/
- chmod 755 /tmp/addon.d/*.sh
+ if [ -d /system/addon.d/ ]; then
+ mkdir -p /tmp/addon.d/
+ cp -a /system/addon.d/* /tmp/addon.d/
+ chmod 755 /tmp/addon.d/*.sh
+ fi
}
-# Restore /system/addon.d in /tmp/addon.d
+# Restore /system/addon.d from /tmp/addon.d
restore_addon_d() {
- cp -a /tmp/addon.d/* /system/addon.d/
- rm -rf /tmp/addon.d/
+ if [ -d /tmp/addon.d/ ]; then
+ cp -a /tmp/addon.d/* /system/addon.d/
+ rm -rf /tmp/addon.d/
+ fi
}
# Proceed only if /system is the expected major and minor version
check_prereq() {
+# If there is no build.prop file the partition is probably empty.
+if [ ! -r /system/build.prop ]; then
+ return 0
+fi
if ( ! grep -q "^ro.cm.version=$V.*" /system/build.prop ); then
echo "Not backing up files from incompatible version: $V"
return 0
@@ -63,9 +71,11 @@ check_whitelist() {
# Execute /system/addon.d/*.sh scripts with $1 parameter
run_stage() {
-for script in $(find /tmp/addon.d/ -name '*.sh' |sort -n); do
- $script $1
-done
+if [ -d /tmp/addon.d/ ]; then
+ for script in $(find /tmp/addon.d/ -name '*.sh' |sort -n); do
+ $script $1
+ done
+fi
}
case "$1" in