All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabian Greffrath <greffrath@leat.rub.de>
To: The development of GRUB 2 <grub-devel@gnu.org>
Cc: "Yoshinori K. Okuji" <okuji@enbug.org>
Subject: Re: [NEW PATCH] os-prober output parser
Date: Mon, 07 Apr 2008 10:39:46 +0200	[thread overview]
Message-ID: <47F9DDD2.8060101@leat.rub.de> (raw)
In-Reply-To: <47E8A979.8080009@leat.rub.de>

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

Fabian Greffrath schrieb:
> Fine! However, should the script utilize the 'which' command or not?

Allright, since I haven't heard any further complaints regarding the 
usage of the 'which' command, here's my proposed script. Please remove 
the UTF-8 crap from the shebang line if it is still there.


2008-04-07  Fabian Greffrath  <fabian.greffrath@web.de>

	* util\grub.d\30_os-prober: New script. Use `os-prober' and
	`linux-boot-prober' (if installed) to detect other operating
	systems which are installed on the computer and add them to
	the boot menu.


-- 
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:  greffrath@leat.ruhr-uni-bochum.de

[-- Attachment #2: 30_os-prober --]
[-- Type: text/plain, Size: 2570 bytes --]

#! /bin/sh -e

# update-grub helper script.
# Copyright (C) 2006,2007,2008  Free Software Foundation, Inc.
#
# 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/>.

if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then
  # missing os-prober and/or linux-boot-prober
  exit 0
fi

OSPROBED="`os-prober 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
if [ -z "${OSPROBED}" ] ; then
  # empty os-prober output, nothing doing
  exit 0
fi

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="`grub-probe --target=drive --device ${DEVICE} 2> /dev/null`"

      cat << EOF
menuentry "${LONGNAME} (on ${DEVICE})" {
	set root=${CHAINROOT}
	chainloader +1
}
EOF
    ;;
    linux)
      LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
 
      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="`grub-probe --target=drive --device ${LBOOT} 2> /dev/null`"

        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
    ;;
    hurd|*)
      echo "  ${LONGNAME} is not yet supported by update-grub." >&2
    ;;
  esac
done

  reply	other threads:[~2008-04-07  8:39 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-12 13:17 [PATCH] Add option to grub-probe to accept system devices as arguments Fabian Greffrath
2008-02-13 13:03 ` Fabian Greffrath
2008-02-13 15:42 ` Robert Millan
2008-02-13 16:51   ` Fabian Greffrath
2008-02-13 19:35     ` Robert Millan
2008-02-14  8:33       ` Fabian Greffrath
2008-02-17 13:42         ` Robert Millan
2008-02-18 12:54           ` Fabian Greffrath
2008-02-20 14:14           ` Fabian Greffrath
2008-02-22 14:32           ` [NEW PATCH] " Fabian Greffrath
2008-02-22 15:36             ` Fabian Greffrath
2008-02-24 15:22               ` Robert Millan
2008-02-25  9:49                 ` Fabian Greffrath
2008-02-25 14:20                   ` Robert Millan
2008-02-28  7:26                     ` Fabian Greffrath
2008-02-28 10:10                       ` Robert Millan
2008-02-28 10:28                         ` Fabian Greffrath
2008-02-28 10:41                           ` Robert Millan
2008-02-28 11:46                             ` Fabian Greffrath
2008-02-28 17:07                               ` Robert Millan
2008-02-29  8:33                                 ` Fabian Greffrath
2008-03-03 21:06                                   ` Robert Millan
2008-03-04  7:57                                     ` Fabian Greffrath
2008-03-05 12:27                                     ` [NEW PATCH] os-prober output parser Fabian Greffrath
2008-03-13  7:56                                       ` Fabian Greffrath
2008-03-19 14:38                                       ` Robert Millan
2008-03-19 15:18                                         ` Fabian Greffrath
2008-03-19 16:10                                           ` Robert Millan
2008-03-20 10:02                                             ` Fabian Greffrath
2008-03-20 10:36                                               ` Robert Millan
2008-03-25  7:27                                                 ` Fabian Greffrath
2008-04-07  8:39                                                   ` Fabian Greffrath [this message]
2008-04-09  8:32                                                     ` Fabian Greffrath
2008-04-09 10:11                                                       ` Robert Millan
2008-04-09 12:41                                                         ` Fabian Greffrath
2008-04-13 10:52                                                     ` Robert Millan
2008-04-14 11:11                                                       ` Fabian Greffrath
2008-02-29 13:46                                 ` [NEW PATCH] Add option to grub-probe to accept system devices as arguments Fabian Greffrath
2008-03-03 20:58                                   ` Robert Millan
2008-02-24 15:23             ` Robert Millan

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=47F9DDD2.8060101@leat.rub.de \
    --to=greffrath@leat.rub.de \
    --cc=grub-devel@gnu.org \
    --cc=okuji@enbug.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.