[1787] 2008-08-06 Christian Franke <[email protected]>

Christian Franke <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 1787
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=1787
Author:   chrfranke
Date:     2008-08-06 18:45:51 +0000 (Wed, 06 Aug 2008)

Log Message:
-----------
2008-08-06  Christian Franke  <[email protected]>

	* conf/common.rmk: Build and install `10_windows'.
	* util/grub.d/10_windows.in: New script.

Modified Paths:
--------------
    trunk/grub2/.cvsignore
    trunk/grub2/ChangeLog
    trunk/grub2/conf/common.mk
    trunk/grub2/conf/common.rmk

Added Paths:
-----------
    trunk/grub2/util/grub.d/10_windows.in

Modified: trunk/grub2/.cvsignore
===================================================================
--- trunk/grub2/.cvsignore	2008-08-06 13:42:02 UTC (rev 1786)
+++ trunk/grub2/.cvsignore	2008-08-06 18:45:51 UTC (rev 1787)
@@ -7,6 +7,7 @@
 00_header
 10_hurd
 10_linux
+10_windows
 30_os-prober
 40_custom
 Makefile

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2008-08-06 13:42:02 UTC (rev 1786)
+++ trunk/grub2/ChangeLog	2008-08-06 18:45:51 UTC (rev 1787)
@@ -1,3 +1,8 @@
+2008-08-06  Christian Franke  <[email protected]>
+
+	* conf/common.rmk: Build and install `10_windows'.
+	* util/grub.d/10_windows.in: New script.
+
 2008-08-06  Pavel Roskin  <[email protected]>
 
 	* kern/i386/pit.c: Include `<grub/i386/pit.h>'.

Modified: trunk/grub2/conf/common.mk
===================================================================
--- trunk/grub2/conf/common.mk	2008-08-06 13:42:02 UTC (rev 1786)
+++ trunk/grub2/conf/common.mk	2008-08-06 18:45:51 UTC (rev 1787)
@@ -493,7 +493,7 @@
 %: util/grub.d/%.in config.status
 	./config.status --file=$@:$<
 	chmod +x $@
-update-grub_SCRIPTS = 00_header 10_linux 10_hurd 30_os-prober 40_custom
+update-grub_SCRIPTS = 00_header 10_linux 10_hurd 10_windows 30_os-prober 40_custom
 CLEANFILES += $(update-grub_SCRIPTS)
 
 update-grub_DATA += util/grub.d/README

Modified: trunk/grub2/conf/common.rmk
===================================================================
--- trunk/grub2/conf/common.rmk	2008-08-06 13:42:02 UTC (rev 1786)
+++ trunk/grub2/conf/common.rmk	2008-08-06 18:45:51 UTC (rev 1787)
@@ -120,7 +120,7 @@
 %: util/grub.d/%.in config.status
 	./config.status --file=$@:$<
 	chmod +x $@
-update-grub_SCRIPTS = 00_header 10_linux 10_hurd 30_os-prober 40_custom
+update-grub_SCRIPTS = 00_header 10_linux 10_hurd 10_windows 30_os-prober 40_custom
 CLEANFILES += $(update-grub_SCRIPTS)
 
 update-grub_DATA += util/grub.d/README

Added: trunk/grub2/util/grub.d/10_windows.in
===================================================================
--- trunk/grub2/util/grub.d/10_windows.in	                        (rev 0)
+++ trunk/grub2/util/grub.d/10_windows.in	2008-08-06 18:45:51 UTC (rev 1787)
@@ -0,0 +1,83 @@
+#! /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/update-grub_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
+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.