blob: e73f0ef2eab122e5fb1685dafb0fbd914eca41e9 [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
kmobse051cf32010-06-24 22:36:11 -050049app/LatinImeTutorial.apk
Steve Kondikd89a39c2010-06-29 02:46:10 -040050app/Maps.apk
kmobse051cf32010-06-24 22:36:11 -050051app/MarketUpdater.apk
52app/MediaUploader.apk
53app/NetworkLocation.apk
54app/OneTimeInitializer.apk
55app/PassionQuickOffice.apk
Steve Kondike0b98d02010-07-02 16:33:54 -040056app/SetupWizard.apk app/Provision.apk
kmobse051cf32010-06-24 22:36:11 -050057app/soundback.apk
58app/Street.apk
59app/Talk.apk
60app/talkback.apk
61app/Twitter.apk
62app/Vending.apk
63app/VoiceSearch.apk
64app/YouTube.apk
65etc/permissions/com.google.android.maps.xml
Steve Kondik1bfa1322010-06-28 21:16:14 -040066etc/permissions/features.xml
kmobse051cf32010-06-24 22:36:11 -050067framework/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
Steve Kondik715f2d52010-07-05 19:36:33 -040093 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -050094 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