update-binary 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/sbin/sh
  2. ZIP=$3
  3. set_con() {
  4. $UTILS chcon -h u:object_r:"$1":s0 $2
  5. $UTILS chcon u:object_r:"$1":s0 $2
  6. }
  7. set_perm() {
  8. $UTILS chmod $1 $2
  9. }
  10. set_owner() {
  11. $UTILS chown $1:$2 $3
  12. }
  13. ui_print "*****************"
  14. ui_print "MindTheGapps installer"
  15. ui_print "*****************"
  16. ui_print "Mounting /system"
  17. if mount /system; then
  18. ui_print "/system mounted"
  19. else
  20. # Try to get the block from /etc/recovery.fstab
  21. block=`cat /etc/recovery.fstab | cut -d '#' -f 1 | grep /system | grep -o '/dev/[^ ]*' | head -1`
  22. if [ -n "$block" ] && mount $block /system; then
  23. ui_print "Could not mount /system! Aborting..."
  24. exit 1
  25. else
  26. ui_print "/system mounted"
  27. fi
  28. fi
  29. if [ -f /system/bin/toybox ]; then
  30. UTILS=/system/bin/toybox
  31. else
  32. ui_print "Could not find /system/bin/toybox! Aborting..."
  33. exit 1
  34. fi
  35. ui_print "Extracting files"
  36. cd /tmp
  37. mkdir system
  38. cd system
  39. unzip -o "$ZIP"
  40. DIRS="addon.d app priv-app framework etc lib"
  41. if [ -d /system/lib64 ]; then
  42. DIRS="$DIRS lib64"
  43. fi
  44. for dirs in $DIRS; do
  45. set_perm 0755 $dir
  46. for d in `$UTILS find ./$dir -type d`; do
  47. set_perm 0755 $d
  48. set_owner system system $d
  49. done
  50. for f in `$UTILS find ./$dir -type f`; do
  51. type=$(echo "$f" | sed 's/.*\.//')
  52. if [ "$type" == "sh" ] || [ "$type" == "$f" ]; then
  53. set_perm 0755 $f
  54. else
  55. set_perm 0644 $f
  56. fi
  57. set_owner system system $f
  58. set_con system_file $f
  59. done
  60. done
  61. ui_print "Copying files"
  62. $UTILS cp --preserve=a -r ./* /system/
  63. ui_print "Cleaning up files"
  64. cd ../
  65. $UTILS rm -rf system/
  66. ui_print "Unmounting /system"
  67. umount /system
  68. ui_print "Done!"
  69. exit 0