Warren Togami | b1637c8 | 2012-03-03 22:37:42 -1000 | [diff] [blame] | 1 | #!/sbin/sh |
| 2 | # |
| 3 | # Functions for backuptool.sh |
| 4 | # |
| 5 | |
| 6 | export C=/tmp/backupdir |
| 7 | export S=/system |
blunden | 02d26cb | 2013-07-29 23:53:15 +0200 | [diff] [blame] | 8 | export V=10.2 |
Warren Togami | b1637c8 | 2012-03-03 22:37:42 -1000 | [diff] [blame] | 9 | |
| 10 | backup_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 | |
| 24 | restore_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 | } |