kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 1 | #!/sbin/sh |
| 2 | # |
| 3 | # Backup and restore proprietary Android system files |
| 4 | # |
| 5 | |
| 6 | C=/tmp/backupdir |
| 7 | S=/system |
Steve Kondik | 25d7ca1 | 2011-12-29 15:29:34 -0800 | [diff] [blame] | 8 | V=9 |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 9 | |
| 10 | PROCEED=1; |
| 11 | |
| 12 | check_prereq() { |
Steve Kondik | 25d7ca1 | 2011-12-29 15:29:34 -0800 | [diff] [blame] | 13 | if ( ! grep -q "^ro.cm.version=$V.*" /system/build.prop ); |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 14 | then |
| 15 | echo "Not backing up files from incompatible version."; |
| 16 | PROCEED=0; |
| 17 | fi |
| 18 | } |
| 19 | |
| 20 | check_installscript() { |
PaulW | cfe876c | 2011-05-13 12:56:19 +0100 | [diff] [blame] | 21 | if [ -f "/tmp/.installscript" ] && [ $PROCEED -ne 0 ]; |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 22 | then |
PaulW | cfe876c | 2011-05-13 12:56:19 +0100 | [diff] [blame] | 23 | # 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 |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 33 | fi |
| 34 | } |
| 35 | |
| 36 | get_files() { |
| 37 | cat <<EOF |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 38 | vendor/pittpatt/models/recognition/face.face.y0-y0-22-b-N/full_model.bin |
| 39 | vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin |
| 40 | vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin |
| 41 | vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin |
| 42 | vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin |
| 43 | vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-rp7-ri20.2d_n2/full_model.bin |
| 44 | vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin |
| 45 | vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/nose_base-y0-yi45-p0-pi45-rn7-ri20.2d_n2/full_model.bin |
| 46 | vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/right_eye-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin |
| 47 | vendor/pittpatt/models/detection/multi_pose_face_landmark_detectors.3/left_eye-y0-yi45-p0-pi45-r0-ri20.2d_n2/full_model.bin |
| 48 | vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-rn30-ri30.5/full_model.bin |
| 49 | vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-rp30-ri30.5/full_model.bin |
| 50 | vendor/pittpatt/models/detection/yaw_roll_face_detectors.3/head-y0-yi45-p0-pi45-r0-ri30.4a/full_model.bin |
DvTonder | c61cb92 | 2011-12-26 20:43:28 -0500 | [diff] [blame] | 51 | framework/com.android.nfc_extras.jar |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 52 | framework/com.google.widevine.software.drm.jar |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 53 | framework/com.google.android.maps.jar |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 54 | framework/com.google.android.media.effects.jar |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 55 | lib/libfacelock_jni.so |
DvTonder | c61cb92 | 2011-12-26 20:43:28 -0500 | [diff] [blame] | 56 | lib/libfilterpack_facedetect.so |
| 57 | lib/libflint_engine_jni_api.so |
| 58 | lib/libfrsdk.so |
| 59 | lib/libgcomm_jni.so |
| 60 | lib/libpicowrapper.so |
| 61 | lib/libspeexresampler.so |
| 62 | lib/libspeexwrapper.so |
| 63 | lib/libvideochat_jni.so |
| 64 | lib/libvideochat_stabilize.so |
Steve Kondik | 6721ac9 | 2010-08-16 18:55:59 -0400 | [diff] [blame] | 65 | lib/libvoicesearch.so |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 66 | etc/permissions/com.google.android.nfc_extras.xml |
| 67 | etc/permissions/com.google.android.media.effects.xml |
| 68 | etc/permissions/com.google.android.maps.xml |
| 69 | etc/permissions/com.google.widevine.software.drm.xml |
| 70 | etc/permissions/features.xml |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 71 | app/MediaUploader.apk |
| 72 | app/GoogleFeedback.apk |
| 73 | app/GoogleTTS.apk |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 74 | app/MarketUpdater.apk |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 75 | app/GoogleServicesFramework.apk |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 76 | app/YouTube.apk |
| 77 | app/GenieWidget.apk |
| 78 | app/GooglePackageVerifierUpdater.apk |
| 79 | app/SetupWizard.apk app/Provision.apk |
| 80 | app/GoogleEarth.apk |
| 81 | app/ChromeBookmarksSyncAdapter.apk |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 82 | app/GoogleQuickSearchBox.apk |
| 83 | app/GoogleLoginService.apk |
| 84 | app/Talk.apk |
Tanguy Pruvot | 7636248 | 2011-12-18 21:32:41 +0100 | [diff] [blame] | 85 | app/Maps.apk |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 86 | app/GooglePackageVerifier.apk |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 87 | app/GoogleBackupTransport.apk |
| 88 | app/GalleryGoogle.apk app/Gallery.apk |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 89 | app/FaceLock.apk |
| 90 | app/Vending.apk |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 91 | app/GoogleContactsSyncAdapter.apk |
Steve Kondik | f67c4ae | 2011-12-30 11:24:34 -0800 | [diff] [blame^] | 92 | app/GoogleCalendarSyncAdapter.apk |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 93 | app/Gmail.apk |
| 94 | app/OneTimeInitializer.apk |
| 95 | app/NetworkLocation.apk |
Ricardo Cerqueira | e1f3738 | 2011-11-27 19:56:54 +0000 | [diff] [blame] | 96 | app/GooglePartnerSetup.apk |
Steve Kondik | f67c4ae | 2011-12-30 11:24:34 -0800 | [diff] [blame^] | 97 | app/Phonesky.apk |
Steve Kondik | 94ca1ae | 2010-07-11 02:49:36 -0400 | [diff] [blame] | 98 | etc/hosts |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 99 | etc/custom_backup_list.txt |
ladios | e7cc354 | 2011-01-24 13:47:14 +0800 | [diff] [blame] | 100 | etc/force_backuptool |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 101 | EOF |
| 102 | } |
| 103 | |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 104 | get_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 |
| 113 | EOF |
| 114 | fi |
| 115 | } |
| 116 | |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 117 | backup_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` |
| 131 | |
| 132 | # dont backup any apps that have odex files, they are useless |
| 133 | if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ]; |
| 134 | then |
| 135 | echo "Skipping odexed apk $1"; |
| 136 | else |
Steve Kondik | 715f2d5 | 2010-07-05 19:36:33 -0400 | [diff] [blame] | 137 | cp -p $1 $C/$F |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 138 | fi |
| 139 | fi |
| 140 | } |
| 141 | |
| 142 | restore_file() { |
| 143 | local FILE=`basename $1` |
| 144 | local DIR=`dirname $1` |
| 145 | if [ -e "$C/$FILE" ]; |
| 146 | then |
| 147 | if [ ! -d "$DIR" ]; |
| 148 | then |
| 149 | mkdir -p $DIR; |
| 150 | fi |
| 151 | cp -p $C/$FILE $1; |
| 152 | if [ -n "$2" ]; |
| 153 | then |
| 154 | rm $2; |
| 155 | fi |
| 156 | fi |
| 157 | } |
| 158 | |
Tanguy Pruvot | 1ef5075 | 2011-06-15 10:40:23 +0200 | [diff] [blame] | 159 | # don't (u)mount system if already done |
| 160 | UMOUNT=0 |
| 161 | |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 162 | case "$1" in |
| 163 | backup) |
Tanguy Pruvot | 1ef5075 | 2011-06-15 10:40:23 +0200 | [diff] [blame] | 164 | if [ ! -f "$S/build.prop" ]; then |
| 165 | mount $S |
| 166 | UMOUNT=1 |
| 167 | fi |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 168 | check_prereq; |
PaulW | cfe876c | 2011-05-13 12:56:19 +0100 | [diff] [blame] | 169 | check_installscript; |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 170 | if [ $PROCEED -ne 0 ]; |
| 171 | then |
| 172 | rm -rf $C |
| 173 | mkdir -p $C |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 174 | for file_list in get_files get_custom_files; do |
| 175 | $file_list | while read FILE REPLACEMENT; do |
| 176 | backup_file $S/$FILE |
| 177 | done |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 178 | done |
| 179 | fi |
Tanguy Pruvot | 1ef5075 | 2011-06-15 10:40:23 +0200 | [diff] [blame] | 180 | if [ $UMOUNT -ne 0 ]; then |
| 181 | umount $S |
| 182 | fi |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 183 | ;; |
| 184 | restore) |
Tanguy Pruvot | 1ef5075 | 2011-06-15 10:40:23 +0200 | [diff] [blame] | 185 | if [ ! -f "$S/build.prop" ]; then |
| 186 | mount $S |
| 187 | UMOUNT=1 |
| 188 | fi |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 189 | check_prereq; |
PaulW | cfe876c | 2011-05-13 12:56:19 +0100 | [diff] [blame] | 190 | check_installscript; |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 191 | if [ $PROCEED -ne 0 ]; |
| 192 | then |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 193 | for file_list in get_files get_custom_files; do |
| 194 | $file_list | while read FILE REPLACEMENT; do |
| 195 | R="" |
| 196 | [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT" |
| 197 | restore_file $S/$FILE $R |
| 198 | done |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 199 | done |
| 200 | rm -rf $C |
| 201 | fi |
Tanguy Pruvot | 1ef5075 | 2011-06-15 10:40:23 +0200 | [diff] [blame] | 202 | if [ $UMOUNT -ne 0 ]; then |
| 203 | umount $S |
| 204 | fi |
| 205 | sync |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 206 | ;; |
| 207 | *) |
| 208 | echo "Usage: $0 {backup|restore}" |
| 209 | exit 1 |
| 210 | esac |
| 211 | |
| 212 | exit 0 |