Advertisement
Perka

Untitled

Jan 27th, 2012
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. #!/sbin/sh
  2. #
  3. # Backup and restore proprietary Android system files
  4. #
  5.  
  6. C=/tmp/backupdir
  7. S=/system
  8. V=9
  9.  
  10. PROCEED=1;
  11.  
  12. check_prereq() {
  13. if ( ! grep -q "^ro.cm.version=$V.*" /system/build.prop );
  14. then
  15. echo "Not backing up files from incompatible version.";
  16. PROCEED=0;
  17. fi
  18. }
  19.  
  20. check_installscript() {
  21. if [ -f "/tmp/.installscript" ] && [ $PROCEED -ne 0 ];
  22. then
  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
  33. fi
  34. }
  35.  
  36. get_files() {
  37. cat <<EOF
  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
  51. framework/com.android.nfc_extras.jar
  52. framework/com.google.widevine.software.drm.jar
  53. framework/com.google.android.maps.jar
  54. framework/com.google.android.media.effects.jar
  55. lib/libfacelock_jni.so
  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
  65. lib/libvoicesearch.so
  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
  71. app/MediaUploader.apk
  72. app/GoogleFeedback.apk
  73. app/GoogleTTS.apk
  74. app/MarketUpdater.apk
  75. app/GoogleServicesFramework.apk
  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
  82. app/GoogleQuickSearchBox.apk
  83. app/GoogleLoginService.apk
  84. app/Talk.apk
  85. app/Maps.apk
  86. app/GooglePackageVerifier.apk
  87. app/GoogleBackupTransport.apk
  88. app/GalleryGoogle.apk app/Gallery.apk
  89. app/FaceLock.apk
  90. app/Vending.apk
  91. app/GoogleContactsSyncAdapter.apk
  92. app/GoogleCalendarSyncAdapter.apk
  93. app/Gmail.apk
  94. app/OneTimeInitializer.apk
  95. app/NetworkLocation.apk
  96. app/GooglePartnerSetup.apk
  97. app/Phonesky.apk
  98. etc/hosts
  99. etc/custom_backup_list.txt
  100. etc/force_backuptool
  101. EOF
  102. }
  103.  
  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.  
  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
  137. cp -p $1 $C/$F
  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.  
  159. # don't (u)mount system if already done
  160. UMOUNT=0
  161.  
  162. case "$1" in
  163. backup)
  164. if [ ! -f "$S/build.prop" ]; then
  165. mount $S
  166. UMOUNT=1
  167. fi
  168. check_prereq;
  169. check_installscript;
  170. if [ $PROCEED -ne 0 ];
  171. then
  172. rm -rf $C
  173. mkdir -p $C
  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
  178. done
  179. fi
  180. if [ $UMOUNT -ne 0 ]; then
  181. umount $S
  182. fi
  183. ;;
  184. restore)
  185. if [ ! -f "$S/build.prop" ]; then
  186. mount $S
  187. UMOUNT=1
  188. fi
  189. check_prereq;
  190. check_installscript;
  191. if [ $PROCEED -ne 0 ];
  192. then
  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
  199. done
  200. rm -rf $C
  201. fi
  202. if [ $UMOUNT -ne 0 ]; then
  203. umount $S
  204. fi
  205. sync
  206. ;;
  207. *)
  208. echo "Usage: $0 {backup|restore}"
  209. exit 1
  210. esac
  211.  
  212. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement