blob: 0b5e07b012fd12a53e2b45e4c7de52c407700ee2 [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
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000062app/MediaUploader.apk
63app/GoogleFeedback.apk
64app/GoogleTTS.apk
65app/CalendarGoogle.apk app/Calendar.apk
66app/MarketUpdater.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000067app/GoogleServicesFramework.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000068app/YouTube.apk
69app/GenieWidget.apk
70app/GooglePackageVerifierUpdater.apk
71app/SetupWizard.apk app/Provision.apk
72app/GoogleEarth.apk
73app/ChromeBookmarksSyncAdapter.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000074app/GoogleQuickSearchBox.apk
75app/GoogleLoginService.apk
76app/Talk.apk
Tanguy Pruvot76362482011-12-18 21:32:41 +010077app/Maps.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000078app/GooglePackageVerifier.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000079app/GoogleBackupTransport.apk
80app/GalleryGoogle.apk app/Gallery.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000081app/FaceLock.apk
82app/Vending.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000083app/GoogleContactsSyncAdapter.apk
84app/Gmail.apk
85app/OneTimeInitializer.apk
86app/NetworkLocation.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000087app/GooglePartnerSetup.apk
Steve Kondik94ca1ae2010-07-11 02:49:36 -040088etc/hosts
Kali-9f1dab02010-08-14 23:46:34 +020089etc/custom_backup_list.txt
ladiose7cc3542011-01-24 13:47:14 +080090etc/force_backuptool
kmobse051cf32010-06-24 22:36:11 -050091EOF
92}
93
Kali-9f1dab02010-08-14 23:46:34 +020094get_custom_files() {
95 local L
96 if [ -f "$C/custom_backup_list.txt" ];
97 then
98 [ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \
99 > $C/fixed_custom_backup_list.txt
100 L=`cat $C/fixed_custom_backup_list.txt`
101 cat <<EOF
102$L
103EOF
104 fi
105}
106
kmobse051cf32010-06-24 22:36:11 -0500107backup_file() {
108 if [ -e "$1" ];
109 then
110 if [ -n "$2" ];
111 then
112 echo "$2 $1" | md5sum -c -
113 if [ $? -ne 0 ];
114 then
115 echo "MD5Sum check for $1 failed!";
116 exit $?;
117 fi
118 fi
119
120 local F=`basename $1`
121
122 # dont backup any apps that have odex files, they are useless
123 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
124 then
125 echo "Skipping odexed apk $1";
126 else
Steve Kondik715f2d52010-07-05 19:36:33 -0400127 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -0500128 fi
129 fi
130}
131
132restore_file() {
133 local FILE=`basename $1`
134 local DIR=`dirname $1`
135 if [ -e "$C/$FILE" ];
136 then
137 if [ ! -d "$DIR" ];
138 then
139 mkdir -p $DIR;
140 fi
141 cp -p $C/$FILE $1;
142 if [ -n "$2" ];
143 then
144 rm $2;
145 fi
146 fi
147}
148
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200149# don't (u)mount system if already done
150UMOUNT=0
151
kmobse051cf32010-06-24 22:36:11 -0500152case "$1" in
153 backup)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200154 if [ ! -f "$S/build.prop" ]; then
155 mount $S
156 UMOUNT=1
157 fi
kmobse051cf32010-06-24 22:36:11 -0500158 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100159 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500160 if [ $PROCEED -ne 0 ];
161 then
162 rm -rf $C
163 mkdir -p $C
Kali-9f1dab02010-08-14 23:46:34 +0200164 for file_list in get_files get_custom_files; do
165 $file_list | while read FILE REPLACEMENT; do
166 backup_file $S/$FILE
167 done
kmobse051cf32010-06-24 22:36:11 -0500168 done
169 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200170 if [ $UMOUNT -ne 0 ]; then
171 umount $S
172 fi
kmobse051cf32010-06-24 22:36:11 -0500173 ;;
174 restore)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200175 if [ ! -f "$S/build.prop" ]; then
176 mount $S
177 UMOUNT=1
178 fi
kmobse051cf32010-06-24 22:36:11 -0500179 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100180 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500181 if [ $PROCEED -ne 0 ];
182 then
Kali-9f1dab02010-08-14 23:46:34 +0200183 for file_list in get_files get_custom_files; do
184 $file_list | while read FILE REPLACEMENT; do
185 R=""
186 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
187 restore_file $S/$FILE $R
188 done
kmobse051cf32010-06-24 22:36:11 -0500189 done
190 rm -rf $C
191 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200192 if [ $UMOUNT -ne 0 ]; then
193 umount $S
194 fi
195 sync
kmobse051cf32010-06-24 22:36:11 -0500196 ;;
197 *)
198 echo "Usage: $0 {backup|restore}"
199 exit 1
200esac
201
202exit 0