imx.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #
  2. # Copyright (C) 2010-2013 OpenWrt.org
  3. #
  4. rootpartuuid() {
  5. local cmdline=$(cat /proc/cmdline)
  6. local bootpart=${cmdline##*root=}
  7. bootpart=${bootpart%% *}
  8. local uuid=${bootpart#PARTUUID=}
  9. echo ${uuid%-02}
  10. }
  11. bootdev_from_uuid() {
  12. blkid | grep "PTUUID=\"$(rootpartuuid)\"" | cut -d : -f1
  13. }
  14. bootpart_from_uuid() {
  15. blkid | grep $(rootpartuuid)-01 | cut -d : -f1
  16. }
  17. rootpart_from_uuid() {
  18. blkid | grep $(rootpartuuid)-02 | cut -d : -f1
  19. }
  20. imx_sdcard_mount_boot() {
  21. mkdir -p /boot
  22. [ -f /boot/uImage ] || {
  23. mount -o rw,noatime $(bootpart_from_uuid) /boot > /dev/null
  24. }
  25. }
  26. imx_sdcard_copy_config() {
  27. imx_sdcard_mount_boot
  28. cp -af "$UPGRADE_BACKUP" "/boot/$BACKUP_FILE"
  29. sync
  30. umount /boot
  31. }
  32. imx_sdcard_do_upgrade() {
  33. local board_dir="$(tar tf "${1}" | grep -m 1 '^sysupgrade-.*/$')"
  34. board_dir="${board_dir%/}"
  35. imx_sdcard_mount_boot
  36. get_image "$1" | tar Oxf - ${board_dir}/kernel > /boot/uImage-new && \
  37. mv /boot/uImage-new /boot/uImage && \
  38. sync && \
  39. get_image "$1" | tar Oxf - ${board_dir}/root > $(rootpart_from_uuid) && \
  40. sync
  41. umount /boot
  42. }
  43. imx_sdcard_pre_upgrade() {
  44. [ -z "$UPGRADE_BACKUP" ] && {
  45. jffs2reset -y
  46. umount /overlay
  47. }
  48. }
  49. imx_sdcard_move_config() {
  50. if [ -b $(bootpart_from_uuid) ]; then
  51. imx_sdcard_mount_boot
  52. [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
  53. umount /boot
  54. fi
  55. }