blob: 72be427fbf20503c1fffdba936d997a699aec6b2 [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
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000082app/GoogleQuickSearchBox.apk
83app/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
88app/GalleryGoogle.apk app/Gallery.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
Steve Kondik94ca1ae2010-07-11 02:49:36 -040098etc/hosts
Kali-9f1dab02010-08-14 23:46:34 +020099etc/custom_backup_list.txt
ladiose7cc3542011-01-24 13:47:14 +0800100etc/force_backuptool
kmobse051cf32010-06-24 22:36:11 -0500101EOF
102}
103
Kali-9f1dab02010-08-14 23:46:34 +0200104get_custom_files() {
105 local L
106 if [ -f "$C/custom_backup_list.txt" ];
107 then
108 [ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \
109 > $C/fixed_custom_backup_list.txt
110 L=`cat $C/fixed_custom_backup_list.txt`
111 cat <<EOF
112$L
113EOF
114 fi
115}
116
kmobse051cf32010-06-24 22:36:11 -0500117backup_file() {
118 if [ -e "$1" ];
119 then
120 if [ -n "$2" ];
121 then
122 echo "$2 $1" | md5sum -c -
123 if [ $? -ne 0 ];
124 then
125 echo "MD5Sum check for $1 failed!";
126 exit $?;
127 fi
128 fi
129
130 local F=`basename $1`
131
132 # dont backup any apps that have odex files, they are useless
133 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
134 then
135 echo "Skipping odexed apk $1";
136 else
Steve Kondik715f2d52010-07-05 19:36:33 -0400137 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -0500138 fi
139 fi
140}
141
142restore_file() {
143 local FILE=`basename $1`
144 local DIR=`dirname $1`
145 if [ -e "$C/$FILE" ];
146 then
147 if [ ! -d "$DIR" ];
148 then
149 mkdir -p $DIR;
150 fi
151 cp -p $C/$FILE $1;
152 if [ -n "$2" ];
153 then
154 rm $2;
155 fi
156 fi
157}
158
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200159# don't (u)mount system if already done
160UMOUNT=0
161
kmobse051cf32010-06-24 22:36:11 -0500162case "$1" in
163 backup)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200164 if [ ! -f "$S/build.prop" ]; then
165 mount $S
166 UMOUNT=1
167 fi
kmobse051cf32010-06-24 22:36:11 -0500168 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100169 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500170 if [ $PROCEED -ne 0 ];
171 then
172 rm -rf $C
173 mkdir -p $C
Kali-9f1dab02010-08-14 23:46:34 +0200174 for file_list in get_files get_custom_files; do
175 $file_list | while read FILE REPLACEMENT; do
176 backup_file $S/$FILE
177 done
kmobse051cf32010-06-24 22:36:11 -0500178 done
179 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200180 if [ $UMOUNT -ne 0 ]; then
181 umount $S
182 fi
kmobse051cf32010-06-24 22:36:11 -0500183 ;;
184 restore)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200185 if [ ! -f "$S/build.prop" ]; then
186 mount $S
187 UMOUNT=1
188 fi
kmobse051cf32010-06-24 22:36:11 -0500189 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100190 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500191 if [ $PROCEED -ne 0 ];
192 then
Kali-9f1dab02010-08-14 23:46:34 +0200193 for file_list in get_files get_custom_files; do
194 $file_list | while read FILE REPLACEMENT; do
195 R=""
196 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
197 restore_file $S/$FILE $R
198 done
kmobse051cf32010-06-24 22:36:11 -0500199 done
200 rm -rf $C
201 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200202 if [ $UMOUNT -ne 0 ]; then
203 umount $S
204 fi
205 sync
kmobse051cf32010-06-24 22:36:11 -0500206 ;;
207 *)
208 echo "Usage: $0 {backup|restore}"
209 exit 1
210esac
211
212exit 0