]> git.proxmox.com Git - grub2.git/commitdiff
2007-05-20 Robert Millan <rmh@aybabtu.com>
authorrobertmh <robertmh@localhost>
Sun, 20 May 2007 09:10:06 +0000 (09:10 +0000)
committerrobertmh <robertmh@localhost>
Sun, 20 May 2007 09:10:06 +0000 (09:10 +0000)
* util/update-grub_lib.in: New file.
* DISTLIST: Add update-grub_lib.in.
* conf/common.rmk: Generate update-grub_lib and install it in
$(lib_DATA).
* Makefile.in: Add install routine for $(lib_DATA).

* util/grub.d/00_header.in: Use convert_system_path_to_grub_path()
function provided by update-grub_lib to support arbitrary paths of
unifont.pff.
* util/update-grub.in: Use convert_system_path_to_grub_path() to
initialize GRUB_DRIVE_BOOT and GRUB_DRIVE_BOOT_GRUB variables.

ChangeLog
DISTLIST
Makefile.in
conf/common.rmk
util/grub.d/00_header.in
util/update-grub.in
util/update-grub_lib.in [new file with mode: 0644]

index 700ad949a9cc956b600350192f6d35230c58529f..8c6064cf8ced64563106054629ccc028bf9adaad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2007-05-20  Robert Millan  <rmh@aybabtu.com>
+
+       * util/update-grub_lib.in: New file.
+       * DISTLIST: Add update-grub_lib.in.
+       * conf/common.rmk: Generate update-grub_lib and install it in
+       $(lib_DATA).
+       * Makefile.in: Add install routine for $(lib_DATA).
+
+       * util/grub.d/00_header.in: Use convert_system_path_to_grub_path()
+       function provided by update-grub_lib to support arbitrary paths of
+       unifont.pff.
+       * util/update-grub.in: Use convert_system_path_to_grub_path() to
+       initialize GRUB_DRIVE_BOOT and GRUB_DRIVE_BOOT_GRUB variables.
+
 2007-05-19  Robert Millan  <rmh@aybabtu.com>
 
        * commands/i386/cpuid.c: New module.
index 825b6ece9e5e0c20237fb78af090faa8744a8a5f..ed79733d7488f50c7825aab90ac4a11653c10d48 100644 (file)
--- a/DISTLIST
+++ b/DISTLIST
@@ -264,6 +264,7 @@ util/raid.c
 util/resolve.c
 util/unifont2pff.rb
 util/update-grub.in
+util/update-grub_lib.in
 util/grub.d/00_header.in
 util/grub.d/10_hurd.in
 util/grub.d/10_linux.in
index b2bb0d429b128b5d6ed43ecf68964c5c962fd671..34c94b05ccf40baf8237024819983c04e8823a76 100644 (file)
@@ -86,7 +86,7 @@ RMKFILES = $(addprefix conf/,common.rmk i386-pc.rmk powerpc-ieee1275.rmk \
 MKFILES = $(patsubst %.rmk,%.mk,$(RMKFILES))
 
 DATA = $(pkgdata_IMAGES) $(pkgdata_MODULES) $(pkgdata_PROGRAMS) \
-       $(pkgdata_DATA)
+       $(pkgdata_DATA) $(lib_DATA)
 PROGRAMS = $(bin_UTILITIES) $(sbin_UTILITIES)
 SCRIPTS = $(sbin_SCRIPTS) $(update-grub_SCRIPTS)
 
@@ -165,6 +165,13 @@ install-local: all
          dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
          $(INSTALL_DATA) $$dir$$file $(DESTDIR)$(sysconfdir)/grub.d/$$dest; \
        done
+       $(mkinstalldirs) $(DESTDIR)$(libdir)/grub
+       @list='$(lib_DATA)'; \
+       for file in $$list; do \
+         if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
+         dest="`echo $$file | sed 's,.*/,,'`"; \
+         $(INSTALL_DATA) $$dir$$file $(DESTDIR)$(libdir)/grub/$$dest; \
+       done
 
 install-strip:
        $(MAKE) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" install
index 2a7d64018b0daefa22d2df72592b11b52e58a898..e7cafa49c06fde67aa0a8a106b2e677b81b77d30 100644 (file)
@@ -25,6 +25,12 @@ update-grub: util/update-grub.in config.status
 sbin_SCRIPTS += update-grub
 CLEANFILES += update-grub
 
+update-grub_lib: util/update-grub_lib.in config.status
+       ./config.status --file=$@:$<
+       chmod +x $@
+lib_DATA += update-grub_lib
+CLEANFILES += update-grub_lib
+
 00_header: util/grub.d/00_header.in config.status
        ./config.status --file=$@:$<
        chmod +x $@
index 7c9d3963ea23e5b52fbd867921c9be1b9ab4dd12..d4bc6d8eac979a96317dc9bae2ee93b6b71e2f17 100644 (file)
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St - Suite 330, Boston, MA 02110, USA.
 
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+
+# for convert_system_path_to_grub_path()
+. ${libdir}/grub/update-grub_lib
 
 if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
 if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
@@ -27,13 +33,19 @@ set timeout=${GRUB_TIMEOUT}
 set root=${GRUB_DRIVE}
 EOF
 
-if test -e /boot/grub/unifont.pff ; then
-  cat << EOF
+# Prefer system path for space reasons (/boot/grub might be a very small
+# partition in case of OpenFirmware, etc).
+for i in /usr/share/grub/unifont.pff /boot/grub/unifont.pff ; do
+  if test -e $i ; then
+    grub_path=`convert_system_path_to_grub_path $i`
+    cat << EOF
 
-font ${GRUB_DRIVE_BOOT_GRUB}/unifont.pff
+font ${grub_path}
 set gfxmode=640x480
 insmod gfxterm
 insmod vbe
 terminal gfxterm
 EOF
-fi
+    break
+  fi
+done
index 0fc643ea3c54675769f1525457e9e52aff437091..31e12b983a334b1e89143ec0e2b240203dd1812c 100644 (file)
@@ -22,6 +22,7 @@ transform="@program_transform_name@"
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 sbindir=@sbindir@
+libdir=@libdir@
 sysconfdir=@sysconfdir@
 grub_prefix=`echo /boot/grub | sed ${transform}`
 grub_cfg=${grub_prefix}/grub.cfg
@@ -30,6 +31,9 @@ update_grub_dir=${sysconfdir}/grub.d
 grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
 grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
 
+# for convert_system_path_to_grub_path()
+. ${libdir}/grub/update-grub_lib
+
 if [ "x$UID" = "x" ] ; then
   UID=`id -u`
 fi
@@ -76,18 +80,10 @@ GRUB_FS="`grub-probe --target=fs /`"
 GRUB_DRIVE="`grub-probe --target=drive /`"
 
 # GRUB path to /boot
-if [ "x`stat -c %d /`" = "x`stat -c %d /boot/`" ] ; then
-  GRUB_DRIVE_BOOT="${GRUB_DRIVE}/boot"
-else
-  GRUB_DRIVE_BOOT="`grub-probe --target=drive /boot`"
-fi
+GRUB_DRIVE_BOOT="`convert_system_path_to_grub_path /boot`"
 
 # GRUB path to /boot/grub
-if [ "x`stat -c %d /boot`" = "x`stat -c %d /boot/grub`" ] ; then
-  GRUB_DRIVE_BOOT_GRUB="${GRUB_DRIVE_BOOT}/grub"
-else
-  GRUB_DRIVE_BOOT_GRUB="`grub-probe --target=drive /boot/grub`"
-fi
+GRUB_DRIVE_BOOT_GRUB="`convert_system_path_to_grub_path /boot/grub`"
 
 if test -f ${sysconfdir}/default/grub ; then
   . ${sysconfdir}/default/grub
diff --git a/util/update-grub_lib.in b/util/update-grub_lib.in
new file mode 100644 (file)
index 0000000..6393fff
--- /dev/null
@@ -0,0 +1,49 @@
+# Helper library for update-grub
+# Copyright (C) 2007 Free Software Foundation, Inc.
+#
+# This file 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St - Suite 330, Boston, MA 02110, USA.
+
+transform="@program_transform_name@"
+
+sbindir=@sbindir@
+
+grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
+
+convert_system_path_to_grub_path ()
+{
+  dir=$1
+  dir=`readlink -f $dir`
+
+  drive=`${grub_probe} -t drive $dir`
+  if [ "x$drive" = "x" ] ; then
+    return 1
+  fi
+
+  num=`stat -c %d $dir`
+  relative_path=""
+  while : ; do
+    parent=`echo $dir | sed -e "s,/[^/]*$,,g" -e "s,^$,/,g"`
+    if [ "x`stat -c %d $parent`" = "x$num" ] ; then : ; else
+      break
+    fi
+    if [ "x$dir" = "x/" ] ; then
+      break
+    fi
+    relative_path=`echo $dir | sed -e "s,^.*/,/,g"`$relative_path
+    dir=$parent
+  done
+
+  echo ${drive}${relative_path}
+}