blob: 62c1492c3ee08142c636dce394336bbce27b9908 [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
33app/GenieWidget.apk
34app/Gmail.apk
35app/GoogleBackupTransport.apk
36app/GoogleCalendarSyncAdapter.apk
37app/GoogleContactsSyncAdapter.apk
38app/GoogleFeedback.apk
kmobse051cf32010-06-24 22:36:11 -050039app/GooglePartnerSetup.apk
Steve Kondike0b98d02010-07-02 16:33:54 -040040app/GoogleQuickSearchBox.apk app/QuickSearchBox.apk
kmobse051cf32010-06-24 22:36:11 -050041app/GoogleServicesFramework.apk
42app/googlevoice.apk
43app/HtcCopyright.apk
44app/HtcEmailPolicy.apk
45app/HtcSettings.apk
46app/kickback.apk
kmobse051cf32010-06-24 22:36:11 -050047app/LatinImeTutorial.apk
Steve Kondikd89a39c2010-06-29 02:46:10 -040048app/Maps.apk
Patrick Jacques13ce18b2010-11-29 23:24:12 -070049app/MapsSapphire.apk
kmobse051cf32010-06-24 22:36:11 -050050app/MarketUpdater.apk
51app/MediaUploader.apk
52app/NetworkLocation.apk
53app/OneTimeInitializer.apk
54app/PassionQuickOffice.apk
Patrick Jacques13ce18b2010-11-29 23:24:12 -070055app/Quickoffice.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
kmobse051cf32010-06-24 22:36:11 -050068lib/libspeech.so
Steve Kondik6721ac92010-08-16 18:55:59 -040069lib/libvoicesearch.so
Steve Kondik94ca1ae2010-07-11 02:49:36 -040070etc/hosts
Kali-9f1dab02010-08-14 23:46:34 +020071etc/custom_backup_list.txt
kmobse051cf32010-06-24 22:36:11 -050072EOF
73}
74
Kali-9f1dab02010-08-14 23:46:34 +020075get_custom_files() {
76 local L
77 if [ -f "$C/custom_backup_list.txt" ];
78 then
79 [ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \
80 > $C/fixed_custom_backup_list.txt
81 L=`cat $C/fixed_custom_backup_list.txt`
82 cat <<EOF
83$L
84EOF
85 fi
86}
87
kmobse051cf32010-06-24 22:36:11 -050088backup_file() {
89 if [ -e "$1" ];
90 then
91 if [ -n "$2" ];
92 then
93 echo "$2 $1" | md5sum -c -
94 if [ $? -ne 0 ];
95 then
96 echo "MD5Sum check for $1 failed!";
97 exit $?;
98 fi
99 fi
100
101 local F=`basename $1`
102
103 # dont backup any apps that have odex files, they are useless
104 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
105 then
106 echo "Skipping odexed apk $1";
107 else
Steve Kondik715f2d52010-07-05 19:36:33 -0400108 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -0500109 fi
110 fi
111}
112
113restore_file() {
114 local FILE=`basename $1`
115 local DIR=`dirname $1`
116 if [ -e "$C/$FILE" ];
117 then
118 if [ ! -d "$DIR" ];
119 then
120 mkdir -p $DIR;
121 fi
122 cp -p $C/$FILE $1;
123 if [ -n "$2" ];
124 then
125 rm $2;
126 fi
127 fi
128}
129
130check_installscript;
131
132case "$1" in
133 backup)
134 mount $S
135 check_prereq;
136 if [ $PROCEED -ne 0 ];
137 then
138 rm -rf $C
139 mkdir -p $C
Kali-9f1dab02010-08-14 23:46:34 +0200140 for file_list in get_files get_custom_files; do
141 $file_list | while read FILE REPLACEMENT; do
142 backup_file $S/$FILE
143 done
kmobse051cf32010-06-24 22:36:11 -0500144 done
145 fi
146 umount $S
147 ;;
148 restore)
149 check_prereq;
150 if [ $PROCEED -ne 0 ];
151 then
Kali-9f1dab02010-08-14 23:46:34 +0200152 for file_list in get_files get_custom_files; do
153 $file_list | while read FILE REPLACEMENT; do
154 R=""
155 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
156 restore_file $S/$FILE $R
157 done
kmobse051cf32010-06-24 22:36:11 -0500158 done
159 rm -rf $C
160 fi
161 ;;
162 *)
163 echo "Usage: $0 {backup|restore}"
164 exit 1
165esac
166
167exit 0