[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[NEW PATCH] os-prober output parser
From: |
Fabian Greffrath |
Subject: |
[NEW PATCH] os-prober output parser |
Date: |
Wed, 05 Mar 2008 13:27:56 +0100 |
User-agent: |
Thunderbird 2.0.0.12 (Windows/20080213) |
I have improved the script a little bit; in particular I moved the
tests for the required software to the beginning of the script and let
it gracefully 'exit 0' if anything is missing.
Let me comment on these tests:
- The first test (lines 19-22) is to check if grub-probe is recent
enough to support the '--device' option. I have changed this to grep
for it in the '--help' output instead of test-probing a given device,
since you never know if a device.map allready exists (imaging booting
from knoppix).
- I have changed the second test (24-27) to not utilize the 'which'
utility anymore. It's in the debianutils package and I don't know if
there's a chance that this is installed on non-Debian systems. On the
other hand, we are utilizing os-prober which is Debian-only at the
moment...
- The third test (30-33) is redundant, strictly speaking. The script
will never enter the for/do loop if the os-prober output is empty.
However, I found it reasonably to 'exit 0' before even attempting to
enter the loop, YMMV. If it doesn't suit you, it can be removed safely.
Furthermore I have removed the 'hurd' stub. For the time beeing, HURD
kernels remain unsupported and throw a warning message just like
macos* and all other !linux and !chain operating systems.
Best Regards,
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.
# 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 "`grub-probe --help 2> /dev/null | grep '\-d,\ \-\-device'`" ] ; then
# grub-probe does not support '--device' option yet (introduced in
1.96+20080228)
exit 0
fi
if [ -x /usr/bin/os-prober -a -x /usr/bin/linux-boot-prober ] ; then : ; else
# os-prober/linux-boot-prober not installed
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
- Re: [NEW PATCH] Add option to grub-probe to accept system devices as arguments, Robert Millan, 2008/03/03
- Re: [NEW PATCH] Add option to grub-probe to accept system devices as arguments, Robert Millan, 2008/03/03
- Re: [NEW PATCH] Add option to grub-probe to accept system devices as arguments, Fabian Greffrath, 2008/03/04
- [NEW PATCH] os-prober output parser,
Fabian Greffrath <=
- Re: [NEW PATCH] os-prober output parser, Fabian Greffrath, 2008/03/13
- Re: [NEW PATCH] os-prober output parser, Robert Millan, 2008/03/19
- Re: [NEW PATCH] os-prober output parser, Fabian Greffrath, 2008/03/19
- Re: [NEW PATCH] os-prober output parser, Robert Millan, 2008/03/19
- Re: [NEW PATCH] os-prober output parser, Fabian Greffrath, 2008/03/20
- Re: [NEW PATCH] os-prober output parser, Robert Millan, 2008/03/20
- Re: [NEW PATCH] os-prober output parser, Fabian Greffrath, 2008/03/25