blob: 18a9ae5158882d7af0e75d84003b7d11b19a0695 [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
kmobse051cf32010-06-24 22:36:11 -050032app/Facebook.apk
Steve Kondik6e12dad2010-12-14 21:11:23 -050033app/FOTAKill.apk
kmobse051cf32010-06-24 22:36:11 -050034app/GenieWidget.apk
35app/Gmail.apk
36app/GoogleBackupTransport.apk
37app/GoogleCalendarSyncAdapter.apk
38app/GoogleContactsSyncAdapter.apk
39app/GoogleFeedback.apk
kmobse051cf32010-06-24 22:36:11 -050040app/GooglePartnerSetup.apk
Steve Kondike0b98d02010-07-02 16:33:54 -040041app/GoogleQuickSearchBox.apk app/QuickSearchBox.apk
kmobse051cf32010-06-24 22:36:11 -050042app/GoogleServicesFramework.apk
43app/googlevoice.apk
44app/HtcCopyright.apk
45app/HtcEmailPolicy.apk
46app/HtcSettings.apk
47app/kickback.apk
kmobse051cf32010-06-24 22:36:11 -050048app/LatinImeTutorial.apk
Steve Kondikd89a39c2010-06-29 02:46:10 -040049app/Maps.apk
Patrick Jacques13ce18b2010-11-29 23:24:12 -070050app/MapsSapphire.apk
kmobse051cf32010-06-24 22:36:11 -050051app/MarketUpdater.apk
52app/MediaUploader.apk
53app/NetworkLocation.apk
54app/OneTimeInitializer.apk
55app/PassionQuickOffice.apk
Patrick Jacques13ce18b2010-11-29 23:24:12 -070056app/Quickoffice.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
kmobse051cf32010-06-24 22:36:11 -050069lib/libspeech.so
Steve Kondik6721ac92010-08-16 18:55:59 -040070lib/libvoicesearch.so
Steve Kondik94ca1ae2010-07-11 02:49:36 -040071etc/hosts
Kali-9f1dab02010-08-14 23:46:34 +020072etc/custom_backup_list.txt
kmobse051cf32010-06-24 22:36:11 -050073EOF
74}
75
Kali-9f1dab02010-08-14 23:46:34 +020076get_custom_files() {
77 local L
78 if [ -f "$C/custom_backup_list.txt" ];
79 then
80 [ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \
81 > $C/fixed_custom_backup_list.txt
82 L=`cat $C/fixed_custom_backup_list.txt`
83 cat <<EOF
84$L
85EOF
86 fi
87}
88
kmobse051cf32010-06-24 22:36:11 -050089backup_file() {
90 if [ -e "$1" ];
91 then
92 if [ -n "$2" ];
93 then
94 echo "$2 $1" | md5sum -c -
95 if [ $? -ne 0 ];
96 then
97 echo "MD5Sum check for $1 failed!";
98 exit $?;
99 fi
100 fi
101
102 local F=`basename $1`
103
104 # dont backup any apps that have odex files, they are useless
105 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
106 then
107 echo "Skipping odexed apk $1";
108 else
Steve Kondik715f2d52010-07-05 19:36:33 -0400109 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -0500110 fi
111 fi
112}
113
114restore_file() {
115 local FILE=`basename $1`
116 local DIR=`dirname $1`
117 if [ -e "$C/$FILE" ];
118 then
119 if [ ! -d "$DIR" ];
120 then
121 mkdir -p $DIR;
122 fi
123 cp -p $C/$FILE $1;
124 if [ -n "$2" ];
125 then
126 rm $2;
127 fi
128 fi
129}
130
131check_installscript;
132
133case "$1" in
134 backup)
135 mount $S
136 check_prereq;
137 if [ $PROCEED -ne 0 ];
138 then
139 rm -rf $C
140 mkdir -p $C
Kali-9f1dab02010-08-14 23:46:34 +0200141 for file_list in get_files get_custom_files; do
142 $file_list | while read FILE REPLACEMENT; do
143 backup_file $S/$FILE
144 done
kmobse051cf32010-06-24 22:36:11 -0500145 done
146 fi
147 umount $S
148 ;;
149 restore)
150 check_prereq;
151 if [ $PROCEED -ne 0 ];
152 then
Kali-9f1dab02010-08-14 23:46:34 +0200153 for file_list in get_files get_custom_files; do
154 $file_list | while read FILE REPLACEMENT; do
155 R=""
156 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
157 restore_file $S/$FILE $R
158 done
kmobse051cf32010-06-24 22:36:11 -0500159 done
160 rm -rf $C
161 fi
162 ;;
163 *)
164 echo "Usage: $0 {backup|restore}"
165 exit 1
166esac
167
168exit 0