I need to move on so quick and dirty hacks again:

--- /root/archive/system/2024-08-14/usr/share/grub/001c_grub-mkconfig_lib
      2024-08-08 13:35:17.000000000 +0200
+++ /usr/share/grub/grub-mkconfig_lib   2024-08-14 16:59:19.047344532 +0200
@@ -120,23 +120,37 @@

 prepare_grub_to_access_device ()
 {
+  local -A insmod
+
   old_ifs="$IFS"
   IFS='
 '
   partmap="`"${grub_probe}" --device $@ --target=partmap`"
   for module in ${partmap} ; do
+    if [ "${insmod[$module]}" ]; then
+       continue
+    fi
+
     case "${module}" in
       netbsd | openbsd)
         echo "insmod part_bsd";;
       *)
         echo "insmod part_${module}";;
     esac
+
+    insmod[$module]=1
   done

   # Abstraction modules aren't auto-loaded.
   abstraction="`"${grub_probe}" --device $@ --target=abstraction`"
   for module in ${abstraction} ; do
+    if [ "${insmod[$module]}" ]; then
+       continue
+    fi
+
     echo "insmod ${module}"
+
+    insmod[$module]=1
   done

   fs="`"${grub_probe}" --device $@ --target=fs`"
@@ -154,7 +168,7 @@
   # otherwise set root as per value in device.map.
   fs_hint="`"${grub_probe}" --device $@ --target=compatibility_hint`"
   if [ "x$fs_hint" != x ]; then
-    echo "set root='$fs_hint'"
+    echo "set root='`head -1 <<< $fs_hint`'"
   fi
   if [ "x${GRUB_DISABLE_UUID}" != "xtrue" ] &&
fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`"
; then
     hints="`"${grub_probe}" --device $@ --target=hints_string 2>
/dev/null`" || hints=

Unfortunately Gmail web UI converts tabs to spaces so beware.

Regards,
Opty

On Fri, Aug 9, 2024 at 4:50 PM Opty <opt...@gmail.com> wrote:
> Oh right, I probably found the grub.cfg-breaking culprit:
>
> https://git.savannah.gnu.org/cgit/grub.git/tree/util/grub-mkconfig_lib.in?h=grub-2.12#n157
>
> $fs_hint contains newline when using encrypted BTRFS RAID1.

Reply via email to