blob: 3b13843b7ca283f970fa43d7575f487a80c9adbb [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
Steve Kondik25d7ca12011-12-29 15:29:34 -08008V=9
kmobse051cf32010-06-24 22:36:11 -05009
10PROCEED=1;
11
12check_prereq() {
Steve Kondik25d7ca12011-12-29 15:29:34 -080013 if ( ! grep -q "^ro.cm.version=$V.*" /system/build.prop );
kmobse051cf32010-06-24 22:36:11 -050014 then
15 echo "Not backing up files from incompatible version.";
16 PROCEED=0;
17 fi
18}
19
20check_installscript() {
PaulWcfe876c2011-05-13 12:56:19 +010021 if [ -f "/tmp/.installscript" ] && [ $PROCEED -ne 0 ];
kmobse051cf32010-06-24 22:36:11 -050022 then
PaulWcfe876c2011-05-13 12:56:19 +010023 # We have an install script, and ROM versions match!
24 # We now need to check and see if we have force_backup
25 # in either /etc or /tmp/backupdir
26 if [ -f "$S/etc/force_backuptool" ] || [ -f "$C/force_backuptool" ];
27 then
28 echo "force_backuptool file found, Forcing backuptool."
29 else
30 echo "/tmp/.installscript found. Skipping backuptool."
31 PROCEED=0;
32 fi
kmobse051cf32010-06-24 22:36:11 -050033 fi
34}
35
36get_files() {
37 cat <<EOF
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000038vendor/pittpatt/models/recognition/face.face.y0-y0-22-b-N/full_model.bin
39vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin
40vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin
41vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin
42vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin
43vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin
44vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin
45vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin
46vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin
47vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin
48vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-rn30-ri30.5/full_model.bin
49vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-rp30-ri30.5/full_model.bin
50vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-r0-ri30.4a/full_model.bin
DvTonderc61cb922011-12-26 20:43:28 -050051framework/com.android.nfc_extras.jar
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000052framework/com.google.widevine.software.drm.jar
kmobse051cf32010-06-24 22:36:11 -050053framework/com.google.android.maps.jar
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000054framework/com.google.android.media.effects.jar
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000055lib/libfacelock_jni.so
DvTonderc61cb922011-12-26 20:43:28 -050056lib/libfilterpack_facedetect.so
57lib/libflint_engine_jni_api.so
58lib/libfrsdk.so
59lib/libgcomm_jni.so
60lib/libpicowrapper.so
61lib/libspeexresampler.so
62lib/libspeexwrapper.so
63lib/libvideochat_jni.so
64lib/libvideochat_stabilize.so
Steve Kondik6721ac92010-08-16 18:55:59 -040065lib/libvoicesearch.so
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000066etc/permissions/com.google.android.nfc_extras.xml
67etc/permissions/com.google.android.media.effects.xml
68etc/permissions/com.google.android.maps.xml
69etc/permissions/com.google.widevine.software.drm.xml
70etc/permissions/features.xml
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000071app/MediaUploader.apk
72app/GoogleFeedback.apk
73app/GoogleTTS.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000074app/MarketUpdater.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000075app/GoogleServicesFramework.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000076app/YouTube.apk
77app/GenieWidget.apk
78app/GooglePackageVerifierUpdater.apk
79app/SetupWizard.apk app/Provision.apk
80app/GoogleEarth.apk
81app/ChromeBookmarksSyncAdapter.apk
Steve Kondik2824bf82012-02-29 15:42:19 -080082app/GoogleQuickSearchBox.apk app/QuickSearchBox.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000083app/GoogleLoginService.apk
84app/Talk.apk
Tanguy Pruvot76362482011-12-18 21:32:41 +010085app/Maps.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000086app/GooglePackageVerifier.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000087app/GoogleBackupTransport.apk
Steve Kondik2824bf82012-02-29 15:42:19 -080088app/GalleryGoogle.apk app/Gallery2.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000089app/FaceLock.apk
90app/Vending.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000091app/GoogleContactsSyncAdapter.apk
Steve Kondikf67c4ae2011-12-30 11:24:34 -080092app/GoogleCalendarSyncAdapter.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000093app/Gmail.apk
94app/OneTimeInitializer.apk
95app/NetworkLocation.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000096app/GooglePartnerSetup.apk
Steve Kondikf67c4ae2011-12-30 11:24:34 -080097app/Phonesky.apk
Shawn Alty5dda0a92012-02-25 11:06:23 -060098app/VoiceSearch.apk
Steve Kondik94ca1ae2010-07-11 02:49:36 -040099etc/hosts
Kali-9f1dab02010-08-14 23:46:34 +0200100etc/custom_backup_list.txt
ladiose7cc3542011-01-24 13:47:14 +0800101etc/force_backuptool
kmobse051cf32010-06-24 22:36:11 -0500102EOF
103}
104
Kali-9f1dab02010-08-14 23:46:34 +0200105get_custom_files() {
106 local L
107 if [ -f "$C/custom_backup_list.txt" ];
108 then
109 [ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \
110 > $C/fixed_custom_backup_list.txt
111 L=`cat $C/fixed_custom_backup_list.txt`
112 cat <<EOF
113$L
114EOF
115 fi
116}
117
kmobse051cf32010-06-24 22:36:11 -0500118backup_file() {
119 if [ -e "$1" ];
120 then
121 if [ -n "$2" ];
122 then
123 echo "$2 $1" | md5sum -c -
124 if [ $? -ne 0 ];
125 then
126 echo "MD5Sum check for $1 failed!";
127 exit $?;
128 fi
129 fi
130
131 local F=`basename $1`
Ricardo Cerqueira2dc70452012-02-15 14:33:25 +0000132 local D=`dirname $1`
kmobse051cf32010-06-24 22:36:11 -0500133
134 # dont backup any apps that have odex files, they are useless
135 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
136 then
137 echo "Skipping odexed apk $1";
138 else
Ricardo Cerqueira2dc70452012-02-15 14:33:25 +0000139 mkdir -p $C/bak/$D
140 cp -p $1 $C/bak/$D/$F
kmobse051cf32010-06-24 22:36:11 -0500141 fi
142 fi
143}
144
145restore_file() {
146 local FILE=`basename $1`
147 local DIR=`dirname $1`
Ricardo Cerqueira2dc70452012-02-15 14:33:25 +0000148 if [ -e "$C/bak/$DIR/$FILE" ];
kmobse051cf32010-06-24 22:36:11 -0500149 then
150 if [ ! -d "$DIR" ];
151 then
152 mkdir -p $DIR;
153 fi
Ricardo Cerqueira2dc70452012-02-15 14:33:25 +0000154 cp -p $C/bak/$DIR/$FILE $1;
kmobse051cf32010-06-24 22:36:11 -0500155 if [ -n "$2" ];
156 then
157 rm $2;
158 fi
159 fi
160}
161
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200162# don't (u)mount system if already done
163UMOUNT=0
164
kmobse051cf32010-06-24 22:36:11 -0500165case "$1" in
166 backup)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200167 if [ ! -f "$S/build.prop" ]; then
168 mount $S
169 UMOUNT=1
170 fi
kmobse051cf32010-06-24 22:36:11 -0500171 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100172 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500173 if [ $PROCEED -ne 0 ];
174 then
175 rm -rf $C
176 mkdir -p $C
Kali-9f1dab02010-08-14 23:46:34 +0200177 for file_list in get_files get_custom_files; do
178 $file_list | while read FILE REPLACEMENT; do
179 backup_file $S/$FILE
180 done
kmobse051cf32010-06-24 22:36:11 -0500181 done
182 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200183 if [ $UMOUNT -ne 0 ]; then
184 umount $S
185 fi
kmobse051cf32010-06-24 22:36:11 -0500186 ;;
187 restore)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200188 if [ ! -f "$S/build.prop" ]; then
189 mount $S
190 UMOUNT=1
191 fi
kmobse051cf32010-06-24 22:36:11 -0500192 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100193 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500194 if [ $PROCEED -ne 0 ];
195 then
Kali-9f1dab02010-08-14 23:46:34 +0200196 for file_list in get_files get_custom_files; do
197 $file_list | while read FILE REPLACEMENT; do
198 R=""
199 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
200 restore_file $S/$FILE $R
201 done
kmobse051cf32010-06-24 22:36:11 -0500202 done
203 rm -rf $C
204 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200205 if [ $UMOUNT -ne 0 ]; then
206 umount $S
207 fi
208 sync
kmobse051cf32010-06-24 22:36:11 -0500209 ;;
210 *)
211 echo "Usage: $0 {backup|restore}"
212 exit 1
213esac
214
215exit 0