platform.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. x86_get_rootfs() {
  2. local rootfsdev
  3. local rootfstype
  4. rootfstype="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "rootfstype") { print $2 }' < /proc/cmdline)"
  5. case "$rootfstype" in
  6. squashfs|jffs2)
  7. rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "block2mtd.block2mtd") { print substr($2,1,index($2, ",")-1) }' < /proc/cmdline)";;
  8. ext4)
  9. rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "root") { print $2 }' < /proc/cmdline)";;
  10. esac
  11. echo "$rootfstype:$rootfsdev"
  12. }
  13. platform_check_image() {
  14. [ "$#" -gt 1 ] && return 1
  15. case "$(get_magic_word "$1")" in
  16. eb48|eb63) return 0;;
  17. *)
  18. echo "Invalid image type"
  19. return 1
  20. ;;
  21. esac
  22. }
  23. platform_copy_config() {
  24. local rootfs="$(x86_get_rootfs)"
  25. local rootfsdev="${rootfs##*:}"
  26. mount -t ext4 -o rw,noatime "${rootfsdev%[0-9]}1" /mnt
  27. cp -af "$CONF_TAR" /mnt/
  28. umount /mnt
  29. }
  30. platform_do_upgrade() {
  31. local rootfs="$(x86_get_rootfs)"
  32. local rootfsdev="${rootfs##*:}"
  33. sync
  34. [ -b ${rootfsdev%[0-9]} ] && get_image "$@" | dd of=${rootfsdev%[0-9]} bs=4096 conv=fsync
  35. sleep 1
  36. }