Revert grub-file usage in grub-mkconfig.

This commit is contained in:
Vladimir Serbinenko 2013-12-24 17:47:27 +01:00
parent e5fa26e573
commit faf4a65e1e
12 changed files with 97 additions and 181 deletions

View file

@ -1,3 +1,7 @@
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Revert grub-file usage in grub-mkconfig.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com> 2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Make newly-created files other than grub.cfg world-readable. Make newly-created files other than grub.cfg world-readable.

View file

@ -439,42 +439,49 @@ script = {
name = '10_hurd'; name = '10_hurd';
common = util/grub.d/10_hurd.in; common = util/grub.d/10_hurd.in;
installdir = grubconf; installdir = grubconf;
condition = COND_HOST_HURD;
}; };
script = { script = {
name = '10_kfreebsd'; name = '10_kfreebsd';
common = util/grub.d/10_kfreebsd.in; common = util/grub.d/10_kfreebsd.in;
installdir = grubconf; installdir = grubconf;
condition = COND_HOST_KFREEBSD;
}; };
script = { script = {
name = '10_illumos'; name = '10_illumos';
common = util/grub.d/10_illumos.in; common = util/grub.d/10_illumos.in;
installdir = grubconf; installdir = grubconf;
condition = COND_HOST_ILLUMOS;
}; };
script = { script = {
name = '10_netbsd'; name = '10_netbsd';
common = util/grub.d/10_netbsd.in; common = util/grub.d/10_netbsd.in;
installdir = grubconf; installdir = grubconf;
condition = COND_HOST_NETBSD;
}; };
script = { script = {
name = '10_linux'; name = '10_linux';
common = util/grub.d/10_linux.in; common = util/grub.d/10_linux.in;
installdir = grubconf; installdir = grubconf;
condition = COND_HOST_LINUX;
}; };
script = { script = {
name = '10_xnu'; name = '10_xnu';
common = util/grub.d/10_xnu.in; common = util/grub.d/10_xnu.in;
installdir = grubconf; installdir = grubconf;
condition = COND_HOST_XNU;
}; };
script = { script = {
name = '20_linux_xen'; name = '20_linux_xen';
common = util/grub.d/20_linux_xen.in; common = util/grub.d/20_linux_xen.in;
installdir = grubconf; installdir = grubconf;
condition = COND_HOST_LINUX;
}; };
script = { script = {

View file

@ -1666,7 +1666,13 @@ AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ]) AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi]) AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows]) AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x]) AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes]) AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])

View file

@ -55,7 +55,6 @@ usage () {
gettext "Generate a grub config file"; echo gettext "Generate a grub config file"; echo
echo echo
print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")" print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")"
print_option_help "-r, --root-directory=$(gettext DIR)" "$(gettext "use DIR as root directory [default=/]")"
print_option_help "-h, --help" "$(gettext "print this message and exit")" print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")" print_option_help "-v, --version" "$(gettext "print the version information and exit")"
echo echo
@ -73,8 +72,6 @@ argument () {
echo $1 echo $1
} }
GRUB_ROOT=
# Check the arguments. # Check the arguments.
while test $# -gt 0 while test $# -gt 0
do do
@ -93,11 +90,6 @@ do
--output=*) --output=*)
grub_cfg=`echo "$option" | sed 's/--output=//'` grub_cfg=`echo "$option" | sed 's/--output=//'`
;; ;;
-r | --root-directory)
GRUB_ROOT=`argument $option "$@"`; shift;;
--root-directory=*)
GRUB_ROOT=`echo "$option" | sed 's/--output=//'`
;;
-*) -*)
gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2 gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
usage usage
@ -137,19 +129,19 @@ else
fi fi
# Device containing our userland. Typically used for root= parameter. # Device containing our userland. Typically used for root= parameter.
GRUB_DEVICE="`${grub_probe} --target=device "$GRUB_ROOT"/`" GRUB_DEVICE="`${grub_probe} --target=device /`"
GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
# Device containing our /boot partition. Usually the same as GRUB_DEVICE. # Device containing our /boot partition. Usually the same as GRUB_DEVICE.
GRUB_DEVICE_BOOT="`${grub_probe} --target=device "$GRUB_ROOT"/boot`" GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true GRUB_DEVICE_BOOT_UUID="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
# Filesystem for the device containing our userland. Used for stuff like # Filesystem for the device containing our userland. Used for stuff like
# choosing Hurd filesystem module. # choosing Hurd filesystem module.
GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`" GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`"
if [ x"$GRUB_FS" = x ] || [ x"$GRUB_FS" = xunknown ]; then if [ x"$GRUB_FS" = xunknown ]; then
GRUB_FS="$(stat -f --printf=%T "$GRUB_ROOT"/ || echo unknown)" GRUB_FS="$(stat -f --printf=%T / || echo unknown)"
fi fi
if test -f ${sysconfdir}/default/grub ; then if test -f ${sysconfdir}/default/grub ; then
@ -186,7 +178,6 @@ if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub
# These are defined in this script, export them here so that user can # These are defined in this script, export them here so that user can
# override them. # override them.
export GRUB_DEVICE \ export GRUB_DEVICE \
GRUB_ROOT \
GRUB_DEVICE_UUID \ GRUB_DEVICE_UUID \
GRUB_DEVICE_BOOT \ GRUB_DEVICE_BOOT \
GRUB_DEVICE_BOOT_UUID \ GRUB_DEVICE_BOOT_UUID \
@ -256,46 +247,16 @@ EOF
for i in "${grub_mkconfig_dir}"/* ; do for i in "${grub_mkconfig_dir}"/* ; do
case "$i" in case "$i" in
"${grub_mkconfig_dir}"/00_header \
| "${grub_mkconfig_dir}"/30_os-prober \
| "${grub_mkconfig_dir}"/40_custom \
| "${grub_mkconfig_dir}"/41_custom)
if test -x "$i" ; then
echo
echo "### BEGIN $i ###"
"$i"
echo "### END $i ###"
fi
;;
# emacsen backup files. FIXME: support other editors # emacsen backup files. FIXME: support other editors
*~) ;; *~) ;;
# emacsen autosave files. FIXME: support other editors # emacsen autosave files. FIXME: support other editors
*/\#*\#) ;; */\#*\#) ;;
*) *)
if grub_file_is_not_garbage "$i" && test -x "$i" ; then if grub_file_is_not_garbage "$i" && test -x "$i" ; then
for platform in x86 i386-xen-pae x86_64-xen mips mipsel sparc64 powerpc ia64 arm arm64; do
GRUB_PLATFORM=$platform
export GRUB_PLATFORM
buf="$($i)"
if [ x"$buf" != x ]; then
echo echo
echo "### BEGIN $i ($platform) ###" echo "### BEGIN $i ###"
case x$platform in "$i"
xx86) echo "### END $i ###"
echo "if [ x\"\$grub_platform\" != xxen \\( x\"\$grub_cpu\" = xi386 -o x\"\$grub_cpu\" = xx86_64 -o x\"\$grub_platform\" = x \\) ]; then" ;;
xi386-xen-pae)
echo "if [ x\"\$grub_cpu-\$grub_platform\" = xi386-xen -o x\"\$grub_cpu-\$grub_platform\" = x- ]; then" ;;
xx86_64-xen)
echo "if [ x\"\$grub_cpu-\$grub_platform\" = xx86_64-xen -o x\"\$grub_cpu-\$grub_platform\" = x- ]; then" ;;
*)
echo "if [ x\"\$grub_cpu\" = x$platform -o x\"\$grub_platform\" = x ]; then" ;;
esac
echo "$buf"
echo "fi"
echo "### END $i ($platform) ###"
fi
done
fi fi
;; ;;
esac esac

View file

@ -152,7 +152,7 @@ if [ "x$gfxterm" = x1 ]; then
if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT}"` ; then if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT}"` ; then
EOF EOF
else else
for dir in "${pkgdatadir}" "`echo "$GRUB_ROOT"'/@bootdirname@/@grubdirname@' | sed "s,//*,/,g"`" "`echo "$GRUB_ROOT"'/usr/share/grub' | sed "s,//*,/,g"`" ; do for dir in "${pkgdatadir}" "`echo '/@bootdirname@/@grubdirname@' | sed "s,//*,/,g"`" /usr/share/grub ; do
for basename in unicode unifont ascii; do for basename in unicode unifont ascii; do
path="${dir}/${basename}.pf2" path="${dir}/${basename}.pf2"
if is_path_readable_by_grub "${path}" > /dev/null ; then if is_path_readable_by_grub "${path}" > /dev/null ; then

View file

@ -21,16 +21,6 @@ prefix="@prefix@"
exec_prefix="@exec_prefix@" exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@" datarootdir="@datarootdir@"
if [ x$GRUB_PLATFORM = xx86 ]; then
check=--is-x86-multiboot
elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
check=--is-i386-xen-pae-domu
elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
check=--is-x86_64-xen-domu
else
exit 0
fi
export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@" export TEXTDOMAINDIR="@localedir@"
@ -50,11 +40,11 @@ all_of_them=true
# FIXME: add l4 here? # FIXME: add l4 here?
kernel= kernel=
for i in "$GRUB_ROOT"/boot/gnumach* ; do for i in /boot/gnumach* ; do
if test -f "$i" && "${grub_file}" $check "$i" ; then if test -e $i ; then
basename=`basename "$i"` basename=`basename $i`
dirname=`dirname "$i"` dirname=`dirname $i`
rel_dirname=`make_system_path_relative_to_its_root "$dirname"` rel_dirname=`make_system_path_relative_to_its_root $dirname`
gettext_printf "Found GNU Mach: %s" "$i" >&2 gettext_printf "Found GNU Mach: %s" "$i" >&2
echo >&2 echo >&2
kernels="${kernels} ${rel_dirname}/${basename}" kernels="${kernels} ${rel_dirname}/${basename}"
@ -68,8 +58,8 @@ case "${GRUB_FS}" in
*) hurd_fs="${GRUB_FS}fs" ;; *) hurd_fs="${GRUB_FS}fs" ;;
esac esac
for i in "$GRUB_ROOT"/hurd/${hurd_fs}.static "$GRUB_ROOT"/hurd/exec ; do for i in /hurd/${hurd_fs}.static /hurd/exec ; do
if test -f "$i" ; then if test -e "$i" ; then
gettext_printf "Found Hurd module: %s" "$i" >&2 gettext_printf "Found Hurd module: %s" "$i" >&2
echo >&2 echo >&2
at_least_one=true at_least_one=true
@ -83,7 +73,7 @@ if ${at_least_one} ; then : ; else
exit 0 exit 0
fi fi
if ${all_of_them} && test -f "$GRUB_ROOT"/lib/ld.so.1 ; then : ; else if ${all_of_them} && test -e /lib/ld.so.1 ; then : ; else
gettext "Some Hurd stuff found, but not enough to boot." >&2 gettext "Some Hurd stuff found, but not enough to boot." >&2
echo >&2 echo >&2
exit 1 exit 1

View file

@ -27,21 +27,6 @@ export TEXTDOMAINDIR="@localedir@"
CLASS="--class os" CLASS="--class os"
if [ x$GRUB_PLATFORM = xx86 ]; then
check=--is-x86-multiboot
elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
check=--is-i386-xen-pae-domu
elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
check=--is-x86_64-xen-domu
else
exit 0
fi
if ! test -f "$GRUB_ROOT"/platform/i86pc/kernel || ! "${grub_file}" $check "$GRUB_ROOT"/platform/i86pc/kernel; then
exit 0
fi
case "${GRUB_DISTRIBUTOR}" in case "${GRUB_DISTRIBUTOR}" in
*) *)
OS="Illumos" OS="Illumos"
@ -60,7 +45,7 @@ message="$(gettext_printf "Loading kernel of Illumos ...")"
else else
ISADIR= ISADIR=
fi fi
zfs-bootfs $($grub_mkrelpath "$GRUB_ROOT"/) ZFS_BOOTFS zfs-bootfs $($grub_mkrelpath /) ZFS_BOOTFS
echo '$(echo "$message" | grub_quote)' echo '$(echo "$message" | grub_quote)'
multiboot $($grub_mkrelpath /platform/i86pc/kernel)/\$ISADIR/unix /platform/i86pc/kernel/\$ISADIR/unix -B \$ZFS_BOOTFS,console=text multiboot $($grub_mkrelpath /platform/i86pc/kernel)/\$ISADIR/unix /platform/i86pc/kernel/\$ISADIR/unix -B \$ZFS_BOOTFS,console=text
module $($grub_mkrelpath /platform/i86pc)/\$ISADIR/boot_archive /platform/i86pc/\$ISADIR/boot_archive module $($grub_mkrelpath /platform/i86pc)/\$ISADIR/boot_archive /platform/i86pc/\$ISADIR/boot_archive

View file

@ -27,16 +27,6 @@ export TEXTDOMAINDIR="@localedir@"
CLASS="--class os" CLASS="--class os"
if [ x$GRUB_PLATFORM = xx86 ]; then
check=--is-x86-kfreebsd
elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
check=--is-i386-xen-pae-domu
elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
check=--is-x86_64-xen-domu
else
exit 0
fi
case "${GRUB_DISTRIBUTOR}" in case "${GRUB_DISTRIBUTOR}" in
Debian) Debian)
OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
@ -132,10 +122,10 @@ EOF
zfs) zfs)
load_kfreebsd_module opensolaris false load_kfreebsd_module opensolaris false
ls "$GRUB_ROOT/boot/zfs/zpool.cache" > /dev/null ls "/boot/zfs/zpool.cache" > /dev/null
printf '%s\n' "${prepare_boot_cache}" printf '%s\n' "${prepare_boot_cache}"
sed "s/^/$submenu_indentation/" << EOF sed "s/^/$submenu_indentation/" << EOF
kfreebsd_module $(make_system_path_relative_to_its_root $GRUB_ROOT/boot)/zfs/zpool.cache type=/boot/zfs/zpool.cache kfreebsd_module $(make_system_path_relative_to_its_root /boot)/zfs/zpool.cache type=/boot/zfs/zpool.cache
EOF EOF
;; ;;
esac esac
@ -153,8 +143,8 @@ EOF
EOF EOF
} }
list=`for i in $GRUB_ROOT/boot/kfreebsd-* $GRUB_ROOT/boot/kernel/kernel ; do list=`for i in /boot/kfreebsd-* /boot/kernel/kernel ; do
if grub_file_is_not_garbage "$i" && ${grub_file} $check "$i"; then echo -n "$i " ; fi if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done` done`
prepare_boot_cache= prepare_boot_cache=
boot_device_id= boot_device_id=
@ -173,8 +163,8 @@ while [ "x$list" != "x" ] ; do
dirname=`dirname $kfreebsd` dirname=`dirname $kfreebsd`
rel_dirname=`make_system_path_relative_to_its_root $dirname` rel_dirname=`make_system_path_relative_to_its_root $dirname`
if [ -f "$GRUB_ROOT"/boot/device.hints ] ; then if [ -f /boot/device.hints ] ; then
devices="$GRUB_ROOT"/boot/device.hints devices=/boot/device.hints
devices_basename=`basename $devices` devices_basename=`basename $devices`
devices_dirname=`dirname $devices` devices_dirname=`dirname $devices`
devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname` devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname`
@ -191,14 +181,14 @@ while [ "x$list" != "x" ] ; do
# zpool name # zpool name
kfreebsd_device=$(${grub_probe} -t fs_label --device ${GRUB_DEVICE}) kfreebsd_device=$(${grub_probe} -t fs_label --device ${GRUB_DEVICE})
# filesystem name (empty string for the main filesystem) # filesystem name (empty string for the main filesystem)
kfreebsd_device="${kfreebsd_device}$(${grub_mkrelpath} "$GRUB_ROOT"/ | sed -e "s,/*@$,,")" kfreebsd_device="${kfreebsd_device}$(${grub_mkrelpath} / | sed -e "s,/*@$,,")"
;; ;;
*) *)
kfreebsd_device=${kfreebsd_fs}id/${GRUB_DEVICE_UUID} kfreebsd_device=${kfreebsd_fs}id/${GRUB_DEVICE_UUID}
# Debian GNU/kFreeBSD can't remount root if it's supplied as UUID but # Debian GNU/kFreeBSD can't remount root if it's supplied as UUID but
# as an UUID # as an UUID
if [ "x${GRUB_DISTRIBUTOR}" = "xDebian" ] \ if [ "x${GRUB_DISTRIBUTOR}" = "xDebian" ] \
&& ! (cat "$GRUB_ROOT"/etc/fstab | awk '!/^[[:space:]]*#/ && $2=="/" { print $1; }' \ && ! (cat /etc/fstab | awk '!/^[[:space:]]*#/ && $2=="/" { print $1; }' \
| grep "${kfreebsd_fs}id/${GRUB_DEVICE_UUID}" > /dev/null); then | grep "${kfreebsd_fs}id/${GRUB_DEVICE_UUID}" > /dev/null); then
kfreebsd_device=${GRUB_DEVICE} kfreebsd_device=${GRUB_DEVICE}
fi fi
@ -209,8 +199,8 @@ while [ "x$list" != "x" ] ; do
alt_version=`echo $version | sed -e "s,\.old$,,g"` alt_version=`echo $version | sed -e "s,\.old$,,g"`
module_dir= module_dir=
for i in "$GRUB_ROOT/lib/modules/${version}" "$GRUB_ROOT/lib/modules/${alt_version}" \ for i in "/lib/modules/${version}" "/lib/modules/${alt_version}" \
"$GRUB_ROOT/boot/kernel"; do "/boot/kernel"; do
if test -e "$i" ; then if test -e "$i" ; then
module_dir="$i" module_dir="$i"
break break

View file

@ -26,31 +26,6 @@ datarootdir="@datarootdir@"
export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@" export TEXTDOMAINDIR="@localedir@"
if [ x$GRUB_PLATFORM = xx86 ]; then
check=--is-x86-linux32
elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
check=--is-i386-xen-pae-domu
elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
check=--is-x86_64-xen-domu
else
check=--is-${GRUB_PLATFORM}-linux
fi
case "x$GRUB_PLATFORM" in
xx86)
list=`for i in "$GRUB_ROOT"/boot/vmlinuz-* "$GRUB_ROOT"/vmlinuz-* "$GRUB_ROOT"/boot/kernel-* ; do
if grub_file_is_not_garbage "$i" && "${grub_file}" $check "$i" ; then echo -n "$i " ; fi
done` ;;
*)
list=`for i in "$GRUB_ROOT"/boot/vmlinuz-* "$GRUB_ROOT"/boot/vmlinux-* "$GRUB_ROOT"/vmlinuz-* "$GRUB_ROOT"/vmlinux-* "$GRUB_ROOT"/boot/kernel-* ; do
if grub_file_is_not_garbage "$i" && "${grub_file}" $check "$i" ; then echo -n "$i " ; fi
done` ;;
esac
if [ x"$list" = x ]; then
exit 0
fi
CLASS="--class gnu-linux --class gnu --class os" CLASS="--class gnu-linux --class gnu --class os"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
@ -78,14 +53,14 @@ fi
case x"$GRUB_FS" in case x"$GRUB_FS" in
xbtrfs) xbtrfs)
rootsubvol="`make_system_path_relative_to_its_root "$GRUB_ROOT"/`" rootsubvol="`make_system_path_relative_to_its_root /`"
rootsubvol="${rootsubvol#/}" rootsubvol="${rootsubvol#/}"
if [ "x${rootsubvol}" != x ]; then if [ "x${rootsubvol}" != x ]; then
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi;; fi;;
xzfs) xzfs)
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
bootfs="`make_system_path_relative_to_its_root "$GRUB_ROOT"/ | sed -e "s,@$,,"`" bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}" LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
;; ;;
esac esac
@ -140,7 +115,7 @@ linux_entry ()
echo " insmod gzio" | sed "s/^/$submenu_indentation/" echo " insmod gzio" | sed "s/^/$submenu_indentation/"
if [ x$dirname = x"$GRUB_ROOT"/ ]; then if [ x$dirname = x/ ]; then
if [ -z "${prepare_root_cache}" ]; then if [ -z "${prepare_root_cache}" ]; then
prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)" prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)"
fi fi
@ -169,12 +144,24 @@ EOF
EOF EOF
} }
case "$GRUB_PLATFORM" in machine=`uname -m`
x86 | i386-xen-pae | x86_64-xen) GENKERNEL_ARCH="x86" ;; case "x$machine" in
xi?86 | xx86_64)
list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done` ;;
*)
list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done` ;;
esac
case "$machine" in
i?86) GENKERNEL_ARCH="x86" ;;
mips|mips64) GENKERNEL_ARCH="mips" ;; mips|mips64) GENKERNEL_ARCH="mips" ;;
mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;; mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;;
arm*) GENKERNEL_ARCH="arm" ;; arm*) GENKERNEL_ARCH="arm" ;;
*) GENKERNEL_ARCH="$GRUB_PLATFORM" ;; *) GENKERNEL_ARCH="$machine" ;;
esac esac
prepare_boot_cache= prepare_boot_cache=
@ -213,7 +200,7 @@ while [ "x$list" != "x" ] ; do
done done
config= config=
for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "$GRUB_ROOT/etc/kernels/kernel-config-${version}" ; do for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
if test -e "${i}" ; then if test -e "${i}" ; then
config="${i}" config="${i}"
break break

View file

@ -22,16 +22,6 @@ exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@" datarootdir="@datarootdir@"
. "@datadir@/@PACKAGE@/grub-mkconfig_lib" . "@datadir@/@PACKAGE@/grub-mkconfig_lib"
if [ x$GRUB_PLATFORM = xx86 ]; then
check=--is-x86-kfreebsd
elif [ x$GRUB_PLATFORM = xi386-xen-pae ]; then
check=--is-i386-xen-pae-domu
elif [ x$GRUB_PLATFORM = xx86_64-xen ]; then
check=--is-x86_64-xen-domu
else
exit 0
fi
export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@" export TEXTDOMAINDIR="@localedir@"
@ -46,13 +36,19 @@ netbsd_load_fs_module ()
loader="$1" # "knetbsd" or "multiboot" loader="$1" # "knetbsd" or "multiboot"
kernel="$2" # absolute path to the kernel file kernel="$2" # absolute path to the kernel file
if "${grub_file}" --is-x86_64-kfreebsd "${kernel}"; then case $(zcat -f "${kernel}" | file -bL - | cut -d , -f 2 | tr -d ' ') in
karch="amd64" Intel80386)
else
karch="i386" karch="i386"
fi ;;
x86-64)
karch="amd64"
;;
*)
return
;;
esac
case $GRUB_FS in case $(${grub_probe} --target=fs -d ${GRUB_DEVICE}) in
ext2) ext2)
kmod="ext2fs" kmod="ext2fs"
;; ;;
@ -71,7 +67,7 @@ netbsd_load_fs_module ()
esac esac
kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }') kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }')
kmodule="$GRUB_ROOT/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod" kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod"
if test -z "$karch" -o -z "$kversion" -o ! -f "${kmodule}"; then if test -z "$karch" -o -z "$kversion" -o ! -f "${kmodule}"; then
return return
@ -98,10 +94,6 @@ netbsd_entry ()
type="$3" type="$3"
args="$4" # extra arguments appended to loader command args="$4" # extra arguments appended to loader command
if [ "x${loader}" = xmultiboot ] && [ x$GRUB_PLATFORM = xx86 ] && ! "$grub_file" --is-x86-multiboot "$kernel"; then
return
fi
kroot_device="$(echo ${GRUB_DEVICE} | sed -e 's,^/dev/r,,')" kroot_device="$(echo ${GRUB_DEVICE} | sed -e 's,^/dev/r,,')"
if [ -z "$boot_device_id" ]; then if [ -z "$boot_device_id" ]; then
@ -155,13 +147,10 @@ pattern="^ELF[^,]*executable.*statically linked"
submenu_indentation="" submenu_indentation=""
is_top_level=true is_top_level=true
for k in "$GRUB_ROOT"/netbsd $(ls -t "$GRUB_ROOT"/netbsd?* 2>/dev/null) ; do for k in /netbsd $(ls -t /netbsd?* 2>/dev/null) ; do
if ! grub_file_is_not_garbage "$k" ; then if ! grub_file_is_not_garbage "$k" ; then
continue continue
fi fi
if ! "$grub_file" $check "$k"; then
continue
fi
if ! (zcat -f "$k" | file -bL - | grep -q "${pattern}") 2>/dev/null ; then if ! (zcat -f "$k" | file -bL - | grep -q "${pattern}") 2>/dev/null ; then
continue continue
fi fi

View file

@ -26,28 +26,18 @@ export TEXTDOMAINDIR="@localedir@"
. "@datadir@/@PACKAGE@/grub-mkconfig_lib" . "@datadir@/@PACKAGE@/grub-mkconfig_lib"
if [ x$GRUB_PLATFORM != xx86 ]; then
exit 0
fi
osx_entry() { osx_entry() {
if [ x$2 = x32 ]; then if [ x$2 = x32 ]; then
# TRANSLATORS: it refers to kernel architecture (32-bit) # TRANSLATORS: it refers to kernel architecture (32-bit)
bitstr="$(gettext "(32-bit)")" bitstr="$(gettext "(32-bit)")"
if ! [ -f "$GRUB_ROOT"/mach_kernel ] || ! "${grub_file}" --is-i386-xnu "$GRUB_ROOT"/mach_kernel; then
return;
fi
else else
# TRANSLATORS: it refers to kernel architecture (64-bit) # TRANSLATORS: it refers to kernel architecture (64-bit)
bitstr="$(gettext "(64-bit)")" bitstr="$(gettext "(64-bit)")"
if ! [ -f "$GRUB_ROOT"/mach_kernel ] || ! "${grub_file}" --is-x86_64-xnu "$GRUB_ROOT"/mach_kernel; then
return;
fi
fi fi
# TRANSLATORS: it refers on the OS residing on device %s # TRANSLATORS: it refers on the OS residing on device %s
onstr="$(gettext_printf "(on %s)" "${GRUB_DEVICE}")" onstr="$(gettext_printf "(on %s)" "${GRUB_DEVICE}")"
cat << EOF cat << EOF
menuentry '$(echo "Darwin/Mac OS X $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'xnu-$2-$(grub_get_device_id "${GRUB_DEVICE}")' { menuentry '$(echo "Darwin/Mac OS X $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${GRUB_DEVICE}")' {
EOF EOF
save_default_entry | grub_add_tab save_default_entry | grub_add_tab
prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab
@ -60,7 +50,7 @@ EOF
fi fi
fi fi
if [ \$do_resume = 0 ]; then if [ \$do_resume = 0 ]; then
xnu_uuid ${GRUB_DEVICE_UUID} uuid xnu_uuid ${OSXUUID} uuid
if [ -f /Extra/DSDT.aml ]; then if [ -f /Extra/DSDT.aml ]; then
acpi -e /Extra/DSDT.aml acpi -e /Extra/DSDT.aml
fi fi
@ -100,5 +90,6 @@ EOF
EOF EOF
} }
OSXUUID="`${grub_probe} --target=fs_uuid --device ${GRUB_DEVICE} 2> /dev/null`"
osx_entry xnu_kernel 32 osx_entry xnu_kernel 32
osx_entry xnu_kernel64 64 osx_entry xnu_kernel64 64

View file

@ -26,10 +26,6 @@ datarootdir="@datarootdir@"
export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR="@localedir@" export TEXTDOMAINDIR="@localedir@"
if [ x$GRUB_PLATFORM != xx86 ]; then
exit 0
fi
CLASS="--class gnu-linux --class gnu --class os --class xen" CLASS="--class gnu-linux --class gnu --class os --class xen"
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
@ -65,14 +61,14 @@ fi
case x"$GRUB_FS" in case x"$GRUB_FS" in
xbtrfs) xbtrfs)
rootsubvol="`make_system_path_relative_to_its_root "$GRUB_ROOT"/`" rootsubvol="`make_system_path_relative_to_its_root /`"
rootsubvol="${rootsubvol#/}" rootsubvol="${rootsubvol#/}"
if [ "x${rootsubvol}" != x ]; then if [ "x${rootsubvol}" != x ]; then
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi;; fi;;
xzfs) xzfs)
rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
bootfs="`make_system_path_relative_to_its_root "$GRUB_ROOT"/ | sed -e "s,@$,,"`" bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}" LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
;; ;;
esac esac
@ -141,9 +137,19 @@ EOF
EOF EOF
} }
linux_list=`for i in "$GRUB_ROOT"/boot/vmlinu[xz]-* "$GRUB_ROOT"/vmlinu[xz]-* "$GRUB_ROOT"/boot/kernel-*; do linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do
if grub_file_is_not_garbage "$i" && "${grub_file}" --is-x86-xen-dom0 "$i"; then if grub_file_is_not_garbage "$i"; then
echo -n "$i " ; basename=$(basename $i)
version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
dirname=$(dirname $i)
config=
for j in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
if test -e "${j}" ; then
config="${j}"
break
fi
done
if (grep -qx "CONFIG_XEN_DOM0=y" "${config}" 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" "${config}" 2> /dev/null); then echo -n "$i " ; fi
fi fi
done` done`
if [ "x${linux_list}" = "x" ] ; then if [ "x${linux_list}" = "x" ] ; then
@ -159,8 +165,8 @@ file_is_not_sym () {
esac esac
} }
xen_list=`for i in "$GRUB_ROOT"/boot/xen*; do xen_list=`for i in /boot/xen*; do
if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" && ${grub_file} --is-x86-multiboot "$i"; then echo -n "$i " ; fi if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then echo -n "$i " ; fi
done` done`
prepare_boot_cache= prepare_boot_cache=
boot_device_id= boot_device_id=