vendor: fix backuptool for O

we run the backuptool scripts now right from system
and no longer copy them into /tmp

also add some debug hooks

Change-Id: I7550942e54e0dfbcd5282da7024489428284ceff
diff --git a/prebuilt/bin/backuptool.sh b/prebuilt/bin/backuptool.sh
index ce3627f..dd71112 100755
--- a/prebuilt/bin/backuptool.sh
+++ b/prebuilt/bin/backuptool.sh
@@ -7,6 +7,8 @@
 export S=/system
 export V=8.0
 
+DEBUG=0
+
 # Preserve /system/addon.d in /tmp/addon.d
 preserve_addon_d() {
   mkdir -p /tmp/addon.d/
@@ -42,12 +44,16 @@
 # 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
 }
 
 case "$1" in
   backup)
+    cp /system/bin/backuptool.functions /tmp
     mkdir -p $C
     check_prereq
     check_blacklist system
@@ -57,6 +63,7 @@
     run_stage post-backup
   ;;
   restore)
+    cp /system/bin/backuptool.functions /tmp
     check_prereq
     check_blacklist tmp
     run_stage pre-restore