3 # update-grub helper script.
4 # Copyright (C) 2008 Free Software Foundation, Inc.
6 # GRUB is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # GRUB is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 exec_prefix
=@exec_prefix@
22 .
${libdir}/grub
/grub-mkconfig_lib
24 case "`uname 2>/dev/null`" in
29 # Try C: even if current system is on other partition.
30 case "$SYSTEMDRIVE" in
31 [Cc
]:) dirlist
="C:" ;;
32 [D-Zd-z
]:) dirlist
="C: $SYSTEMDRIVE" ;;
36 get_os_name_from_boot_ini
()
38 # Fail if no or more than one partition.
39 test "`sed -n 's,^\(\(multi\|scsi\)[^=]*\)=.*$,\1,p' "$1" 2>/dev/null | \
40 sort | uniq | wc -l`" = 1 ||
return 1
42 # Search 'default=PARTITION'
43 local part
=`sed -n 's,^default=,,p' "$1" | sed 's,\\\\,/,g;s,[ \t\r]*$,,;1q'`
44 test -n "$part" ||
return 1
46 # Search 'PARTITION="NAME" ...'
47 local name
=`sed -n 's,\\\\,/,g;s,^'"$part"'="\([^"]*\)".*$,\1,p' "$1" | sed 1q`
48 test -n "$name" ||
return 1
54 for dir
in $dirlist ; do
56 # Check for Vista bootmgr.
57 if [ -f "$dir"/bootmgr
-a -f "$dir"/boot
/bcd
] ; then
58 OS
="Windows Vista bootmgr"
61 elif [ -f "$dir"/ntldr
-a -f "$dir"/ntdetect.com
-a -f "$dir"/boot.ini
] ; then
62 OS
=`get_os_name_from_boot_ini "$dir"/boot.ini` || OS
="Windows NT/2000/XP loader"
69 dev
=`${grub_probe} -t device "$dir" 2>/dev/null` ||
continue
71 echo "Found $OS on $dir ($dev)" >&2
76 prepare_grub_to_access_device
"$dev" |
sed 's,^,\t,'