blob: 2c47ec53fdf0cd8b57de73fe711d6564c6d6e9a0 [file] [log] [blame]
kmobse051cf32010-06-24 22:36:11 -05001#!/sbin/sh
2#
3# Backup and restore proprietary Android system files
4#
5
6C=/tmp/backupdir
7S=/system
8V=CyanogenMod-6
9
10PROCEED=1;
11
12check_prereq() {
13 if ( ! grep -q "^ro.modversion=.*$V.*" /system/build.prop );
14 then
15 echo "Not backing up files from incompatible version.";
16 PROCEED=0;
17 fi
18}
19
20check_installscript() {
21 if [ -f "/tmp/.installscript" ];
22 then
23 echo "/tmp/.installscript found. Skipping backuptool."
24 PROCEED=0;
25 fi
26}
27
28get_files() {
29 cat <<EOF
30app/CarHomeGoogle.apk
31app/CarHomeLauncher.apk
32app/com.amazon.mp3.apk
33app/com.google.android.apps.maps-1.apk
34app/Facebook.apk
35app/GenieWidget.apk
36app/Gmail.apk
37app/GoogleBackupTransport.apk
38app/GoogleCalendarSyncAdapter.apk
39app/GoogleContactsSyncAdapter.apk
40app/GoogleFeedback.apk
41app/GoogleGoggles.apk
42app/GooglePartnerSetup.apk
43app/GoogleQuickSearchBox.apk
44app/GoogleServicesFramework.apk
45app/googlevoice.apk
46app/HtcCopyright.apk
47app/HtcEmailPolicy.apk
48app/HtcSettings.apk
49app/kickback.apk
50app/LatinImeGoogle.apk
51app/LatinImeTutorial.apk
52app/MarketUpdater.apk
53app/MediaUploader.apk
54app/NetworkLocation.apk
55app/OneTimeInitializer.apk
56app/PassionQuickOffice.apk
57app/SetupWizard.apk
58app/soundback.apk
59app/Street.apk
60app/Talk.apk
61app/talkback.apk
62app/Twitter.apk
63app/Vending.apk
64app/VoiceSearch.apk
65app/YouTube.apk
66etc/permissions/com.google.android.maps.xml
67framework/com.google.android.maps.jar
68lib/libinterstitial.so
69lib/libspeech.so
70EOF
71}
72
73backup_file() {
74 if [ -e "$1" ];
75 then
76 if [ -n "$2" ];
77 then
78 echo "$2 $1" | md5sum -c -
79 if [ $? -ne 0 ];
80 then
81 echo "MD5Sum check for $1 failed!";
82 exit $?;
83 fi
84 fi
85
86 local F=`basename $1`
87
88 # dont backup any apps that have odex files, they are useless
89 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
90 then
91 echo "Skipping odexed apk $1";
92 else
93 cp $1 $C/$F
94 fi
95 fi
96}
97
98restore_file() {
99 local FILE=`basename $1`
100 local DIR=`dirname $1`
101 if [ -e "$C/$FILE" ];
102 then
103 if [ ! -d "$DIR" ];
104 then
105 mkdir -p $DIR;
106 fi
107 cp -p $C/$FILE $1;
108 if [ -n "$2" ];
109 then
110 rm $2;
111 fi
112 fi
113}
114
115check_installscript;
116
117case "$1" in
118 backup)
119 mount $S
120 check_prereq;
121 if [ $PROCEED -ne 0 ];
122 then
123 rm -rf $C
124 mkdir -p $C
125 get_files | while read FILE REPLACEMENT; do
126 backup_file $S/$FILE
127 done
128 fi
129 umount $S
130 ;;
131 restore)
132 check_prereq;
133 if [ $PROCEED -ne 0 ];
134 then
135 get_files | while read FILE REPLACEMENT; do
136 R=""
137 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
138 restore_file $S/$FILE $R
139 done
140 rm -rf $C
141 fi
142 ;;
143 *)
144 echo "Usage: $0 {backup|restore}"
145 exit 1
146esac
147
148exit 0