generate-uboot4extlinux-sunxi-install-text.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0+
  3. # Copyright (C) 2020 Denis 'GNUtoo' Carikli
  4. line_length=81
  5. printchar()
  6. {
  7. char="$1"
  8. nr_chars="$2"
  9. if [ -z "${nr_chars}" ] ; then
  10. echo -n "${char}"
  11. else
  12. i=0
  13. while [ $i -lt ${nr_chars} ] ; do
  14. echo -n "${char}"
  15. i=$(expr $i + 1)
  16. done
  17. fi
  18. }
  19. print_separation_line()
  20. {
  21. echo -n "+"
  22. printchar "-" $(expr ${line_length} - 2)
  23. echo "+"
  24. }
  25. strlen()
  26. {
  27. echo $(expr $(echo "$1" | wc -c) - 1)
  28. }
  29. print_header()
  30. {
  31. pkgname="$1"
  32. # ${line_length}
  33. # - '| '
  34. # - ${pkgname}
  35. # - ' '
  36. # - 'installation instructions:'
  37. # - ' |'
  38. extra_spaces=$(expr ${line_length} - 2 - $(strlen "${pkgname}") - 1)
  39. extra_spaces=$(expr ${extra_spaces} - \
  40. $(strlen "installation instructions:") - 2)
  41. print_separation_line
  42. echo -n "| "
  43. echo -n "${pkgname} installation instructions:"
  44. printchar " " "${extra_spaces}"
  45. echo " |"
  46. print_separation_line
  47. }
  48. print_line()
  49. {
  50. line="$1"
  51. # ${line_length} - '| ' - ${line} - ' |'
  52. extra_spaces=$(expr ${line_length} - 2 - $(strlen "${line}") - 2)
  53. echo -n '| '
  54. echo -n "${line}"
  55. printchar " " "${extra_spaces}"
  56. echo ' |'
  57. }
  58. print_text()
  59. {
  60. for line in "$@" ; do
  61. print_line "${line}"
  62. done
  63. }
  64. print_introduction()
  65. {
  66. print_text \
  67. "To boot with u-boot you will need to do two things:" \
  68. "- First you will need to install u-boot to the storage device (like" \
  69. " a microSD) you will be booting from. You can consult the Parabola" \
  70. " installation instructions to know which storage devices are" \
  71. " supported." \
  72. "- Then you will need to read and potentially modify the" \
  73. " /boot/extlinux/extlinux.conf configuration file to tell u-boot" \
  74. " from which kernel to boot, and various other settings related to" \
  75. " booting (like LVM or disk encryption settings)."
  76. }
  77. print_uboot_install_instructions()
  78. {
  79. pkgname="$1"
  80. install_script="$2"
  81. print_text \
  82. "To install or upgrade u-boot you can use similar commands:" \
  83. " cd $(dirname ${script})" \
  84. " sudo ./$(basename ${script}) <path/to/block-device>"
  85. print_line ""
  86. print_text \
  87. "For instance if the microSD you (will) boot from is available at" \
  88. "/dev/mmcblk0 you can use the following commands:" \
  89. " cd $(dirname ${script})" \
  90. " sudo ./$(basename ${script}) /dev/mmcblk0"
  91. print_line ""
  92. print_text \
  93. "Instead if the microSD is available at /dev/sdb you can use the" \
  94. "following commands:" \
  95. " cd $(dirname ${script})" \
  96. " sudo ./$(basename ${script}) /dev/sdb"
  97. }
  98. print_extlinux_config_remainder()
  99. {
  100. pkgbase="$1"
  101. print_text \
  102. "When this is done you'll need to create and/or modify the" \
  103. "/boot/extlinux/extlinux.conf configuration file."
  104. print_line ""
  105. print_text \
  106. "There is an example file for that at" \
  107. "/usr/lib/u-boot/${pkgbase}/extlinux.conf"
  108. }
  109. pkgname="$1"
  110. pkgbase="$2"
  111. script="$3"
  112. print_header "${pkgname}"
  113. print_introduction
  114. print_line " "
  115. print_uboot_install_instructions "${pkgname}" "${script}"
  116. print_line " "
  117. print_extlinux_config_remainder "${pkgbase}"
  118. print_separation_line