grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug#461442: please add support for os-prober to detect other OSes in


From: Fabian Greffrath
Subject: Re: Bug#461442: please add support for os-prober to detect other OSes in update-grub
Date: Wed, 30 Jan 2008 11:48:32 +0100
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

Robert Millan schrieb:
You could try with qemu.
Update:
I tried with Knoppix on a computer that has Debian sid and Windows XP installed. The attached script did it's job well - of course except for the part when it has to convert Linux device names to GRUB drives (see #462218). Support for HURD is still outstanding, though.

Cheers,
Fabian

--
Dipl.-Phys. Fabian Greffrath

Ruhr-Universität Bochum
Lehrstuhl für Energieanlagen und Energieprozesstechnik (LEAT)
Universitätsstr. 150, IB 3/134
D-44780 Bochum

Telefon: +49 (0)234 / 32-26334
Fax:     +49 (0)234 / 32-14227
E-Mail:  address@hidden

#! /bin/sh -e

# update-grub helper script.
# <insert copyright and license blurb here>

convert_device_to_grub_drive () {
  # you know what's missing here...
  echo $1
}

if [ -x "`which os-prober 2>/dev/null`" ] ; then
  OSPROBED="`os-prober | tr ' ' '|' | paste -s -d ' '`"
fi

if [ -n "${OSPROBED}" ] ; then
  for OS in ${OSPROBED} ; do
    DEVICE="`echo ${OS} | cut -d ':' -f 1`"
    LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '|' ' '`"
    LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '|' ' '`"
    BOOT="`echo ${OS} | cut -d ':' -f 4`"

    if [ -z "${LONGNAME}" ] ; then
      LONGNAME="${LABEL}"
    fi

    echo "Found ${LONGNAME} on ${DEVICE}" >&2

    case "${BOOT}" in
      chain)
        CHAINROOT="`convert_device_to_grub_drive ${DEVICE}`"

        cat << EOF
menuentry "${LONGNAME} (on ${DEVICE})" {
        set root=${CHAINROOT}
        chainloader +1
}
EOF
      ;;
      linux)
        if [ -x "`which linux-boot-prober 2>/dev/null`" ] ; then
          LINUXPROBED="`linux-boot-prober ${DEVICE} | tr ' ' '|' | paste -s -d 
' '`"
        fi

        if [ -n "${LINUXPROBED}" ] ; then
          for LINUX in ${LINUXPROBED} ; do
            LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
            LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
            LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '|' ' '`"
            LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
            LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
            LPARAMS="`echo ${LINUX} | cut -d ':' -f 6 | tr '|' ' '`"

            LINUXROOT="`convert_device_to_grub_drive ${LBOOT}`"

            if [ -z "${LLABEL}" ] ; then
              LLABEL="${LONGNAME}"
            fi

            cat << EOF
menuentry "${LLABEL} (on ${DEVICE})" {
        set root=${LINUXROOT}
        linux ${LKERNEL} ${LPARAMS}
EOF
            if [ -n "${LINITRD}" ] ; then
              cat << EOF
        initrd ${LINITRD}
EOF
            fi
            cat << EOF
}
EOF
          done
        fi
      ;;
      hurd)
        # not yet...
      ;;
      *)
      ;;
    esac
  done
fi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]