All of lore.kernel.org
 help / color / mirror / Atom feed
From: adrian15 <adrian15sgd@gmail.com>
To: grub-devel@gnu.org
Subject: How one is supposed to write kind-of-library cfg files?
Date: Sun, 16 Mar 2014 04:49:24 +0100	[thread overview]
Message-ID: <53251F44.3000505@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1806 bytes --]

( Using 2.02~beta2-7 from Debian Unstable  )

   I have tried to write some cfg files to kind of organise them as 
libraries but it does not work as expected.

   It seems as the sourced cfg files are being interpreted.


   Here below you will find the overall idea in an theoric example.
Attached you will find an actual code (although you are missing some 
pieces from Super Grub2 Disk).


When selecting the "Boot manually..." submenu (not when trying to run 
one of their options) I am getting these errors:

BEGIN

error: syntax error
error: Incorrect command.
error: syntax error
error: Incorrect command.
error: syntax error
error: syntax error
error: Incorrect command.
error: syntax error
error: can't find command `searchindevice'
FATAL: int13_cdrom: function 42. Can't use 64bits lba

END

searchindevice is a function which it's sourced in main.cfg so it should 
be detected ok.

But anyways... the run_option function is being interpreted while I do 
not want it !!!

I have also tried to replace source command by extract_entries_source. I 
get different output but the same problem, the sourced file is being 
interpreted (I mean it is being run).

Thank you.


########################### caller.cfg

function process_option {

   set option_cfg="${1}"
   source ${option_cfg}
   menuentry ${option_title} {
     source ${option_cfg}
     run_option
   }

}

process_option ${prefix}/called.cfg
process_option ${prefix}/option2.cfg

########################### called.cfg

set option_title="My title"



function run_option {

   function aux_lib {

   }

   function aux_lib2 {

   }

   aux_lib
   aux_lib2

   do_interesting_stuff

}


adrian15
-- 
Support free software. Donate to Super Grub Disk. Apoya el software 
libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/

[-- Attachment #2: main.cfg --]
[-- Type: text/plain, Size: 8838 bytes --]

# Super Grub Disk Main Configuration file
# Copyright (C) 2009  Adrian Gibanel Lopez.
#
# Super Grub Disk is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Super Grub Disk is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.

# Configure gfxterm, but allow it to be disabled by holding shift during boot.
# gfxterm is required to display non-ASCII translations.
loadfont "$prefix/unifont.pf2"
if keystatus --shift; then
  disable_gfxterm=true
  # export disable_gfxterm is needed so that the setting will persist even after
  # a "configfile /boot/grub/main.cfg" (which is what language_select.cfg does after
  # you select a new language)
  export disable_gfxterm

  # The following strings are intentionally not made translateable.
  echo "It has been detected that the shift key was held down. Because of this SG2D"
  echo "will use VGA text mode rather than gfxterm. This will cause display problems"
  echo "when using some non-English translations."
  echo
  echo "Press escape to continue to the main menu"
  sleep --interruptible 9999
fi

if [ "$disable_gfxterm" != true ]; then
  insmod all_video
  gfxmode=640x480
  if terminal_output --append gfxterm; \
  then \
      terminal_output --remove console; \
  fi
fi

# Export the variables so that they persist when loading a new menu.
export menu_color_normal
export menu_color_highlight
export menu_color_background
export bwcolor

function set_sgd_colors {
  if [ "$bwcolor" = "yes" ]; then
    menu_color_normal=white/black
    menu_color_highlight=black/white
    menu_color_background=black/white
  else
    menu_color_normal=white/brown
    menu_color_highlight=white/blue
    menu_color_background=yellow/cyan
  fi
}

set_sgd_colors

# Set secondary_locale_dir to the directory containing SG2D specific mo files.
# This makes grub aware of translations for SG2D specific strings.
secondary_locale_dir="${prefix}/sgd_locale/"

insmod part_acorn
insmod part_amiga
insmod part_apple
insmod part_bsd
insmod part_gpt
insmod part_msdos
insmod part_sun
insmod part_sunpc

# Prepare environment variables, needed mostly for update_paths()
export prefix_device prefix_path prefix_uuid
regexp -s prefix_device '^\((.*)\)/' "$prefix"
regexp -s prefix_path '^\(.*\)/(.*)$' "$prefix"
probe --fs-uuid --set=prefix_uuid "$prefix_device"

# Define a function for updating paths when device names change.
# search.mod is required for update-paths, and must be loaded before device
# names change because $prefix will be invalid.
insmod search

function update_paths {
  search --fs-uuid --set=prefix_device $prefix_uuid
  prefix="($prefix_device)/$prefix_path"
}

function process_option {

  set option_cfg="$1"
  source ${option_cfg}
  menuentry ${option_title} {
    source ${option_cfg}
    run_option
  }

}

# Timeout for menu
#set timeout=10

# Set default boot entry as Entry number 2 (counting from 0)
set default=2

# Get the version number for this Super GRUB2 Disk release
source "${prefix}/version.cfg"

# Get design variables
source "${prefix}/design.cfg"

menuentry "               ====---==- Super Grub2 Disk $sgrub_version  -==---==== " {
  # Set pager=1 so ls output doesn't scroll past the top of the screen
  # but restore $pager to its previous value when finished
  set oldpager="${pager}"
  set pager=1

  cat /boot/grub/AUTHORS
  cat /boot/grub/COPYING

  set pager="${oldpager}"
  unset oldpager
  echo $"Press escape to return to the main menu"
  sleep --interruptible 9999
}

menuentry $"Languages..." {
  configfile "${prefix}/language_select.cfg"
}

# Everything
menuentry $"Everything" {
  configfile "${prefix}/everything.cfg"
}

submenu $"Boot manually..." {

  process_option "${prefix}/osdetect.cfg"

  # Load cfgdetect script as a new menu
  menuentry $"grub.cfg - (GRUB2 configuration files)" {
    currentmenu_str=$"grub.cfg - (GRUB2 configuration files)"
    export currentmenu_str
    menuinteractive=yes
    export menuinteractive
    configfile "${prefix}/cfgdetect.cfg"
  }

  # Load menulstdetect script as a new menu
  menuentry $"menu.lst - (GRUB legacy configuration files)" {
    currentmenu_str=$"menu.lst - (GRUB legacy configuration files)"
    export currentmenu_str
    menuinteractive=yes
    export menuinteractive
    configfile "${prefix}/menulstdetect.cfg"
  }

  # Load grubdetect script as a new menu
  menuentry $"core.img - (GRUB2 installation (even if mbr is overwritten))" {
    currentmenu_str=$"core.img - (GRUB2 installation (even if mbr is overwritten))"
    export currentmenu_str
    menuinteractive=yes
    export menuinteractive
    configfile "${prefix}/grubdetect.cfg"
  }

  # Load autoiso script as a new menu
  menuentry $"Bootable ISOs (in /boot-isos or /boot/boot-isos)" {
    currentmenu_str=$"Bootable ISOs (in /boot-isos or /boot/boot-isos)"
    export currentmenu_str
    menuinteractive=yes
    export menuinteractive
    configfile "${prefix}/autoiso.cfg"
  }

}

submenu $"Extra GRUB2 functionality..." {

  menuentry $"Enable GRUB2's LVM support" {
    insmod lvm
    echo $"Press escape to return to the main menu (or wait 5 seconds)"
    sleep --interruptible 5
    configfile "${prefix}/main.cfg"
  }

  menuentry $"Enable GRUB2's RAID support" {
    insmod dm_nv
    insmod mdraid09_be
    insmod mdraid09
    insmod mdraid1x
    insmod raid5rec
    insmod raid6rec
    echo $"Press escape to return to the main menu (or wait 5 seconds)"
    sleep --interruptible 5
    configfile "${prefix}/main.cfg"
  }

  menuentry $"Enable GRUB2's PATA support (to work around BIOS bugs/limitations)" {
    insmod ata
    update_paths
    echo $"Press escape to return to the main menu (or wait 5 seconds)"
    sleep --interruptible 5
    configfile "${prefix}/main.cfg"
  }

  menuentry $"Enable GRUB2's USB support *experimental*" {
    insmod ohci
    insmod uhci
    insmod usbms
    update_paths
    echo $"Press escape to return to the main menu (or wait 5 seconds)"
    sleep --interruptible 5
    configfile "${prefix}/main.cfg"
  }

  menuentry $"Mount encrypted volumes (LUKS and geli)" {
    insmod luks
    insmod geli

    cryptomount -a
    echo $"Press escape to return to the main menu (or wait 5 seconds)"
    sleep --interruptible 5
    configfile "${prefix}/main.cfg"
  }

  menuentry $"Enable serial terminal" {
    serial
    terminal_input --append serial
    terminal_output --append serial
    echo $"Press escape to return to the main menu (or wait 5 seconds)"
    sleep --interruptible 5
    configfile "${prefix}/main.cfg"
  }

  source "${prefix}/return.cfg"
}

submenu $"Extra Search functionality..." {

  menuentry $"Search in floppy ON/OFF (Default: OFF)" {
    if [ "$fd0search" = 'yes' ]; then
      fd0search=no
    else
      fd0search=yes
    fi
    export fd0search
    echo $"Search in FLOPPY: ${fd0search}"
    echo $"Press escape to return to the main menu (or wait 5 seconds)"
    sleep --interruptible 5
    configfile "${prefix}/main.cfg"

  }

  menuentry $"Search in CDROM ON/OFF (Default: OFF)" {
    if [ "$cdsearch" = 'yes' ]; then
      cdsearch=no
    else
      cdsearch=yes
    fi
    export cdsearch
    echo $"Search in CDROM: ${cdsearch}"
    echo $"Press escape to return to the main menu (or wait 5 seconds)"
    sleep --interruptible 5
    configfile "${prefix}/main.cfg"

  }

  source "${prefix}/return.cfg"

}
menuentry $"List devices/partitions" {
  # Set pager=1 so ls output doesn't scroll past the top of the screen
  # but restore $pager to its previous value when finished
  set oldpager="${pager}"
  set pager=1

  ls -l

  set pager="${oldpager}"
  unset oldpager

  echo $"Press escape to return to the main menu"
  sleep --interruptible 9999
}

menuentry $"Color ON/OFF" {
  if [ "$bwcolor" = 'yes' ]; then
    bwcolor=no
  else
    bwcolor=yes
  fi

  set_sgd_colors
}

# If it exists, source $prefix/sgd_custom.cfg. This follows the same idea as
# grub-mkconfig generated grub.cfg files sourcing $prefix/custom.cfg, though
# it's less needed here since one could add custom code to this file directly
# whereas their distro might automatically overwrite /boot/grub/grub.cfg on
# kernel upgrades. The main motivation for adding this was the vmtest script
# which I use heavily during Super GRUB2 Disk development, but this feature
# might also be useful to others.
if [ -e "$prefix/sgd_custom.cfg" ]; then
  source "$prefix/sgd_custom.cfg"
fi

[-- Attachment #3: osdetect.cfg --]
[-- Type: text/plain, Size: 12071 bytes --]

# Sample GRUB script to autodetect operating systems
#
# Copyright (C) 2010  Free Software Foundation, Inc.
# Copyright (C) 2011, 2012 Jordan Uggla
# Copyright (C) 2011, 2012 Adrian Gibanel
# Copyright (C) 2013 Niall Walsh
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.

set option_title=$"Operating Systems"

function run_option {

    source "${prefix}/topbootmenu.cfg"

    source "${prefix}/tools.cfg"

    set saved_root=$root

    function freebsd_ufs_variants {
	set device=$1
	set fstype=$2
	set uuid=$3

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device)" $device $uuid {
	    set root=$2
	    set uuid=$3

	    kfreebsd /boot/kernel/kernel
	    set kFreeBSD.acpi_load=YES
	    set kFreeBSD.hint.acpi.0.disabled=0
	    set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
	    kfreebsd_loadenv /boot/device.hints
	}

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (single)" $device $uuid {
	    set root=$2
	    set uuid=$3

	    kfreebsd /boot/kernel/kernel -s
	    set kFreeBSD.acpi_load=YES
	    set kFreeBSD.hint.acpi.0.disabled=0
	    set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
	    kfreebsd_loadenv /boot/device.hints
	}

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (verbose)" $device $uuid {
	    set root=$2
	    set uuid=$3

	    kfreebsd /boot/kernel/kernel -v
	    set kFreeBSD.acpi_load=YES
	    set kFreeBSD.hint.acpi.0.disabled=0
	    set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
	    kfreebsd_loadenv /boot/device.hints
	}

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (no ACPI)" $device $uuid {
	    set root=$2
	    set uuid=$3

	    kfreebsd /boot/kernel/kernel -v
	    unset kFreeBSD.acpi_load
	    set kFreeBSD.hint.acpi.0.disabled=1
	    set kFreeBSD.loader.acpi_disabled_by_user=1
	    set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
	    kfreebsd_loadenv /boot/device.hints
	}

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (safe mode)" $device $uuid {
	    set root=$2
	    set uuid=$3

	    kfreebsd /boot/kernel/kernel -v
	    unset kFreeBSD.acpi_load
	    set kFreeBSD.hint.acpi.0.disabled=1
	    set kFreeBSD.loader.acpi_disabled_by_user=1
	    set kFreeBSD.hint.apic.0.disabled=1
	    set kFreeBSD.hw.ata.ata_dma=0
	    set kFreeBSD.hw.ata.atapi_dma=0
	    set kFreeBSD.hw.ata.wc=0
	    set kFreeBSD.hw.eisa_slots=0
	    set kFreeBSD.hint.kbdmux.0.disabled=1
	    set kFreeBSD.vfs.root.mountfrom=ufs:ufsid/$uuid
	    kfreebsd_loadenv /boot/device.hints
	}

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (Default boot loader)" $device $uuid {
	    set root=$2

	    kfreebsd /boot/loader
	}
    }

    function freebsd_zfs_variants {
	set device=$1
	set fstype=zfs

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device)" $device {
	    set root=$2

	    kfreebsd /@/boot/kernel/kernel
	    set kFreeBSD.acpi_load=YES
	    set kFreeBSD.hint.acpi.0.disabled=0
	    kfreebsd_module_elf /@/boot/kernel/opensolaris.ko
	    kfreebsd_module_elf /@/boot/kernel/zfs.ko
	    kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
	    probe -l -s name $root
	    set kFreeBSD.vfs.root.mountfrom=zfs:$name
	    kfreebsd_loadenv /@/boot/device.hints
	}

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (single)" $device {
	    set root=$2

	    kfreebsd /@/boot/kernel/kernel -s
	    set kFreeBSD.acpi_load=YES
	    set kFreeBSD.hint.acpi.0.disabled=0
	    kfreebsd_module_elf /@/boot/kernel/opensolaris.ko
	    kfreebsd_module_elf /@/boot/kernel/zfs.ko
	    kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
	    probe -l -s name $root
	    set kFreeBSD.vfs.root.mountfrom=zfs:$name
	    kfreebsd_loadenv /@/boot/device.hints
	}

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (verbose)" $device {
	    set root=$2

	    kfreebsd /@/boot/kernel/kernel -v
	    set kFreeBSD.acpi_load=YES
	    set kFreeBSD.hint.acpi.0.disabled=0
	    kfreebsd_module_elf /@/boot/kernel/opensolaris.ko
	    kfreebsd_module_elf /@/boot/kernel/zfs.ko
	    kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
	    probe -l -s name $root
	    set kFreeBSD.vfs.root.mountfrom=zfs:$name
	    kfreebsd_loadenv /@/boot/device.hints
	}

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (no ACPI)" $device {
	    set root=$2

	    kfreebsd /@/boot/kernel/kernel -v
	    unset kFreeBSD.acpi_load
	    set kFreeBSD.hint.acpi.0.disabled=1
	    set kFreeBSD.loader.acpi_disabled_by_user=1
	    kfreebsd_module_elf /@/boot/kernel/opensolaris.ko
	    kfreebsd_module_elf /@/boot/kernel/zfs.ko
	    kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
	    probe -l -s name $root
	    set kFreeBSD.vfs.root.mountfrom=zfs:$name
	    kfreebsd_loadenv /@/boot/device.hints
	}

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (safe mode)" $device {
	    set root=$2

	    kfreebsd /@/boot/kernel/kernel -v
	    unset kFreeBSD.acpi_load
	    set kFreeBSD.hint.acpi.0.disabled=1
	    set kFreeBSD.loader.acpi_disabled_by_user=1
	    set kFreeBSD.hint.apic.0.disabled=1
	    set kFreeBSD.hw.ata.ata_dma=0
	    set kFreeBSD.hw.ata.atapi_dma=0
	    set kFreeBSD.hw.ata.wc=0
	    set kFreeBSD.hw.eisa_slots=0
	    set kFreeBSD.hint.kbdmux.0.disabled=1
	    kfreebsd_module_elf /@/boot/kernel/opensolaris.ko
	    kfreebsd_module_elf /@/boot/kernel/zfs.ko
	    kfreebsd_module /@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
	    probe -l -s name $root
	    set kFreeBSD.vfs.root.mountfrom=zfs:$name
	    kfreebsd_loadenv /@/boot/device.hints
	}

	menuentry "${finaloption_tab_str}FreeBSD ($fstype $device) (Default boot loader)" $device $uuid {
	    set root=$2

	    kfreebsd /@/boot/loader
	}

    }

    function get_efis {
	    blockdev="$1"
	    blockfs="$2"
	    efis=""
	    if [ "$blockfs" = "fat" ]; then
		    for efi in ($blockdev)/efi/*/*.efi ($blockdev)/efi/*/*/*.efi \
		      ($blockdev)/*.efi ($blockdev)/*/*.efi ; do
			    if [ -f "$efi" ] ; then
				    efis="$efis $efi"
			    fi
		    done
		    if [ -n "$efis" ]; then
			    return 0
		    fi
	    fi
	    return 1
    }

    insmod regexp


    for dev in (*); do
	# $device: parenthesis removed from $dev
	regexp -s device '\((.*)\)' $dev
	# Discard floppy and cdrom devices in search
	# But search them if their search has been inforced

	if searchindevice "$device" ; then


	    # $fstype: filesystem type identified
	    probe -s fstype -f $dev
	    # uuid: filesystem UUID
	    probe -s uuid -u $dev

	    if test -f ($device)/bootmgr -a -f ($device)/boot/bcd; then
		menuentry "${finaloption_tab_str}Windows Vista ($device)" $device {
		    set root=$2
		    chainloader +1
		}
	    elif test -f ($device)/ntldr -a \
		-e ($device)/ntdetect.com -a -f ($device)/boot.ini; then
		menuentry "${finaloption_tab_str}Windows NT/2000/XP ($device)" $device {
		    set root=$2
		    regexp -s devnum 'hd([0-9]+)' $root
		    if test "$devnum" != "0"; then
			drivemap -s hd0 $root
		    fi
		    chainloader +1
		}
	    elif test -f ($device)/windows/win.com; then
		menuentry "${finaloption_tab_str}Windows 98/ME ($device)" $device {
		    set root=$2
		    regexp -s devnum 'hd([0-9]+)' $root
		    if test "$devnum" != "0"; then
			drivemap -s hd0 $root
		    fi
		    chainloader +1
		}
	    elif test -f ($device)/io.sys -a -f ($device)/command.com; then
		menuentry "${finaloption_tab_str}MS-DOS ($device)" $device {
		    set root=$2
		    regexp -s devnum 'hd([0-9]+)' $root
		    if test "$devnum" != "0"; then
			drivemap -s hd0 $root
		    fi
		    chainloader +1
		}
	    elif test -f ($device)/kernel.sys; then
		menuentry "${finaloption_tab_str}FreeDOS ($device)" $device {
		    set root=$2
		    regexp -s type '([fh])d[0-9]+' $root
		    regexp -s devnum '[fh]d([0-9]+)' $root
		    if test $type = 'h' -a "$devnum" != "0"; then
			drivemap -s hd0 $root
		    fi
		    chainloader +1
		}
	    elif test "$fstype" = ufs1 -o "$fstype" = ufs2 -a \
		-e ($device)/boot/kernel/kernel -a \
		-e ($device)/boot/device.hints; then

		freebsd_ufs_variants $device $fstype $uuid

	    elif test "$fstype" = zfs -a \
		-e ($device)/@/boot/kernel/kernel -a \
		-e ($device)/@/boot/device.hints; then

		freebsd_zfs_variants $device

	    elif test "$fstype" = hfsplus -a -f ($device)/mach_kernel; then
		menuentry "${finaloption_tab_str}Mac OS X/Darwin" $device $uuid {
		    set root=$2
		    set uuid=$3

		    insmod vbe
		    do_resume=0
		    if [ /var/vm/sleepimage -nt10 / ]; then
			if xnu_resume /var/vm/sleepimage; then
			    do_resume=1
			fi
		    fi
		    if [ $do_resume = 1 ]; then
			xnu_uuid $uuid uuid
			if [ -f /Extra/DSDT.aml ]; then
			    acpi -e /Extra/DSDT.aml
			fi
			xnu_kernel /mach_kernel boot-uuid=${uuid} rd=*uuid
			if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
			    xnu_mkext /System/Library/Extensions.mkext
			else
			    xnu_mkext /System/Library/Extensions
			fi
			if [ -f /Extra/Extensions.mkext ]; then
			    xnu_mkext /Extra/Extensions.mkext
			fi
			if [ -d /Extra/Extensions ]; then
			    xnu_kextdir /Extra/Extensions
			fi
			if [ -f /Extra/devtree.txt ]; then
			    xnu_devtree /Extra/devtree.txt
			fi
			if [ -f /Extra/splash.jpg ]; then
			    insmod jpeg
			    xnu_splash /Extra/splash.jpg
			fi
			if [ -f /Extra/splash.png ]; then
			    insmod png
			    xnu_splash /Extra/splash.png
			fi
			if [ -f /Extra/splash.tga ]; then
			    insmod tga
			    xnu_splash /Extra/splash.tga
			fi
		    fi
		}
	    elif get_efis $device $fstype; then
		    for efi in $efis; do
			    menuentry "${finaloption_tab_str}$efi" "$device" {
				    efi_device="$2"
				    efi="$1"
				    if [ "$grub_platform" = "efi" ]; then
					    root="$efi_device"
					    chainloader "$efi"
				    else
					    echo $"Sorry, but we are booted via BIOS and can not load this OS."
					    echo $"Please try booting SG2D via UEFI."
					    echo $"Press escape to return to the menu"
					    sleep --interruptible 9999
				    fi
			    }
		    done
	    else
		set root=$device
		for file in /boot/vmlinuz-* /boot/linux-* /boot/kernel-genkernel-*; do
		    if test -f $file; then
			regexp -s version '/boot/vmlinuz-(.*)' $file
			regexp -s version '/boot/linux-(.*)' $file
			regexp -s version '/boot/kernel-genkernel-(.*)' $file

			menuentry "${finaloption_tab_str}Linux $file" $device $uuid $file $version {
			    set root=$2
			    set uuid=$3
			    set kernel=$4
			    set version=$5

			    linux $kernel root=UUID=$uuid ro
			    if test -f /boot/initrd-$version.img; then
				initrd /boot/initrd-$version.img
			    elif test -f /boot/initrd.img-$version; then
				initrd /boot/initrd.img-$version
			    elif test -f /boot/initrd-$version; then
				initrd /boot/initrd-$version
			    elif test -f /boot/initramfs-genkernel-$version; then
				initrd /boot/initramfs-genkernel-$version
			    fi
			}

			menuentry "${finaloption_tab_str}Linux $file (single)" $device $uuid $file $version {
			    set root=$2
			    set uuid=$3
			    set kernel=$4
			    set version=$5

			    linux $kernel root=UUID=$uuid ro single
			    if test -f /boot/initrd-$version.img; then
				initrd /boot/initrd-$version.img
			    elif test -f /boot/initrd.img-$version; then
				initrd /boot/initrd.img-$version
			    elif test -f /boot/initrd-$version; then
				initrd /boot/initrd-$version
			    elif test -f /boot/initramfs-genkernel-$version; then
				initrd /boot/initramfs-genkernel-$version
			    fi
			}
		    fi
		done
	    fi
	fi
    done

    set root=$saved_root


}

             reply	other threads:[~2014-03-16  3:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-16  3:49 adrian15 [this message]
2014-03-16  4:21 ` How one is supposed to write kind-of-library cfg files? adrian15
2014-03-16  5:49   ` Andrey Borzenkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53251F44.3000505@gmail.com \
    --to=adrian15sgd@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.