blob: f25130197aa13159b013a797337db6df462c12c4 [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
Steve Kondikd2bad262010-08-14 22:46:28 -040032app/ChromeToPhone.apk
kmobse051cf32010-06-24 22:36:11 -050033app/com.amazon.mp3.apk
kmobse051cf32010-06-24 22:36:11 -050034app/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
Steve Kondike0b98d02010-07-02 16:33:54 -040043app/GoogleQuickSearchBox.apk app/QuickSearchBox.apk
kmobse051cf32010-06-24 22:36:11 -050044app/GoogleServicesFramework.apk
45app/googlevoice.apk
46app/HtcCopyright.apk
47app/HtcEmailPolicy.apk
48app/HtcSettings.apk
49app/kickback.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
Steve Kondikd2bad262010-08-14 22:46:28 -040069lib/libimageutils.so
kmobse051cf32010-06-24 22:36:11 -050070lib/libinterstitial.so
71lib/libspeech.so
Steve Kondik4eb26732010-07-11 02:25:37 -040072lib/libzxing.so
Steve Kondik94ca1ae2010-07-11 02:49:36 -040073etc/hosts
kmobse051cf32010-06-24 22:36:11 -050074EOF
75}
76
77backup_file() {
78 if [ -e "$1" ];
79 then
80 if [ -n "$2" ];
81 then
82 echo "$2 $1" | md5sum -c -
83 if [ $? -ne 0 ];
84 then
85 echo "MD5Sum check for $1 failed!";
86 exit $?;
87 fi
88 fi
89
90 local F=`basename $1`
91
92 # dont backup any apps that have odex files, they are useless
93 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
94 then
95 echo "Skipping odexed apk $1";
96 else
Steve Kondik715f2d52010-07-05 19:36:33 -040097 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -050098 fi
99 fi
100}
101
102restore_file() {
103 local FILE=`basename $1`
104 local DIR=`dirname $1`
105 if [ -e "$C/$FILE" ];
106 then
107 if [ ! -d "$DIR" ];
108 then
109 mkdir -p $DIR;
110 fi
111 cp -p $C/$FILE $1;
112 if [ -n "$2" ];
113 then
114 rm $2;
115 fi
116 fi
117}
118
119check_installscript;
120
121case "$1" in
122 backup)
123 mount $S
124 check_prereq;
125 if [ $PROCEED -ne 0 ];
126 then
127 rm -rf $C
128 mkdir -p $C
129 get_files | while read FILE REPLACEMENT; do
130 backup_file $S/$FILE
131 done
132 fi
133 umount $S
134 ;;
135 restore)
136 check_prereq;
137 if [ $PROCEED -ne 0 ];
138 then
139 get_files | while read FILE REPLACEMENT; do
140 R=""
141 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
142 restore_file $S/$FILE $R
143 done
144 rm -rf $C
145 fi
146 ;;
147 *)
148 echo "Usage: $0 {backup|restore}"
149 exit 1
150esac
151
152exit 0