]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2009-10-26 Colin Watson <cjwatson@ubuntu.com>
authorcjwatson <cjwatson@localhost>
Mon, 26 Oct 2009 16:28:04 +0000 (16:28 +0000)
committercjwatson <cjwatson@localhost>
Mon, 26 Oct 2009 16:28:04 +0000 (16:28 +0000)
Improve grub-mkconfig performance when there are several menu
entries on a single filesystem.

* util/grub.d/10_linux.in (linux_entry): Cache the output of
prepare_grub_to_access_device.
* util/grub.d/10_kfreebsd.in (kfreebsd_entry): Likewise.
* util/grub.d/30_os-prober.in: Likewise.

ChangeLog
util/grub.d/10_kfreebsd.in
util/grub.d/10_linux.in
util/grub.d/30_os-prober.in

index 6ca49a0e2896dae2e5f61d156f4bba66ccbf899b..e7e01fa37ad82049f8aa36db4f9b017c86470f26 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-10-26  Colin Watson  <cjwatson@ubuntu.com>
+
+       Improve grub-mkconfig performance when there are several menu
+       entries on a single filesystem.
+
+       * util/grub.d/10_linux.in (linux_entry): Cache the output of
+       prepare_grub_to_access_device.
+       * util/grub.d/10_kfreebsd.in (kfreebsd_entry): Likewise.
+       * util/grub.d/30_os-prober.in: Likewise.
+
 2009-10-26  Robert Millan  <rmh.grub@aybabtu.com>
 
        * util/grub.d/10_freebsd.in: Remove.
index 4fb704c49aaae4bdabb7d75f7221d6d7d18194cc..cd8c186becf3e3d0471744b38bc7b3cde6f626ad 100644 (file)
@@ -31,7 +31,10 @@ kfreebsd_entry ()
   cat << EOF
 menuentry "$1" {
 EOF
-  prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
+  if [ -z "${prepare_boot_cache}" ]; then
+    prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
+  fi
+  printf '%s\n' "${prepare_boot_cache}"
   cat << EOF
        kfreebsd                        ${rel_dirname}/${basename}
 EOF
@@ -58,6 +61,7 @@ EOF
 list=`for i in /boot/kfreebsd-* /boot/kernel/kernel ; do
         if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
       done`
+prepare_boot_cache=
 
 while [ "x$list" != "x" ] ; do
   kfreebsd=`version_find_latest $list`
index 1473a42a2b1264acbaf049d56ac9a9ab3069e811..f1795584670ca0b8274adabf3a3e6f81db18e815 100644 (file)
@@ -47,7 +47,10 @@ linux_entry ()
   cat << EOF
 menuentry "$1" {
 EOF
-  prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
+  if [ -z "${prepare_boot_cache}" ]; then
+    prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
+  fi
+  printf '%s\n' "${prepare_boot_cache}"
   cat << EOF
        linux   ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro $2
 EOF
@@ -64,6 +67,7 @@ EOF
 list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
         if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
       done`
+prepare_boot_cache=
 
 while [ "x$list" != "x" ] ; do
   linux=`version_find_latest $list`
index 84e227ee71a69c5183b465cca9007c3630af06d7..6fd97fc4e0da721ab8f90244e217c3ed273b4f9a 100644 (file)
@@ -74,6 +74,7 @@ EOF
     ;;
     linux)
       LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
+      prepare_boot_cache=
 
       for LINUX in ${LINUXPROBED} ; do
         LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
@@ -90,7 +91,10 @@ EOF
         cat << EOF
 menuentry "${LLABEL} (on ${DEVICE})" {
 EOF
-       prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
+       if [ -z "${prepare_boot_cache}" ]; then
+         prepare_boot_cache="$(prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/")"
+       fi
+       printf '%s\n' "${prepare_boot_cache}"
        cat <<  EOF
        linux ${LKERNEL} ${LPARAMS}
 EOF