Robert Millan schrieb:
It is difficult to merge things in upstream when they haven't been writen
purposely for upstream. This is a decision that has to be taken now.
I believe I am not the one to decide about this.
Please find attached my script proposal. It's only 1.5 kB, tab-indented
and full of comments and paranoid test. I'd like to hand it over to the
GRUB-maintainers (including copyright!) for further nursing. ;)
Cheers,
Fabian
#! /bin/sh -e
# update-grub helper script.
# <insert copyright and license blurb here>
if [ -x "`which os-prober 2>/dev/null`" ] ; then
# os-prober output contains the partition and the name, a label and
# a boot keyword, separated by colons (:) for each detected OS.
# It may contain space characters and linebreaks,
# e.g. "/dev/hda2:Windows XP Professional:Windows:chain".
# Convert space characters to underscores and linebreaks to spaces.
RESULT="`os-prober | tr ' ' '_' | tr '\n' ' '`"
fi
if [ "x${RESULT}" != "x" ] ; then
for OS in "${RESULT}" ; do
# e.g. "/dev/hda2:Windows_XP_Professional:Windows:chain"
PARTITION="`echo ${OS} | cut -d ':' -f 1`"
LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '_' ' '`"
LABEL="`echo ${OS} | cut -d ':' -f 3`"
BOOT="`echo ${OS} | cut -d ':' -f 4`"
if [ "x${LONGNAME}" = "x" ] ; then
# is this likely to happen?
LONGNAME="${LABEL}"
fi
case "${BOOT}" in
chain)
echo "Found ${LONGNAME} on ${PARTITION}" >&2
if [ -x "`which grub-probe 2>/dev/null`" ] ;
then
# need to convert partition device to
GRUB drive here!
GRUB_DEVICE="`grub-probe --something
${PARTITION}`"
cat << EOF
menuentry "${LONGNAME} (on ${PARTITION})" {
set root=${GRUB_DEVICE}
chainloader +1
}
EOF
else # wtf?!
echo " Error: Missing grub-probe!" >&2
fi
;;
macos|macosx)
# can't macos* also be chainloaded?
;;
hurd|linux)
# other Linux/HURD-Systems are not (yet)
supported
# with the given output of os-prober
;;
*)
# is it possible to reach here?
;;
esac
done
fi