0023-x86-sysupgrade-move-partition-table-change-check-to-platform_check_image.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Wed, 3 May 2017 08:57:29 +0200
  3. Subject: x86: sysupgrade: move partition table change check to platform_check_image
  4. The staged sysupgrade will prevent us from using ask_bool in
  5. platform_do_upgrade; therefore, the check is moved to platform_check_image.
  6. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
  7. diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
  8. index d3e9f360aadedad0995da55205364940c9884ba4..81b349a81816033eef9df464b2a70fdb998e5a1d 100644
  9. --- a/target/linux/x86/base-files/lib/upgrade/platform.sh
  10. +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
  11. @@ -1,13 +1,37 @@
  12. platform_check_image() {
  13. + local diskdev partdev diff
  14. [ "$#" -gt 1 ] && return 1
  15. case "$(get_magic_word "$1")" in
  16. - eb48|eb63) return 0;;
  17. + eb48|eb63) ;;
  18. *)
  19. echo "Invalid image type"
  20. return 1
  21. ;;
  22. esac
  23. +
  24. + export_bootdevice && export_partdevice diskdev 0 || {
  25. + echo "Unable to determine upgrade device"
  26. + return 1
  27. + }
  28. +
  29. + get_partitions "/dev/$diskdev" bootdisk
  30. +
  31. + #extract the boot sector from the image
  32. + get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null
  33. +
  34. + get_partitions /tmp/image.bs image
  35. +
  36. + #compare tables
  37. + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
  38. +
  39. + rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image
  40. +
  41. + if [ -n "$diff" ]; then
  42. + echo "Partition layout has changed. Full image will be written."
  43. + ask_bool 0 "Abort" && exit 1
  44. + return 0
  45. + fi
  46. }
  47. platform_copy_config() {
  48. @@ -36,9 +60,6 @@ platform_do_upgrade() {
  49. #compare tables
  50. diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
  51. if [ -n "$diff" ]; then
  52. - echo "Partition layout is changed. Full image will be written."
  53. - ask_bool 0 "Abort" && exit
  54. -
  55. get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
  56. return 0
  57. fi