blob: 90943b31d1715a82e6b0a4672cd708836c6bc560 [file] [log] [blame]
Warren Togamib1637c82012-03-03 22:37:42 -10001#!/sbin/sh
2#
3# Functions for backuptool.sh
4#
5
6export C=/tmp/backupdir
7export S=/system
blunden02d26cb2013-07-29 23:53:15 +02008export V=10.2
Warren Togamib1637c82012-03-03 22:37:42 -10009
10backup_file() {
11 if [ -e "$1" ]; then
12 local F=`basename "$1"`
13 local D=`dirname "$1"`
14 # dont backup any apps that have odex files, they are useless
15 if ( echo "$F" | grep -q "\.apk$" ) && [ -e `echo "$1" | sed -e 's/\.apk$/\.odex/'` ]; then
16 echo "Skipping odexed apk $1";
17 else
18 mkdir -p "$C/$D"
19 cp -p $1 "$C/$D/$F"
20 fi
21 fi
22}
23
24restore_file() {
25 local FILE=`basename "$1"`
26 local DIR=`dirname "$1"`
27 if [ -e "$C/$DIR/$FILE" ]; then
28 if [ ! -d "$DIR" ]; then
29 mkdir -p "$DIR";
30 fi
31 cp -p "$C/$DIR/$FILE" "$1";
32 if [ -n "$2" ]; then
33 echo "Deleting obsolete file $2"
34 rm "$2";
35 fi
36 fi
37}