blob: a702d3765dd42b447e0c5a643f77d3b89af04369 [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
Steve Kondikf3428372012-02-15 16:33:52 -080088app/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`
Ricardo Cerqueira2dc70452012-02-15 14:33:25 +0000131 local D=`dirname $1`
kmobse051cf32010-06-24 22:36:11 -0500132
133 # dont backup any apps that have odex files, they are useless
134 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
135 then
136 echo "Skipping odexed apk $1";
137 else
Ricardo Cerqueira2dc70452012-02-15 14:33:25 +0000138 mkdir -p $C/bak/$D
139 cp -p $1 $C/bak/$D/$F
kmobse051cf32010-06-24 22:36:11 -0500140 fi
141 fi
142}
143
144restore_file() {
145 local FILE=`basename $1`
146 local DIR=`dirname $1`
Ricardo Cerqueira2dc70452012-02-15 14:33:25 +0000147 if [ -e "$C/bak/$DIR/$FILE" ];
kmobse051cf32010-06-24 22:36:11 -0500148 then
149 if [ ! -d "$DIR" ];
150 then
151 mkdir -p $DIR;
152 fi
Ricardo Cerqueira2dc70452012-02-15 14:33:25 +0000153 cp -p $C/bak/$DIR/$FILE $1;
kmobse051cf32010-06-24 22:36:11 -0500154 if [ -n "$2" ];
155 then
156 rm $2;
157 fi
158 fi
159}
160
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200161# don't (u)mount system if already done
162UMOUNT=0
163
kmobse051cf32010-06-24 22:36:11 -0500164case "$1" in
165 backup)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200166 if [ ! -f "$S/build.prop" ]; then
167 mount $S
168 UMOUNT=1
169 fi
kmobse051cf32010-06-24 22:36:11 -0500170 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100171 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500172 if [ $PROCEED -ne 0 ];
173 then
174 rm -rf $C
175 mkdir -p $C
Kali-9f1dab02010-08-14 23:46:34 +0200176 for file_list in get_files get_custom_files; do
177 $file_list | while read FILE REPLACEMENT; do
178 backup_file $S/$FILE
179 done
kmobse051cf32010-06-24 22:36:11 -0500180 done
181 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200182 if [ $UMOUNT -ne 0 ]; then
183 umount $S
184 fi
kmobse051cf32010-06-24 22:36:11 -0500185 ;;
186 restore)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200187 if [ ! -f "$S/build.prop" ]; then
188 mount $S
189 UMOUNT=1
190 fi
kmobse051cf32010-06-24 22:36:11 -0500191 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100192 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500193 if [ $PROCEED -ne 0 ];
194 then
Kali-9f1dab02010-08-14 23:46:34 +0200195 for file_list in get_files get_custom_files; do
196 $file_list | while read FILE REPLACEMENT; do
197 R=""
198 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
199 restore_file $S/$FILE $R
200 done
kmobse051cf32010-06-24 22:36:11 -0500201 done
202 rm -rf $C
203 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200204 if [ $UMOUNT -ne 0 ]; then
205 umount $S
206 fi
207 sync
kmobse051cf32010-06-24 22:36:11 -0500208 ;;
209 *)
210 echo "Usage: $0 {backup|restore}"
211 exit 1
212esac
213
214exit 0