vendor: fix backuptool version check
before when we extracted the script from the new image
the version check was working already on backup
now we need to wait for restore to check if versions
are compatible. Fot that copy the build.prop file
into /tmp and use to check the version on restore
Change-Id: I4e463df60f15fd6d5d69e51bdd34693387ee72d3
diff --git a/prebuilt/bin/backuptool.sh b/prebuilt/bin/backuptool.sh
index dd71112..19578b6 100755
--- a/prebuilt/bin/backuptool.sh
+++ b/prebuilt/bin/backuptool.sh
@@ -11,6 +11,7 @@
# Preserve /system/addon.d in /tmp/addon.d
preserve_addon_d() {
+ rm -rf /tmp/addon.d/
mkdir -p /tmp/addon.d/
cp -a /system/addon.d/* /tmp/addon.d/
chmod 755 /tmp/addon.d/*.sh
@@ -22,40 +23,48 @@
rm -rf /tmp/addon.d/
}
-# Proceed only if /system is the expected major and minor version
+# Restore only if backup has the expected major and minor version
check_prereq() {
-if ( ! grep -q "^ro.build.version.release=$V.*" /system/build.prop ); then
- echo "Not backing up files from incompatible version: $V"
- exit 127
-fi
+ 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
+ fi
+ if ( ! grep -q "^ro.build.version.release=$V.*" /tmp/build.prop ); then
+ echo "Not restoring files from incompatible version: $V"
+ exit 127
+ fi
}
check_blacklist() {
if [ -f /system/addon.d/blacklist ];then
- ## Discard any known bad backup scripts
- cd /$1/addon.d/
- for f in *sh; do
- s=$(md5sum $f | awk {'print $1'})
- grep -q $s /system/addon.d/blacklist && rm -f $f
- done
+ ## Discard any known bad backup scripts
+ cd /$1/addon.d/
+ for f in *sh; do
+ s=$(md5sum $f | awk {'print $1'})
+ grep -q $s /system/addon.d/blacklist && rm -f $f
+ done
fi
}
# Execute /system/addon.d/*.sh scripts with $1 parameter
run_stage() {
-for script in $(find /tmp/addon.d/ -name '*.sh' |sort -n); do
- if [ $DEBUG -eq 1 ]; then
- echo run_stage $script $1
- fi
- $script $1
-done
+ for script in $(find /tmp/addon.d/ -name '*.sh' |sort -n); do
+ if [ $DEBUG -eq 1 ]; then
+ echo run_stage $script $1
+ fi
+ $script $1
+ done
}
case "$1" in
backup)
+ # make sure we dont start with any leftovers
+ rm -rf $C
cp /system/bin/backuptool.functions /tmp
+ cp /system/build.prop /tmp
mkdir -p $C
- check_prereq
+ #check_prereq
check_blacklist system
preserve_addon_d
run_stage pre-backup