# Calculate append=patch format=patch link=/bootmenu/system.config mirror
<reg>(.*)
(.*)
(.*)
(.*)
(.*)
(.*);
</reg>
<text>menuentry "\2" {
   echo "Language: ${bootlang}"
   echo "Keyboard: ${bootkeymap}"
   echo "Timezone: ${boottimezone}"
   echo "Bootparams: ${bootparams}"
   echo "Please wait..."
   linux \3 \4 \6 ${bootparams} ${noefi_opt} ${no_gfxmode}
   initrd \5
}
</text>
<reg>HEADER</reg>
<text>
if [ x$timeout = x ]; then
    set timeout=5
fi
if [ x$default = x ]; then
    set default=0
fi
set fallback=2
set pager=1

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if loadfont /boot/grub/unicode.pf2 ; then
   set gfxmode=auto
   load_video
   if [ x$no_gfxmode = x ]; then
       insmod gfxterm
       terminal_output gfxterm
   else
       terminal_output console
   fi
   insmod gettext
fi

if [ -f /boot/grub/grub-calculate.png ]; then
   insmod png
   background_image -m stretch /boot/grub/grub-calculate.png
fi

if [ x$noefi_opt = x ]; then
   noefi_opt=''
   export noefi_opt
fi

bootparams=calculate=

if [ x$bootlang != x ]
then
    bootparams=${bootparams}lang:${bootlang}
fi
bootparams=${bootparams},

if [ x$bootkeymap != x ]
then
    bootparams=${bootparams}keymap:${bootkeymap}
fi
bootparams=${bootparams},

if [ x$boottimezone != x ]
then
    bootparams=${bootparams}timezone:${boottimezone}
fi
bootparams=${bootparams},

if [ x$bootvga != x ]
then
    bootparams=${bootparams}resolution:${bootvga}
fi
bootparams=${bootparams},

if [ x$bootvideo != x ]
then
    bootparams=${bootparams}video:${bootvideo}
fi
bootparams=${bootparams},

if [ x$bootcomposite != x ]
then
    bootparams=${bootparams}composite:${bootcomposite}
fi

if [ x$bootparams = xcalculate=,,,,, ]
then
    bootparams=
fi

insmod part_gpt

if [ x$no_gfxmode = x ]; then
    menuentry "Disable grub gfxmode" {
        set no_gfxmode="grub_nogfxmode"
        export no_gfxmode
        set timeout=30
        export timeout
        configfile /boot/grub/grub.cfg
    }
fi
</text>
<reg>FOOTER</reg>
<text>
submenu "Advanced Options" {
#?pkg(sys-apps/memtest86+)!=#
   menuentry "memtest86+" {
      linux16 /isolinux/memtest
   }
#pkg#

   menuentry "Disable EFI" {
      echo "Disabling EFI..."
      set noefi_opt="noefi"
      export noefi_opt
      configfile /boot/grub/grub.cfg
   }
}

if [ x$no_gfxmode = x ]; then
    source /boot/grub/lang.cfg
    source /boot/grub/keymap.cfg
else
    source /boot/grub/lang_nogfx.cfg
    source /boot/grub/keymap_nogfx.cfg
fi
source /boot/grub/timezone.cfg
#?os_builder_linux_system==desktop#
source /boot/grub/video.cfg
source /boot/grub/vga.cfg
#os_builder_linux_system#

</text>
