blob: 62ed43c42ebc76d980c8b8328b4fccd7cd01f433 [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
DvTonder147fb1b2011-12-26 11:30:35 -050066app/CalendarProvider.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000067app/MarketUpdater.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000068app/GoogleServicesFramework.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000069app/YouTube.apk
70app/GenieWidget.apk
71app/GooglePackageVerifierUpdater.apk
72app/SetupWizard.apk app/Provision.apk
73app/GoogleEarth.apk
74app/ChromeBookmarksSyncAdapter.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000075app/GoogleQuickSearchBox.apk
76app/GoogleLoginService.apk
77app/Talk.apk
Tanguy Pruvot76362482011-12-18 21:32:41 +010078app/Maps.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000079app/GooglePackageVerifier.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000080app/GoogleBackupTransport.apk
81app/GalleryGoogle.apk app/Gallery.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000082app/FaceLock.apk
83app/Vending.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000084app/GoogleContactsSyncAdapter.apk
85app/Gmail.apk
86app/OneTimeInitializer.apk
87app/NetworkLocation.apk
Ricardo Cerqueirae1f37382011-11-27 19:56:54 +000088app/GooglePartnerSetup.apk
Steve Kondik94ca1ae2010-07-11 02:49:36 -040089etc/hosts
Kali-9f1dab02010-08-14 23:46:34 +020090etc/custom_backup_list.txt
ladiose7cc3542011-01-24 13:47:14 +080091etc/force_backuptool
kmobse051cf32010-06-24 22:36:11 -050092EOF
93}
94
Kali-9f1dab02010-08-14 23:46:34 +020095get_custom_files() {
96 local L
97 if [ -f "$C/custom_backup_list.txt" ];
98 then
99 [ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \
100 > $C/fixed_custom_backup_list.txt
101 L=`cat $C/fixed_custom_backup_list.txt`
102 cat <<EOF
103$L
104EOF
105 fi
106}
107
kmobse051cf32010-06-24 22:36:11 -0500108backup_file() {
109 if [ -e "$1" ];
110 then
111 if [ -n "$2" ];
112 then
113 echo "$2 $1" | md5sum -c -
114 if [ $? -ne 0 ];
115 then
116 echo "MD5Sum check for $1 failed!";
117 exit $?;
118 fi
119 fi
120
121 local F=`basename $1`
122
123 # dont backup any apps that have odex files, they are useless
124 if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ];
125 then
126 echo "Skipping odexed apk $1";
127 else
Steve Kondik715f2d52010-07-05 19:36:33 -0400128 cp -p $1 $C/$F
kmobse051cf32010-06-24 22:36:11 -0500129 fi
130 fi
131}
132
133restore_file() {
134 local FILE=`basename $1`
135 local DIR=`dirname $1`
136 if [ -e "$C/$FILE" ];
137 then
138 if [ ! -d "$DIR" ];
139 then
140 mkdir -p $DIR;
141 fi
142 cp -p $C/$FILE $1;
143 if [ -n "$2" ];
144 then
145 rm $2;
146 fi
147 fi
148}
149
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200150# don't (u)mount system if already done
151UMOUNT=0
152
kmobse051cf32010-06-24 22:36:11 -0500153case "$1" in
154 backup)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200155 if [ ! -f "$S/build.prop" ]; then
156 mount $S
157 UMOUNT=1
158 fi
kmobse051cf32010-06-24 22:36:11 -0500159 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100160 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500161 if [ $PROCEED -ne 0 ];
162 then
163 rm -rf $C
164 mkdir -p $C
Kali-9f1dab02010-08-14 23:46:34 +0200165 for file_list in get_files get_custom_files; do
166 $file_list | while read FILE REPLACEMENT; do
167 backup_file $S/$FILE
168 done
kmobse051cf32010-06-24 22:36:11 -0500169 done
170 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200171 if [ $UMOUNT -ne 0 ]; then
172 umount $S
173 fi
kmobse051cf32010-06-24 22:36:11 -0500174 ;;
175 restore)
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200176 if [ ! -f "$S/build.prop" ]; then
177 mount $S
178 UMOUNT=1
179 fi
kmobse051cf32010-06-24 22:36:11 -0500180 check_prereq;
PaulWcfe876c2011-05-13 12:56:19 +0100181 check_installscript;
kmobse051cf32010-06-24 22:36:11 -0500182 if [ $PROCEED -ne 0 ];
183 then
Kali-9f1dab02010-08-14 23:46:34 +0200184 for file_list in get_files get_custom_files; do
185 $file_list | while read FILE REPLACEMENT; do
186 R=""
187 [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
188 restore_file $S/$FILE $R
189 done
kmobse051cf32010-06-24 22:36:11 -0500190 done
191 rm -rf $C
192 fi
Tanguy Pruvot1ef50752011-06-15 10:40:23 +0200193 if [ $UMOUNT -ne 0 ]; then
194 umount $S
195 fi
196 sync
kmobse051cf32010-06-24 22:36:11 -0500197 ;;
198 *)
199 echo "Usage: $0 {backup|restore}"
200 exit 1
201esac
202
203exit 0