blob: 65cf43afdf95c34a559dc9ae959a1f1fbdc6facc [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
kmobse051cf32010-06-24 22:36:11 -050033app/Facebook.apk
34app/GenieWidget.apk
35app/Gmail.apk
36app/GoogleBackupTransport.apk
37app/GoogleCalendarSyncAdapter.apk
38app/GoogleContactsSyncAdapter.apk
39app/GoogleFeedback.apk
40app/GoogleGoggles.apk
41app/GooglePartnerSetup.apk
Steve Kondike0b98d02010-07-02 16:33:54 -040042app/GoogleQuickSearchBox.apk app/QuickSearchBox.apk
kmobse051cf32010-06-24 22:36:11 -050043app/GoogleServicesFramework.apk
44app/googlevoice.apk
45app/HtcCopyright.apk
46app/HtcEmailPolicy.apk
47app/HtcSettings.apk
48app/kickback.apk
Steve Kondike0b98d02010-07-02 16:33:54 -040049app/LatinImeGoogle.apk app/LatinIME.apk
kmobse051cf32010-06-24 22:36:11 -050050app/LatinImeTutorial.apk
Steve Kondikd89a39c2010-06-29 02:46:10 -040051app/Maps.apk
kmobse051cf32010-06-24 22:36:11 -050052app/MarketUpdater.apk
53app/MediaUploader.apk
54app/NetworkLocation.apk
55app/OneTimeInitializer.apk
56app/PassionQuickOffice.apk
Steve Kondike0b98d02010-07-02 16:33:54 -040057app/SetupWizard.apk app/Provision.apk
kmobse051cf32010-06-24 22:36:11 -050058app/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
Steve Kondik1bfa1322010-06-28 21:16:14 -040067etc/permissions/features.xml
kmobse051cf32010-06-24 22:36:11 -050068framework/com.google.android.maps.jar
69lib/libinterstitial.so
70lib/libspeech.so
71EOF
72}
73
74backup_file() {
75 if [ -e "$1" ];
76 then
77 if [ -n "$2" ];
78 then
79 echo "$2 $1" | md5sum -c -
80 if [ $? -ne 0 ];
81 then
82 echo "MD5Sum check for $1 failed!";
83 exit $?;
84 fi
85 fi
86
87 local F=`basename $1`
88
89 # dont backup any apps that have odex files, they are useless
90 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
91 then
92 echo "Skipping odexed apk $1";
93 else
Steve Kondik715f2d52010-07-05 19:36:33 -040094 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -050095 fi
96 fi
97}
98
99restore_file() {
100 local FILE=`basename $1`
101 local DIR=`dirname $1`
102 if [ -e "$C/$FILE" ];
103 then
104 if [ ! -d "$DIR" ];
105 then
106 mkdir -p $DIR;
107 fi
108 cp -p $C/$FILE $1;
109 if [ -n "$2" ];
110 then
111 rm $2;
112 fi
113 fi
114}
115
116check_installscript;
117
118case "$1" in
119 backup)
120 mount $S
121 check_prereq;
122 if [ $PROCEED -ne 0 ];
123 then
124 rm -rf $C
125 mkdir -p $C
126 get_files | while read FILE REPLACEMENT; do
127 backup_file $S/$FILE
128 done
129 fi
130 umount $S
131 ;;
132 restore)
133 check_prereq;
134 if [ $PROCEED -ne 0 ];
135 then
136 get_files | while read FILE REPLACEMENT; do
137 R=""
138 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
139 restore_file $S/$FILE $R
140 done
141 rm -rf $C
142 fi
143 ;;
144 *)
145 echo "Usage: $0 {backup|restore}"
146 exit 1
147esac
148
149exit 0