]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2010-08-20 Robert Millan <rmh@gnu.org>
authorRobert Millan <rmh@aybabtu.com>
Fri, 20 Aug 2010 14:36:07 +0000 (16:36 +0200)
committerRobert Millan <rmh@aybabtu.com>
Fri, 20 Aug 2010 14:36:07 +0000 (16:36 +0200)
Make kFreeBSD code more generic to support ext2fs as root, ufs as
a separate module and maybe other interesting combinations.

* util/grub.d/10_kfreebsd.in (load_kfreebsd_module): New function.
(kfreebsd_entry): Use load_kfreebsd_module() to load modules.
(kfreebsd_entry): Add generic filesystem module load routine.
Map GRUB `ext2' to kFreeBSD `ext2fs'.

ChangeLog
util/grub.d/10_kfreebsd.in

index 7d82e08fb81efce030365a10bfe2a0096b4a5678..fa21788759ea019206106685dd7b226e522de677 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-08-20  Robert Millan  <rmh@gnu.org>
+
+       Make kFreeBSD code more generic to support ext2fs as root, ufs as
+       a separate module and maybe other interesting combinations.
+
+       * util/grub.d/10_kfreebsd.in (load_kfreebsd_module): New function.
+       (kfreebsd_entry): Use load_kfreebsd_module() to load modules.
+       (kfreebsd_entry): Add generic filesystem module load routine.
+       Map GRUB `ext2' to kFreeBSD `ext2fs'.
+
 2010-08-20  Colin Watson  <cjwatson@ubuntu.com>
 
        * commands/i386/pc/sendkey.c (keysym_table): Rename "numlock" to
index 3a42de529dfeae8f113836afda3a5c7a1a0e9129..40ac240c74f66a8c5ced51b142277d132c952139 100644 (file)
@@ -39,6 +39,31 @@ case "${GRUB_DISTRIBUTOR}" in
   ;;
 esac
 
+load_kfreebsd_module ()
+{
+  mod="$1"
+  allow_fail="$2"
+
+  if ! test -e "${module_dir}/${mod}.ko" ; then
+    if [ "${allow_fail}" = "true" ] ; then
+      # Return silently
+      return
+    else
+      # Print an error and fail.
+      ls "${module_dir}/${mod}.ko" > /dev/null
+    fi
+  fi
+
+  if [ -z "${prepare_module_dir_cache}" ]; then
+    prepare_module_dir_cache="$(prepare_grub_to_access_device $(grub-probe -t device "${module_dir}") | sed -e "s/^/\t/")"
+  fi
+
+  printf '%s\n' "${prepare_module_dir_cache}"
+  cat << EOF
+       kfreebsd_module_elf     ${module_dir_rel}/${mod}.ko
+EOF
+}
+
 kfreebsd_entry ()
 {
   os="$1"
@@ -51,9 +76,6 @@ kfreebsd_entry ()
   if [ -z "${prepare_boot_cache}" ]; then
     prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
   fi
-  if [ -z "${prepare_module_dir_cache}" ]; then
-    prepare_module_dir_cache="$(prepare_grub_to_access_device $(grub-probe -t device "${module_dir}") | sed -e "s/^/\t/")"
-  fi
 
   printf '%s\n' "${prepare_boot_cache}"
   cat << EOF
@@ -67,26 +89,13 @@ EOF
 EOF
   fi
 
-  if test -e "${module_dir}/acpi.ko" ; then
-    printf '%s\n' "${prepare_module_dir_cache}"
-    cat << EOF
-       kfreebsd_module_elf     ${module_dir_rel}/acpi.ko
-EOF
-  fi
+  load_kfreebsd_module acpi true
 
   case "${kfreebsd_fs}" in
     zfs)
-      for i in "${module_dir}/opensolaris.ko" "${module_dir}/zfs.ko" \
-          "${dirname}/zfs/zpool.cache" ; do
-        ls "$i" > /dev/null
-      done
-
-      printf '%s\n' "${prepare_module_dir_cache}"
-      cat << EOF
-       kfreebsd_module_elf     ${module_dir_rel}/opensolaris.ko
-       kfreebsd_module_elf     ${module_dir_rel}/zfs.ko
-EOF
+      load_kfreebsd_module opensolaris false
 
+      ls "${dirname}/zfs/zpool.cache" > /dev/null
       printf '%s\n' "${prepare_boot_cache}"
   cat << EOF
        kfreebsd_module         ${rel_dirname}/zfs/zpool.cache type=/boot/zfs/zpool.cache
@@ -94,6 +103,8 @@ EOF
     ;;
   esac
 
+  load_kfreebsd_module ${kfreebsd_fs} false
+
   cat << EOF
        set kFreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${kfreebsd_device}
        set kFreeBSD.vfs.root.mountfrom.options=rw
@@ -121,8 +132,9 @@ while [ "x$list" != "x" ] ; do
   fi
 
   case ${GRUB_FS} in
-    ufs1 | ufs2)        kfreebsd_fs=ufs ;;
-    *)                  kfreebsd_fs=${GRUB_FS} ;;
+    ufs1 | ufs2)       kfreebsd_fs=ufs ;;
+    ext2)              kfreebsd_fs=ext2fs ;;
+    *)                 kfreebsd_fs=${GRUB_FS} ;;
   esac
 
   case ${GRUB_FS} in