update-binary 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. unzip -o "$ZIP" system/*
  38. cd system
  39. DIRS="addon.d app priv-app framework etc lib"
  40. if [ -d /system/lib64 ]; then
  41. DIRS="$DIRS lib64"
  42. fi
  43. for dirs in $DIRS; do
  44. set_perm 0755 $dir
  45. for d in `$UTILS find ./$dir -type d`; do
  46. set_perm 0755 $d
  47. set_owner system system $d
  48. done
  49. for f in `$UTILS find ./$dir -type f`; do
  50. type=$(echo "$f" | sed 's/.*\.//')
  51. if [ "$type" == "sh" ] || [ "$type" == "$f" ]; then
  52. set_perm 0755 $f
  53. else
  54. set_perm 0644 $f
  55. fi
  56. set_owner system system $f
  57. set_con system_file $f
  58. done
  59. done
  60. ui_print "Copying files"
  61. $UTILS cp --preserve=a -r ./* /system/
  62. ui_print "Cleaning up files"
  63. cd ../
  64. $UTILS rm -rf system/
  65. ui_print "Unmounting /system"
  66. umount /system
  67. ui_print "Done!"
  68. exit 0