blob: fcd2e83e4a1b96b54b7a83608c1ae11f15f486fe [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
Tanguy Pruvot76362482011-12-18 21:32:41 +010081app/Maps.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000082app/DeskClockGoogle.apk app/DeskClock.apk
83app/GooglePackageVerifier.apk
84app/NfcGoogle.apk app/Nfc.apk
85app/GoogleBackupTransport.apk
86app/GalleryGoogle.apk app/Gallery.apk
87app/VideoEditorGoogle.apk app/VideoEditor.apk
88app/FaceLock.apk
89app/Vending.apk
90app/EmailGoogle.apk app/Email.apk
91app/GoogleContactsSyncAdapter.apk
92app/Gmail.apk
93app/OneTimeInitializer.apk
94app/NetworkLocation.apk
95app/TagGoogle.apk
96app/GooglePartnerSetup.apk
Steve Kondik94ca1ae2010-07-11 02:49:36 -040097etc/hosts
Kali-9f1dab02010-08-14 23:46:34 +020098etc/custom_backup_list.txt
ladiose7cc3542011-01-24 13:47:14 +080099etc/force_backuptool
kmobse051cf32010-06-24 22:36:11 -0500100EOF
101}
102
Kali-9f1dab02010-08-14 23:46:34 +0200103get_custom_files() {
104 local L
105 if [ -f "$C/custom_backup_list.txt" ];
106 then
107 [ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \
108 > $C/fixed_custom_backup_list.txt
109 L=`cat $C/fixed_custom_backup_list.txt`
110 cat <<EOF
111$L
112EOF
113 fi
114}
115
kmobse051cf32010-06-24 22:36:11 -0500116backup_file() {
117 if [ -e "$1" ];
118 then
119 if [ -n "$2" ];
120 then
121 echo "$2 $1" | md5sum -c -
122 if [ $? -ne 0 ];
123 then
124 echo "MD5Sum check for $1 failed!";
125 exit $?;
126 fi
127 fi
128
129 local F=`basename $1`
130
131 # dont backup any apps that have odex files, they are useless
132 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
133 then
134 echo "Skipping odexed apk $1";
135 else
Steve Kondik715f2d52010-07-05 19:36:33 -0400136 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -0500137 fi
138 fi
139}
140
141restore_file() {
142 local FILE=`basename $1`
143 local DIR=`dirname $1`
144 if [ -e "$C/$FILE" ];
145 then
146 if [ ! -d "$DIR" ];
147 then
148 mkdir -p $DIR;
149 fi
150 cp -p $C/$FILE $1;
151 if [ -n "$2" ];
152 then
153 rm $2;
154 fi
155 fi
156}
157
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200158# don't (u)mount system if already done
159UMOUNT=0
160
kmobse051cf32010-06-24 22:36:11 -0500161case "$1" in
162 backup)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200163 if [ ! -f "$S/build.prop" ]; then
164 mount $S
165 UMOUNT=1
166 fi
kmobse051cf32010-06-24 22:36:11 -0500167 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100168 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500169 if [ $PROCEED -ne 0 ];
170 then
171 rm -rf $C
172 mkdir -p $C
Kali-9f1dab02010-08-14 23:46:34 +0200173 for file_list in get_files get_custom_files; do
174 $file_list | while read FILE REPLACEMENT; do
175 backup_file $S/$FILE
176 done
kmobse051cf32010-06-24 22:36:11 -0500177 done
178 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200179 if [ $UMOUNT -ne 0 ]; then
180 umount $S
181 fi
kmobse051cf32010-06-24 22:36:11 -0500182 ;;
183 restore)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200184 if [ ! -f "$S/build.prop" ]; then
185 mount $S
186 UMOUNT=1
187 fi
kmobse051cf32010-06-24 22:36:11 -0500188 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100189 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500190 if [ $PROCEED -ne 0 ];
191 then
Kali-9f1dab02010-08-14 23:46:34 +0200192 for file_list in get_files get_custom_files; do
193 $file_list | while read FILE REPLACEMENT; do
194 R=""
195 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
196 restore_file $S/$FILE $R
197 done
kmobse051cf32010-06-24 22:36:11 -0500198 done
199 rm -rf $C
200 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200201 if [ $UMOUNT -ne 0 ]; then
202 umount $S
203 fi
204 sync
kmobse051cf32010-06-24 22:36:11 -0500205 ;;
206 *)
207 echo "Usage: $0 {backup|restore}"
208 exit 1
209esac
210
211exit 0