Teach grub-mkconfig to load fs modules for NetBSD.
This commit is contained in:
parent
a21e5672fd
commit
1f060f399a
2 changed files with 64 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
2011-01-09 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||
|
||||
* util/grub.d/10_netbsd.in (netbsd_load_fs_module): New function.
|
||||
(netbsd_entry): Use netbsd_load_fs_module() to load filesystem module.
|
||||
|
||||
2011-01-09 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||
|
||||
* util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Handle
|
||||
|
|
|
@ -27,11 +27,65 @@ export TEXTDOMAIN=@PACKAGE@
|
|||
export TEXTDOMAINDIR=@localedir@
|
||||
|
||||
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
|
||||
OS=NetBSD
|
||||
OS="NetBSD"
|
||||
else
|
||||
OS="${GRUB_DISTRIBUTOR} NetBSD"
|
||||
fi
|
||||
|
||||
netbsd_load_fs_module ()
|
||||
{
|
||||
loader="$1" # "knetbsd" or "multiboot"
|
||||
kernel="$2" # absolute path to the kernel file
|
||||
|
||||
case $(zcat -f "${kernel}" | file -bL - | cut -d , -f 2 | tr -d ' ') in
|
||||
Intel80386)
|
||||
karch="i386"
|
||||
;;
|
||||
x86-64)
|
||||
karch="amd64"
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case $(${grub_probe} --target=fs -d ${GRUB_DEVICE}) in
|
||||
ext2)
|
||||
kmod="ext2fs"
|
||||
;;
|
||||
fat)
|
||||
kmod="msdosfs"
|
||||
;;
|
||||
ntfs)
|
||||
kmod="ntfs"
|
||||
;;
|
||||
ufs*)
|
||||
kmod="ffs"
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }')
|
||||
kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod"
|
||||
|
||||
if test -z "$karch" -o -z "$kversion" -o ! -f "${kmodule}"; then
|
||||
return
|
||||
fi
|
||||
|
||||
kmodule_rel=$(make_system_path_relative_to_its_root "$kmodule") || return
|
||||
prepare_grub_to_access_device $(${grub_probe} -t device "${kmodule}") | sed -e 's,^, ,'
|
||||
case "${loader}" in
|
||||
knetbsd)
|
||||
printf "\tknetbsd_module_elf %s\n" "${kmodule_rel}"
|
||||
;;
|
||||
multiboot)
|
||||
printf "\tmodule %s\n" "${kmodule_rel}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
netbsd_entry ()
|
||||
{
|
||||
loader="$1" # "knetbsd" or "multiboot"
|
||||
|
@ -59,6 +113,9 @@ netbsd_entry ()
|
|||
"${kernel}" "${kernel}" "${kroot_device}" "${GRUB_CMDLINE_NETBSD} ${args}"
|
||||
;;
|
||||
esac
|
||||
|
||||
netbsd_load_fs_module "${loader}" "${kernel}"
|
||||
|
||||
printf "}\n"
|
||||
}
|
||||
|
||||
|
@ -72,8 +129,7 @@ for k in $(ls -t /netbsd*) ; do
|
|||
if ! grub_file_is_not_garbage "$k" ; then
|
||||
continue
|
||||
fi
|
||||
if ! ((file -bL "$k" | grep -q "${pattern}") ||
|
||||
(zcat "$k" | file -bL - | grep -q "${pattern}")) 2>/dev/null ; then
|
||||
if ! (zcat -f "$k" | file -bL - | grep -q "${pattern}") 2>/dev/null ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue