backuptool: Deal with multiple files with the same name

Since the destination for all backed up files during an installation was
/tmp, all files sharing a name (like the full_model.bin files from
the various face detectors) ended up being restored as copies of
the last such file, effectively breaking the backup.
As a fix, when backing up files, use the entire original path to make
sure they're kept separate and restorable.

Change-Id: I399f7a9433a225871d97e0ecaeb051a90e68696b
diff --git a/prebuilt/common/bin/backuptool.sh b/prebuilt/common/bin/backuptool.sh
index 72be427..a702d37 100755
--- a/prebuilt/common/bin/backuptool.sh
+++ b/prebuilt/common/bin/backuptool.sh
@@ -128,13 +128,15 @@
       fi
       
       local F=`basename $1`
+      local D=`dirname $1`
       
       # dont backup any apps that have odex files, they are useless
       if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
       then
          echo "Skipping odexed apk $1";
       else
-         cp -p $1 $C/$F
+         mkdir -p $C/bak/$D
+         cp -p $1 $C/bak/$D/$F
       fi
    fi
 }
@@ -142,13 +144,13 @@
 restore_file() {
    local FILE=`basename $1`
    local DIR=`dirname $1`
-   if [ -e "$C/$FILE" ];
+   if [ -e "$C/bak/$DIR/$FILE" ];
    then
       if [ ! -d "$DIR" ];
       then
          mkdir -p $DIR;
       fi
-      cp -p $C/$FILE $1;
+      cp -p $C/bak/$DIR/$FILE $1;
       if [ -n "$2" ];
       then
          rm $2;