]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2007-05-13 Robert Millan <rmh@aybabtu.com>
authorrobertmh <robertmh@localhost>
Sun, 13 May 2007 19:28:54 +0000 (19:28 +0000)
committerrobertmh <robertmh@localhost>
Sun, 13 May 2007 19:28:54 +0000 (19:28 +0000)
* util/update-grub.in: Fix a few assumptions about the devices holding
/, /boot and /boot/grub being the same.
* util/grub.d/00_header.in: Likewise.
* util/grub.d/10_hurd.in: Likewise.
* util/grub.d/10_linux.in: Likewise.

* util/grub.d/10_linux.in: Implement Linux image sorting with arbitrary
patterns.  Use that to define the `.old' suffix as older than `'.

* util/grub.d/00_header.in: Set default gfxmode to `800x600x16'.

* util/update-grub.in: Add a reference to ${sysconfdir}/default/grub in
the grub.cfg header message.

ChangeLog
util/grub.d/00_header.in
util/grub.d/10_hurd.in
util/grub.d/10_linux.in
util/update-grub.in

index 7b5cef72d69efb95b61d12270fab8f7db31980e7..950404f46d44a3a3847a4e4c637b79b16f296832 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2007-05-13  Robert Millan  <rmh@aybabtu.com>
+
+       * util/update-grub.in: Fix a few assumptions about the devices holding
+       /, /boot and /boot/grub being the same.
+       * util/grub.d/00_header.in: Likewise.
+       * util/grub.d/10_hurd.in: Likewise.
+       * util/grub.d/10_linux.in: Likewise.
+
+       * util/grub.d/10_linux.in: Implement Linux image sorting with arbitrary
+       patterns.  Use that to define the `.old' suffix as older than `'.
+
+       * util/grub.d/00_header.in: Set default gfxmode to `800x600x16'.
+
+       * util/update-grub.in: Add a reference to ${sysconfdir}/default/grub in
+       the grub.cfg header message.
+
 2007-05-11  Robert Millan  <rmh@aybabtu.com>
 
        * util/update-grub.in: Create device.map if it doesn't already exist,
index 2d1cc8b4d449f965dbe5f7cfdce6cc63d8ec86e6..e7e9190a5be9f0983d5a6527efbba4a5dec2332b 100644 (file)
@@ -29,8 +29,9 @@ EOF
 
 if test -e /boot/grub/unifont.pff ; then
   cat << EOF
-font /boot/grub/unifont.pff
-set gfxmode=640x480x32
+
+font ${GRUB_DRIVE_BOOT_GRUB}/unifont.pff
+set gfxmode=800x600x16
 insmod gfxterm
 insmod vbe
 terminal gfxterm
index 08aadf3046318a7e6edd022e41499e949068b2a7..620798d3ceb8522db9f4052859297d201ed223c2 100644 (file)
@@ -23,11 +23,19 @@ else
   OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
 fi
 
+at_least_one=false
+all_of_them=true
+
 # FIXME: add l4 here?
 kernel=
 for i in /boot/gnumach.gz /boot/gnumach ; do
   if test -e $i ; then
-    kernel=$i
+    basename=`basename $i`
+    dirname=`dirname $i`
+    grub_dirname=`echo ${dirname} | sed -e "s%^/boot%${GRUB_DRIVE_BOOT}%g"`
+    echo "Found GNU Mach: $i" >&2
+    kernel=${grub_dirname}/${basename}
+    at_least_one=true
   fi
 done
 
@@ -37,10 +45,8 @@ case "${GRUB_FS}" in
   *)   hurd_fs="${GRUB_FS}fs" ;;
 esac
 
-at_least_one=false
-all_of_them=true
-for i in "${kernel}" /hurd/${hurd_fs}.static /hurd/exec ; do
-  if test -e "$i" ; then
+for i in /hurd/${hurd_fs}.static /hurd/exec ; do
+  if test -e "$i" ; then 
     echo "Found Hurd module: $i" >&2
     at_least_one=true
   else
index 1d7d4157552573a3b683a6a1217e081cf45e0d1d..2442297e080cc7ca020381ffa9ae39b901e217b0 100644 (file)
@@ -23,22 +23,76 @@ else
   OS="${GRUB_DISTRIBUTOR} GNU/Linux"
 fi
 
+test_numeric ()
+{
+  local a=$1
+  local cmp=$2
+  local b=$3
+  if [ "$a" = "$b" ] ; then
+    case $cmp in
+      ge|eq|le) return 0 ;;
+      gt|lt) return 1 ;;
+    esac
+  fi
+  if [ "$cmp" = "lt" ] ; then
+    c=$a
+    a=$b
+    b=$c
+  fi
+  if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then
+    return 0
+  else
+    return 1
+  fi
+}
 
-for linux in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
-  if test -e ${linux} ; then : ; else
-    continue
+test_gt ()
+{
+  local a=$1
+  local b=$2
+  local cmp=gt
+  if [ "x$b" = "x" ] ; then
+    return 0
   fi
-  echo "Found linux image:  $linux" >&2
-  version=`echo $linux | sed -e "s,.*/[^0-9]*-,,g"`
-  basedir=`echo $linux | sed -e "s,/[^/]*$,,g"`
+  case $a:$b in
+    *.old:*.old) ;;
+    *.old:*) a=`echo -n $a | sed -e s/\.old$//g` ; cmp=gt ;;
+    *:*.old) b=`echo -n $b | sed -e s/\.old$//g` ; cmp=ge ;;
+  esac
+  test_numeric $a $cmp $b
+  return $?
+}
+
+find_latest ()
+{
+  local a=""
+  for i in $@ ; do
+    if test_gt "$i" "$a" ; then
+      a="$i"
+    fi
+  done
+  echo "$a"
+}
+
+list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
+        if test -e $i ; then echo -n "$i " ; fi
+      done`
+
+while [ "x$list" != "x" ] ; do
+  linux=`find_latest $list`
+  echo "Found linux image: $linux" >&2
+  basename=`basename $linux`
+  dirname=`dirname $linux`
+  grub_dirname=`echo ${dirname} | sed -e "s%^/boot%${GRUB_DRIVE_BOOT}%g"`
+  version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
   cat << EOF
 menuentry "${OS}, linux ${version}" {
-       linux   ${linux} root=${GRUB_DEVICE} ro ${GRUB_CMDLINE_LINUX}
+       linux   ${grub_dirname}/${basename} root=${GRUB_DEVICE} ro ${GRUB_CMDLINE_LINUX}
 EOF
-  if test -e ${basedir}/initrd.img-${version} ; then
-    echo "Found initrd image: ${basedir}/initrd.img-${version}" >&2
+  if test -e ${dirname}/initrd.img-${version} ; then
+    echo "Found initrd image: ${dirname}/initrd.img-${version}" >&2
     cat << EOF
-       initrd  ${basedir}/initrd.img-${version}
+       initrd  ${grub_dirname}/initrd.img-${version}
 EOF
   fi
   cat << EOF
@@ -46,14 +100,15 @@ EOF
 EOF
   cat << EOF
 menuentry "${OS}, linux ${version} (single-user mode)" {
-       linux   ${linux} root=${GRUB_DEVICE} ro single ${GRUB_CMDLINE_LINUX}
+       linux   ${grub_dirname}/${basename} root=${GRUB_DEVICE} ro single ${GRUB_CMDLINE_LINUX}
 EOF
-  if test -e ${basedir}/initrd.img-${version} ; then
+  if test -e ${dirname}/initrd.img-${version} ; then
     cat << EOF
-       initrd  ${basedir}/initrd.img-${version}
+       initrd  ${grub_dirname}/initrd.img-${version}
 EOF
   fi
   cat << EOF
 }
 EOF
+  list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
 done
index 7a8fe77368fa512ba2b6df7796acef96e9a9e30d..293b50067e55b01ceba1da7fb7103707b4e16b43 100644 (file)
@@ -65,13 +65,44 @@ if test -e ${grub_prefix}/device.map ; then : ; else
   grub-mkdevicemap
 fi
 
-exec > ${grub_cfg}.new
-chmod 444 ${grub_cfg}.new
+# Device containing our userland.  Typicaly used for root= parameter.
+GRUB_DEVICE="`grub-probe --target=device /`"
+
+# Filesystem for the device containing our userland.  Used for stuff like
+# choosing Hurd filesystem module.
+GRUB_FS="`grub-probe --target=fs /`"
+
+# GRUB path to /
+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 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
 
 if test -f ${sysconfdir}/default/grub ; then
   . ${sysconfdir}/default/grub
 fi
 
+# These are defined in this script, export them here so that user can
+# override them.
+export GRUB_DEVICE GRUB_FS GRUB_DRIVE GRUB_DRIVE_BOOT GRUB_DRIVE_BOOT_GRUB
+
+# These are optional, user-defined variables.
+export GRUB_DEFAULT GRUB_TIMEOUT GRUB_DISTRIBUTOR
+
+exec > ${grub_cfg}.new
+chmod 444 ${grub_cfg}.new
+
 echo "Updating ${grub_cfg} ..." >&2
 
 cat << EOF
@@ -79,13 +110,11 @@ cat << EOF
 # DO NOT EDIT THIS FILE
 #
 # It is automaticaly generated by $0 using templates from ${update_grub_dir}
+# It is automaticaly generated by $0 using templates from ${update_grub_dir}
+# and settings from ${sysconfdir}/default/grub
 #
 EOF
 
-export GRUB_DEVICE="`grub-probe --target=device ${grub_prefix}`"
-export GRUB_DRIVE="`grub-probe --target=drive ${grub_prefix}`"
-export GRUB_FS="`grub-probe --target=fs ${grub_prefix}`"
-
 for i in ${update_grub_dir}/* ; do
   case $i in
     # emacsen backup files. FIXME: support other editors