2010-06-29 15:20:49 +00:00
|
|
|
#! /bin/sh
|
|
|
|
set -e
|
2008-08-06 18:45:51 +00:00
|
|
|
|
2009-08-08 17:59:19 +00:00
|
|
|
# grub-mkconfig helper script.
|
2010-05-18 19:58:49 +00:00
|
|
|
# Copyright (C) 2008,2009,2010 Free Software Foundation, Inc.
|
2008-08-06 18:45:51 +00:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
2012-01-24 12:17:36 +00:00
|
|
|
prefix="@prefix@"
|
|
|
|
exec_prefix="@exec_prefix@"
|
|
|
|
datarootdir="@datarootdir@"
|
|
|
|
|
2012-02-29 23:40:02 +00:00
|
|
|
export TEXTDOMAIN=@PACKAGE@
|
|
|
|
export TEXTDOMAINDIR="@localedir@"
|
|
|
|
|
2015-04-29 16:18:54 +00:00
|
|
|
. "$pkgdatadir/grub-mkconfig_lib"
|
2008-08-06 18:45:51 +00:00
|
|
|
|
|
|
|
case "`uname 2>/dev/null`" in
|
|
|
|
CYGWIN*) ;;
|
|
|
|
*) exit 0 ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Try C: even if current system is on other partition.
|
|
|
|
case "$SYSTEMDRIVE" in
|
2010-05-18 19:58:49 +00:00
|
|
|
[Cc]:) drives="C:" ;;
|
|
|
|
[D-Zd-z]:) drives="C: $SYSTEMDRIVE" ;;
|
2008-08-06 18:45:51 +00:00
|
|
|
*) 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'
|
2012-09-18 11:04:06 +00:00
|
|
|
get_os_name_from_boot_ini_part=`sed -n 's,^default=,,p' "$1" | sed 's,\\\\,/,g;s,[ $grub_tab\r]*$,,;1q'`
|
2011-11-10 07:46:09 +00:00
|
|
|
test -n "$get_os_name_from_boot_ini_part" || return 1
|
2008-08-06 18:45:51 +00:00
|
|
|
|
|
|
|
# Search 'PARTITION="NAME" ...'
|
2011-11-10 07:46:09 +00:00
|
|
|
get_os_name_from_boot_ini_name=`sed -n 's,\\\\,/,g;s,^'"$get_os_name_from_boot_ini_part"'="\([^"]*\)".*$,\1,p' "$1" | sed 1q`
|
|
|
|
test -n "$get_os_name_from_boot_ini_name" || return 1
|
2008-08-06 18:45:51 +00:00
|
|
|
|
2011-11-10 07:46:09 +00:00
|
|
|
echo "$get_os_name_from_boot_ini_name"
|
2008-08-06 18:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-18 19:58:49 +00:00
|
|
|
for drv in $drives ; do
|
|
|
|
|
|
|
|
# Convert to Cygwin path.
|
|
|
|
dir=`cygpath "$drv"`
|
|
|
|
test -n "$dir" || continue
|
|
|
|
|
|
|
|
needmap=
|
2012-03-04 13:55:13 +00:00
|
|
|
osid=
|
2008-08-06 18:45:51 +00:00
|
|
|
|
|
|
|
# Check for Vista bootmgr.
|
2014-01-17 15:24:50 +00:00
|
|
|
if [ -f "$dir"/bootmgr ] && [ -f "$dir"/boot/bcd ] ; then
|
2012-03-04 21:18:33 +00:00
|
|
|
OS="$(gettext "Windows Vista/7 (loader)")"
|
2012-03-04 13:55:13 +00:00
|
|
|
osid=bootmgr
|
2008-08-06 18:45:51 +00:00
|
|
|
# Check for NTLDR.
|
2014-01-17 15:24:50 +00:00
|
|
|
elif [ -f "$dir"/ntldr ] && [ -f "$dir"/ntdetect.com ] && [ -f "$dir"/boot.ini ] ; then
|
2012-03-04 21:18:33 +00:00
|
|
|
OS=`get_os_name_from_boot_ini "$dir"/boot.ini` || OS="$(gettext "Windows NT/2000/XP (loader)")"
|
2012-03-04 13:55:13 +00:00
|
|
|
osid=ntldr
|
2010-05-18 19:58:49 +00:00
|
|
|
needmap=t
|
2008-08-06 18:45:51 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2012-02-08 18:26:01 +00:00
|
|
|
# Get boot device.
|
2008-08-06 18:45:51 +00:00
|
|
|
dev=`${grub_probe} -t device "$dir" 2>/dev/null` || continue
|
|
|
|
|
2012-02-03 10:42:22 +00:00
|
|
|
gettext_printf "Found %s on %s (%s)\n" "$OS" "$drv" "$dev" >&2
|
2008-08-06 18:45:51 +00:00
|
|
|
cat << EOF
|
2012-03-04 21:18:33 +00:00
|
|
|
menuentry '$(echo "$OS" | grub_quote)' \$menuentry_id_option '$osid-$(grub_get_device_id "${dev}")' {
|
2008-08-06 18:45:51 +00:00
|
|
|
EOF
|
|
|
|
|
2012-09-18 11:04:06 +00:00
|
|
|
save_default_entry | sed -e 's,^,$grub_tab,'
|
|
|
|
prepare_grub_to_access_device "$dev" | sed 's,^,$grub_tab,'
|
2010-05-18 19:58:49 +00:00
|
|
|
test -z "$needmap" || cat <<EOF
|
|
|
|
drivemap -s (hd0) \$root
|
|
|
|
EOF
|
2008-08-06 18:45:51 +00:00
|
|
|
cat << EOF
|
|
|
|
chainloader +1
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
done
|
|
|
|
|