blob: e3b783653ba0d457eaea8f7856f9f9aa0fd5ab6a [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 Kondik6721ac92010-08-16 18:55:59 -040073lib/libvoicesearch.so
Steve Kondik94ca1ae2010-07-11 02:49:36 -040074etc/hosts
Kali-9f1dab02010-08-14 23:46:34 +020075etc/custom_backup_list.txt
kmobse051cf32010-06-24 22:36:11 -050076EOF
77}
78
Kali-9f1dab02010-08-14 23:46:34 +020079get_custom_files() {
80 local L
81 if [ -f "$C/custom_backup_list.txt" ];
82 then
83 [ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \
84 > $C/fixed_custom_backup_list.txt
85 L=`cat $C/fixed_custom_backup_list.txt`
86 cat <<EOF
87$L
88EOF
89 fi
90}
91
kmobse051cf32010-06-24 22:36:11 -050092backup_file() {
93 if [ -e "$1" ];
94 then
95 if [ -n "$2" ];
96 then
97 echo "$2 $1" | md5sum -c -
98 if [ $? -ne 0 ];
99 then
100 echo "MD5Sum check for $1 failed!";
101 exit $?;
102 fi
103 fi
104
105 local F=`basename $1`
106
107 # dont backup any apps that have odex files, they are useless
108 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
109 then
110 echo "Skipping odexed apk $1";
111 else
Steve Kondik715f2d52010-07-05 19:36:33 -0400112 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -0500113 fi
114 fi
115}
116
117restore_file() {
118 local FILE=`basename $1`
119 local DIR=`dirname $1`
120 if [ -e "$C/$FILE" ];
121 then
122 if [ ! -d "$DIR" ];
123 then
124 mkdir -p $DIR;
125 fi
126 cp -p $C/$FILE $1;
127 if [ -n "$2" ];
128 then
129 rm $2;
130 fi
131 fi
132}
133
134check_installscript;
135
136case "$1" in
137 backup)
138 mount $S
139 check_prereq;
140 if [ $PROCEED -ne 0 ];
141 then
142 rm -rf $C
143 mkdir -p $C
Kali-9f1dab02010-08-14 23:46:34 +0200144 for file_list in get_files get_custom_files; do
145 $file_list | while read FILE REPLACEMENT; do
146 backup_file $S/$FILE
147 done
kmobse051cf32010-06-24 22:36:11 -0500148 done
149 fi
150 umount $S
151 ;;
152 restore)
153 check_prereq;
154 if [ $PROCEED -ne 0 ];
155 then
Kali-9f1dab02010-08-14 23:46:34 +0200156 for file_list in get_files get_custom_files; do
157 $file_list | while read FILE REPLACEMENT; do
158 R=""
159 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
160 restore_file $S/$FILE $R
161 done
kmobse051cf32010-06-24 22:36:11 -0500162 done
163 rm -rf $C
164 fi
165 ;;
166 *)
167 echo "Usage: $0 {backup|restore}"
168 exit 1
169esac
170
171exit 0