blob: 1c2cee10d299248b6818fe3038178be9d61cce3b [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
Steve Kondik4eb26732010-07-11 02:25:37 -040070lib/libzxing.so
Steve Kondik94ca1ae2010-07-11 02:49:36 -040071etc/hosts
kmobse051cf32010-06-24 22:36:11 -050072EOF
73}
74
75backup_file() {
76 if [ -e "$1" ];
77 then
78 if [ -n "$2" ];
79 then
80 echo "$2 $1" | md5sum -c -
81 if [ $? -ne 0 ];
82 then
83 echo "MD5Sum check for $1 failed!";
84 exit $?;
85 fi
86 fi
87
88 local F=`basename $1`
89
90 # dont backup any apps that have odex files, they are useless
91 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
92 then
93 echo "Skipping odexed apk $1";
94 else
Steve Kondik715f2d52010-07-05 19:36:33 -040095 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -050096 fi
97 fi
98}
99
100restore_file() {
101 local FILE=`basename $1`
102 local DIR=`dirname $1`
103 if [ -e "$C/$FILE" ];
104 then
105 if [ ! -d "$DIR" ];
106 then
107 mkdir -p $DIR;
108 fi
109 cp -p $C/$FILE $1;
110 if [ -n "$2" ];
111 then
112 rm $2;
113 fi
114 fi
115}
116
117check_installscript;
118
119case "$1" in
120 backup)
121 mount $S
122 check_prereq;
123 if [ $PROCEED -ne 0 ];
124 then
125 rm -rf $C
126 mkdir -p $C
127 get_files | while read FILE REPLACEMENT; do
128 backup_file $S/$FILE
129 done
130 fi
131 umount $S
132 ;;
133 restore)
134 check_prereq;
135 if [ $PROCEED -ne 0 ];
136 then
137 get_files | while read FILE REPLACEMENT; do
138 R=""
139 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
140 restore_file $S/$FILE $R
141 done
142 rm -rf $C
143 fi
144 ;;
145 *)
146 echo "Usage: $0 {backup|restore}"
147 exit 1
148esac
149
150exit 0