blob: 95129efaffc78d163435370ef17df3ef12857f22 [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
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +00008V=CyanogenMod-9
kmobse051cf32010-06-24 22:36:11 -05009
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() {
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
51framework/com.google.widevine.software.drm.jar
kmobse051cf32010-06-24 22:36:11 -050052framework/com.google.android.maps.jar
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000053framework/com.google.android.media.effects.jar
54lib/libfilterpack_facedetect.so
55lib/libfacelock_jni.so
Steve Kondik6721ac92010-08-16 18:55:59 -040056lib/libvoicesearch.so
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000057etc/permissions/com.google.android.nfc_extras.xml
58etc/permissions/com.google.android.media.effects.xml
59etc/permissions/com.google.android.maps.xml
60etc/permissions/com.google.widevine.software.drm.xml
61etc/permissions/features.xml
62app/LatinImeGoogle.apk app/LatinIme.apk
63app/MediaUploader.apk
64app/GoogleFeedback.apk
65app/GoogleTTS.apk
66app/CalendarGoogle.apk app/Calendar.apk
67app/MarketUpdater.apk
68app/BrowserGoogle.apk app/Browser.apk
69app/GoogleServicesFramework.apk
70app/CameraGoogle.apk app/Camera.apk
71app/YouTube.apk
72app/GenieWidget.apk
73app/GooglePackageVerifierUpdater.apk
74app/SetupWizard.apk app/Provision.apk
75app/GoogleEarth.apk
76app/ChromeBookmarksSyncAdapter.apk
77app/ExchangeGoogle.apk app/Exchange.apk
78app/GoogleQuickSearchBox.apk
79app/GoogleLoginService.apk
80app/Talk.apk
81app/DeskClockGoogle.apk app/DeskClock.apk
82app/GooglePackageVerifier.apk
83app/NfcGoogle.apk app/Nfc.apk
84app/GoogleBackupTransport.apk
85app/GalleryGoogle.apk app/Gallery.apk
86app/VideoEditorGoogle.apk app/VideoEditor.apk
87app/FaceLock.apk
88app/Vending.apk
89app/EmailGoogle.apk app/Email.apk
90app/GoogleContactsSyncAdapter.apk
91app/Gmail.apk
92app/OneTimeInitializer.apk
93app/NetworkLocation.apk
94app/TagGoogle.apk
95app/GooglePartnerSetup.apk
Steve Kondik94ca1ae2010-07-11 02:49:36 -040096etc/hosts
Kali-9f1dab02010-08-14 23:46:34 +020097etc/custom_backup_list.txt
ladiose7cc3542011-01-24 13:47:14 +080098etc/force_backuptool
kmobse051cf32010-06-24 22:36:11 -050099EOF
100}
101
Kali-9f1dab02010-08-14 23:46:34 +0200102get_custom_files() {
103 local L
104 if [ -f "$C/custom_backup_list.txt" ];
105 then
106 [ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \
107 > $C/fixed_custom_backup_list.txt
108 L=`cat $C/fixed_custom_backup_list.txt`
109 cat <<EOF
110$L
111EOF
112 fi
113}
114
kmobse051cf32010-06-24 22:36:11 -0500115backup_file() {
116 if [ -e "$1" ];
117 then
118 if [ -n "$2" ];
119 then
120 echo "$2 $1" | md5sum -c -
121 if [ $? -ne 0 ];
122 then
123 echo "MD5Sum check for $1 failed!";
124 exit $?;
125 fi
126 fi
127
128 local F=`basename $1`
129
130 # dont backup any apps that have odex files, they are useless
131 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
132 then
133 echo "Skipping odexed apk $1";
134 else
Steve Kondik715f2d52010-07-05 19:36:33 -0400135 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -0500136 fi
137 fi
138}
139
140restore_file() {
141 local FILE=`basename $1`
142 local DIR=`dirname $1`
143 if [ -e "$C/$FILE" ];
144 then
145 if [ ! -d "$DIR" ];
146 then
147 mkdir -p $DIR;
148 fi
149 cp -p $C/$FILE $1;
150 if [ -n "$2" ];
151 then
152 rm $2;
153 fi
154 fi
155}
156
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200157# don't (u)mount system if already done
158UMOUNT=0
159
kmobse051cf32010-06-24 22:36:11 -0500160case "$1" in
161 backup)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200162 if [ ! -f "$S/build.prop" ]; then
163 mount $S
164 UMOUNT=1
165 fi
kmobse051cf32010-06-24 22:36:11 -0500166 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100167 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500168 if [ $PROCEED -ne 0 ];
169 then
170 rm -rf $C
171 mkdir -p $C
Kali-9f1dab02010-08-14 23:46:34 +0200172 for file_list in get_files get_custom_files; do
173 $file_list | while read FILE REPLACEMENT; do
174 backup_file $S/$FILE
175 done
kmobse051cf32010-06-24 22:36:11 -0500176 done
177 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200178 if [ $UMOUNT -ne 0 ]; then
179 umount $S
180 fi
kmobse051cf32010-06-24 22:36:11 -0500181 ;;
182 restore)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200183 if [ ! -f "$S/build.prop" ]; then
184 mount $S
185 UMOUNT=1
186 fi
kmobse051cf32010-06-24 22:36:11 -0500187 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100188 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500189 if [ $PROCEED -ne 0 ];
190 then
Kali-9f1dab02010-08-14 23:46:34 +0200191 for file_list in get_files get_custom_files; do
192 $file_list | while read FILE REPLACEMENT; do
193 R=""
194 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
195 restore_file $S/$FILE $R
196 done
kmobse051cf32010-06-24 22:36:11 -0500197 done
198 rm -rf $C
199 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200200 if [ $UMOUNT -ne 0 ]; then
201 umount $S
202 fi
203 sync
kmobse051cf32010-06-24 22:36:11 -0500204 ;;
205 *)
206 echo "Usage: $0 {backup|restore}"
207 exit 1
208esac
209
210exit 0