18ade780ed
* util/update-grub_lib.in: Copy to ... * util/grub-mkconfig_lib.in: ... this. Update all users. * util/update-grub_lib.in: Make it a stub to `grub-mkconfigig_lib.in'. * util/update-grub.in: Rename to ... * util/grub-mkconfig.in: ... this. Update all users. Remove `-y' option. Add `--output' option to allow users to specify the generated configuration file. Default to stdout. (update_grub_dir): Rename to ... (grub_mkconfig_dir): ... this. (grub_cfg): Default to an empty string. * conf/common.rmk (update-grub): Rename to ... (grub-mkconfig): ... this. (update-grub_lib): Copy to ... (grub-mkconfig_lib): ... this. (update-grub_SCRIPTS): Copy to ... (grub-mkconfig_SCRIPTS): ... this. Update all users. (update-grub_DATA): Rename to ... (grub-mkconfig_DATA): ... this.
83 lines
2.1 KiB
Bash
83 lines
2.1 KiB
Bash
#! /bin/sh -e
|
|
|
|
# update-grub helper script.
|
|
# Copyright (C) 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/>.
|
|
|
|
prefix=@prefix@
|
|
exec_prefix=@exec_prefix@
|
|
libdir=@libdir@
|
|
. ${libdir}/grub/grub-mkconfig_lib
|
|
|
|
case "`uname 2>/dev/null`" in
|
|
CYGWIN*) ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
|
|
# Try C: even if current system is on other partition.
|
|
case "$SYSTEMDRIVE" in
|
|
[Cc]:) dirlist="C:" ;;
|
|
[D-Zd-z]:) dirlist="C: $SYSTEMDRIVE" ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
|
|
get_os_name_from_boot_ini ()
|
|
{
|
|
# Fail if no or more than one partition.
|
|
test "`sed -n 's,^\(\(multi\|scsi\)[^=]*\)=.*$,\1,p' "$1" 2>/dev/null | \
|
|
sort | uniq | wc -l`" = 1 || return 1
|
|
|
|
# Search 'default=PARTITION'
|
|
local part=`sed -n 's,^default=,,p' "$1" | sed 's,\\\\,/,g;s,[ \t\r]*$,,;1q'`
|
|
test -n "$part" || return 1
|
|
|
|
# Search 'PARTITION="NAME" ...'
|
|
local name=`sed -n 's,\\\\,/,g;s,^'"$part"'="\([^"]*\)".*$,\1,p' "$1" | sed 1q`
|
|
test -n "$name" || return 1
|
|
|
|
echo "$name"
|
|
}
|
|
|
|
|
|
for dir in $dirlist ; do
|
|
|
|
# Check for Vista bootmgr.
|
|
if [ -f "$dir"/bootmgr -a -f "$dir"/boot/bcd ] ; then
|
|
OS="Windows Vista bootmgr"
|
|
|
|
# Check for NTLDR.
|
|
elif [ -f "$dir"/ntldr -a -f "$dir"/ntdetect.com -a -f "$dir"/boot.ini ] ; then
|
|
OS=`get_os_name_from_boot_ini "$dir"/boot.ini` || OS="Windows NT/2000/XP loader"
|
|
|
|
else
|
|
continue
|
|
fi
|
|
|
|
# Get boot /dev/ice.
|
|
dev=`${grub_probe} -t device "$dir" 2>/dev/null` || continue
|
|
|
|
echo "Found $OS on $dir ($dev)" >&2
|
|
cat << EOF
|
|
menuentry "$OS" {
|
|
EOF
|
|
|
|
prepare_grub_to_access_device "$dev" | sed 's,^,\t,'
|
|
|
|
cat << EOF
|
|
chainloader +1
|
|
}
|
|
EOF
|
|
done
|
|
|