0002-10_linux-20_linux_xen-detect-parabola-initramfs.patch 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. From 328495cd629ed53a0d9e046f3e2faa435c608d12 Mon Sep 17 00:00:00 2001
  2. From: "Luke T. Shumaker" <lukeshu@lukeshu.com>
  3. Date: Sat, 13 Jan 2024 15:54:01 -0700
  4. Subject: [PATCH 2/4] 10_linux, 20_linux_xen: detect parabola initramfs
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Based on the following downstream commits:
  9. - https://gitlab.archlinux.org/archlinux/packaging/packages/grub/-/commit/438b56c08a536202ae922c8a3f6023bd9aea7330
  10. - https://gitlab.archlinux.org/archlinux/packaging/packages/grub/-/commit/1c268927020d5ee37055250ee3de3ce4fdae23eb
  11. - https://gitlab.archlinux.org/archlinux/packaging/packages/grub/-/commit/fa9d34525f424546cf83cf396ef7d6d4b817640b
  12. - https://gitlab.archlinux.org/archlinux/packaging/packages/grub/-/commit/5347cbc7b8122e4f36068c12a649960240c4be07
  13. - https://gitlab.archlinux.org/archlinux/packaging/packages/grub/-/commit/80d4490bc85d2b35a6e08c1bb3211391e70f24ca
  14. - https://git.parabola.nu/abslibre.git/commit/?id=575127b3d909f886e87526c3e9369fe690d862c2
  15. - https://git.parabola.nu/abslibre.git/commit/?id=be608b5fc736ea2249b1224f2f6999cb76ca5059
  16. - https://git.parabola.nu/abslibre.git/commit/?id=cfc5b3757f11b7760d5246cd181f084328cae912
  17. - https://git.parabola.nu/abslibre.git/commit/?id=ede60ed00d4c781adadca99ddef19be1bf56e8aa
  18. - https://git.parabola.nu/abslibre.git/commit/?id=eaf3d6f308094aca4f87ed111c2580e81b18f269
  19. - https://git.parabola.nu/abslibre.git/commit/?id=d3fff86fb7d77716f3ca171b633bd462202a3b18
  20. - https://git.parabola.nu/abslibre.git/commit/?id=856b2c7c881ecf9ef2607a9a4c4466635fea857f
  21. Co-Authored-By: Keshav Amburay <the.ridikulus.rat@gmail.com> (2014)
  22. Co-Authored-By: Tobias Powalowski <tpowa@archlinux.org> (2014)
  23. Co-Authored-By: Christian Hesse <eworm@archlinux.org> (2016, 2021)
  24. Co-Authored-By: André Fabian Silva Delgado <emulatorman@parabola.nu> (2014)
  25. Co-Authored-By: Márcio Alexandre Silva Delgado <coadde@parabola.nu> (2014-2015)
  26. Co-Authored-By: Omar Vega Ramos <ovruni@gnu.org.pe> (2021)
  27. ---
  28. util/grub.d/10_linux.in | 37 ++++++++++++++++++++++++++++++++-----
  29. util/grub.d/20_linux_xen.in | 24 +++++++++++++++++++-----
  30. 2 files changed, 51 insertions(+), 10 deletions(-)
  31. diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
  32. index cc393be7e..772966b89 100644
  33. --- a/util/grub.d/10_linux.in
  34. +++ b/util/grub.d/10_linux.in
  35. @@ -93,10 +93,14 @@ linux_entry ()
  36. fi
  37. if [ x$type != xsimple ] ; then
  38. case $type in
  39. + booster)
  40. + title="$(gettext_printf "%s, %s kernel (booster initramfs)" "${os}" "${version}")" ;;
  41. + fallback)
  42. + title="$(gettext_printf "%s, %s kernel (fallback initramfs)" "${os}" "${version}")" ;;
  43. recovery)
  44. - title="$(gettext_printf "%s, with Linux %s (recovery mode)" "${os}" "${version}")" ;;
  45. + title="$(gettext_printf "%s, %s kernel (recovery mode)" "${os}" "${version}")" ;;
  46. *)
  47. - title="$(gettext_printf "%s, with Linux %s" "${os}" "${version}")" ;;
  48. + title="$(gettext_printf "%s, %s kernel" "${os}" "${version}")" ;;
  49. esac
  50. if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
  51. replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
  52. @@ -108,7 +112,7 @@ linux_entry ()
  53. else
  54. echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
  55. fi
  56. - if [ x$type != xrecovery ] ; then
  57. + if [ x$type != xrecovery ] && [ x$type != xfallback ] ; then
  58. save_default_entry | grub_add_tab
  59. fi
  60. @@ -140,7 +144,7 @@ linux_entry ()
  61. fi
  62. printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
  63. fi
  64. - message="$(gettext_printf "Loading Linux %s ..." ${version})"
  65. + message="$(gettext_printf "Loading %s kernel ..." ${version})"
  66. sed "s/^/$submenu_indentation/" << EOF
  67. echo '$(echo "$message" | grub_quote)'
  68. linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
  69. @@ -210,7 +214,7 @@ for linux in ${reverse_sorted_list}; do
  70. basename=`basename $linux`
  71. dirname=`dirname $linux`
  72. rel_dirname=`make_system_path_relative_to_its_root $dirname`
  73. - version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
  74. + version=`echo $basename | sed -e "s,vmlinuz-,,g"`
  75. alt_version=`echo $version | sed -e "s,\.old$,,g"`
  76. linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
  77. @@ -299,6 +303,29 @@ for linux in ${reverse_sorted_list}; do
  78. linux_entry "${OS}" "${version}" advanced \
  79. "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
  80. +
  81. + if test -e "${dirname}/initramfs-${version}-fallback.img" ; then
  82. + initrd="${initrd_early} initramfs-${version}-fallback.img"
  83. +
  84. + if test -n "${initrd}" ; then
  85. + gettext_printf "Found fallback initramfs image: %s\n" "${dirname}/${initrd}" >&2
  86. + fi
  87. +
  88. + linux_entry "${OS}" "${version}" fallback \
  89. + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
  90. + fi
  91. +
  92. + if test -e "${dirname}/booster-${version}.img" ; then
  93. + initrd="${initrd_early} booster-${version}.img"
  94. +
  95. + if test -n "${initrd}" ; then
  96. + gettext_printf "Found booster initrd image(s) in %s:%s\n" "${dirname}" "${initrd_extra} ${initrd}" >&2
  97. + fi
  98. +
  99. + linux_entry "${OS}" "${version}" booster \
  100. + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
  101. + fi
  102. +
  103. if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
  104. linux_entry "${OS}" "${version}" recovery \
  105. "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}"
  106. diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
  107. index 94dd8be13..abc2fd7b4 100644
  108. --- a/util/grub.d/20_linux_xen.in
  109. +++ b/util/grub.d/20_linux_xen.in
  110. @@ -120,9 +120,11 @@ linux_entry_xsm ()
  111. fi
  112. if [ x$type != xsimple ] ; then
  113. if [ x$type = xrecovery ] ; then
  114. - title="$(gettext_printf "%s, with Xen %s and Linux %s (recovery mode)" "${os}" "${entry_xen_version}" "${version}")"
  115. + title="$(gettext_printf "%s, with Xen %s and %s kernel (recovery mode)" "${os}" "${entry_xen_version}" "${version}")"
  116. + elif [ x$type = xfallback ] ; then
  117. + title="$(gettext_printf "%s, with Xen %s and %s kernel (fallback initramfs)" "${os}" "${entry_ xen_version}" "${version}")"
  118. else
  119. - title="$(gettext_printf "%s, with Xen %s and Linux %s" "${os}" "${entry_xen_version}" "${version}")"
  120. + title="$(gettext_printf "%s, with Xen %s and %s kernel" "${os}" "${entry_xen_version}" "${version}")"
  121. fi
  122. replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
  123. if [ x"Xen ${entry_xen_version}>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
  124. @@ -135,7 +137,7 @@ linux_entry_xsm ()
  125. title="$(gettext_printf "%s, with Xen hypervisor" "${os}")"
  126. echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'xen-gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
  127. fi
  128. - if [ x$type != xrecovery ] ; then
  129. + if [ x$type != xrecovery ] && [ x$type != xfallback ] ; then
  130. save_default_entry | grub_add_tab | sed "s/^/$submenu_indentation/"
  131. fi
  132. @@ -144,7 +146,7 @@ linux_entry_xsm ()
  133. fi
  134. printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
  135. xmessage="$(gettext_printf "Loading Xen %s ..." ${entry_xen_version})"
  136. - lmessage="$(gettext_printf "Loading Linux %s ..." ${version})"
  137. + lmessage="$(gettext_printf "Loading %s kernel ..." ${version})"
  138. sed "s/^/$submenu_indentation/" << EOF
  139. echo '$(echo "$xmessage" | grub_quote)'
  140. if [ "\$grub_platform" = "pc" -o "\$grub_platform" = "" ]; then
  141. @@ -290,7 +292,7 @@ for current_xen in ${reverse_sorted_xen_list}; do
  142. basename=`basename $linux`
  143. dirname=`dirname $linux`
  144. rel_dirname=`make_system_path_relative_to_its_root $dirname`
  145. - version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
  146. + version=`echo $basename | sed -e "s,vmlinuz-,,g"`
  147. alt_version=`echo $version | sed -e "s,\.old$,,g"`
  148. linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
  149. @@ -361,6 +363,18 @@ for current_xen in ${reverse_sorted_xen_list}; do
  150. linux_entry "${OS}" "${version}" "${xen_version}" advanced \
  151. "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
  152. +
  153. + if test -e "${dirname}/initramfs-${version}-fallback.img" ; then
  154. + initrd="initramfs-${version}-fallback.img"
  155. +
  156. + if test -n "${initrd}" ; then
  157. + gettext_printf "Found fallback initramfs image: %s\n" "${dirname}/${initrd}" >&2
  158. + fi
  159. +
  160. + linux_entry "${OS}" "${version}" "${xen_version}" fallback \
  161. + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
  162. + fi
  163. +
  164. if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
  165. linux_entry "${OS}" "${version}" "${xen_version}" recovery \
  166. "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
  167. --
  168. 2.43.0