commit 4626a651d0aeeafb24d84f5c622cca25843f4dcd Author: Mike Hiretsky Date: Fri Jun 10 11:17:34 2011 +0400 Add CHROOT_PATH ability. Add sync before grub_setup. diff --git a/util/grub-install.in b/util/grub-install.in index ff8bea8..16236ba 100644 --- a/util/grub-install.in +++ b/util/grub-install.in @@ -580,6 +580,8 @@ fi # Perform the platform-dependent install if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then + # sync filesystem before grub_setup + sync # Now perform the installation. "$grub_setup" ${allow_floppy} ${setup_verbose} ${setup_force} --directory="${grubdir}" \ --device-map="${device_map}" "${install_device}" || exit 1 diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index afc66f8..1586ad7 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -141,19 +141,19 @@ if test -e ${GRUB_PREFIX}/device.map ; then : ; else fi # Device containing our userland. Typically used for root= parameter. -GRUB_DEVICE="`${grub_probe} --target=device /`" +GRUB_DEVICE="`${grub_probe} --target=device /${CHROOT_PATH#/}`" 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. -GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`" +GRUB_DEVICE_BOOT="`${grub_probe} --target=device ${CHROOT_PATH%/}/boot`" 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 # choosing Hurd filesystem module. GRUB_FS="`${grub_probe} --device ${GRUB_DEVICE} --target=fs 2> /dev/null || echo unknown`" -if test -f ${sysconfdir}/default/grub ; then - . ${sysconfdir}/default/grub +if test -f ${CHROOT_PATH}${sysconfdir}/default/grub ; then + . ${CHROOT_PATH}${sysconfdir}/default/grub fi # XXX: should this be deprecated at some point? @@ -171,7 +171,7 @@ fi for x in ${GRUB_TERMINAL_OUTPUT}; do if [ "x${x}" = "xgfxterm" ]; then if [ -n "$GRUB_FONT" ] ; then - if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then + if is_path_readable_by_grub ${CHROOT_PATH%/}${GRUB_FONT} > /dev/null ; then GRUB_FONT_PATH=${GRUB_FONT} else echo "No such font or not readable by grub: ${GRUB_FONT}" >&2 @@ -181,7 +181,7 @@ for x in ${GRUB_TERMINAL_OUTPUT}; do for dir in ${pkgdatadir} ${GRUB_PREFIX} /usr/share/grub ; do for basename in unicode unifont ascii; do path="${dir}/${basename}.pf2" - if is_path_readable_by_grub ${path} > /dev/null ; then + if is_path_readable_by_grub ${CHROOT_PATH%/}${path} > /dev/null ; then GRUB_FONT_PATH=${path} else continue diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 9da1511..5d54f1c 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -125,7 +125,7 @@ fi if [ "x$gfxterm" = x1 ]; then # Make the font accessible - prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT_PATH}"` + prepare_grub_to_access_device `${grub_probe} --target=device "${CHROOT_PATH%/}${GRUB_FONT_PATH}"` cat << EOF if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then @@ -136,7 +136,7 @@ EOF # Gettext variables and module if [ "x${LANG}" != "xC" ] && [ -d "${locale_dir}" ] ; then - prepare_grub_to_access_device $(${grub_probe} --target=device ${locale_dir}) | sed -e "s/^/ /" + prepare_grub_to_access_device $(${grub_probe} --target=device ${CHROOT_PATH%/}${locale_dir}) | sed -e "s/^/ /" cat << EOF set locale_dir=(\$root)$(make_system_path_relative_to_its_root ${locale_dir}) set lang=${grub_lang} @@ -175,7 +175,7 @@ if [ "x$gfxterm" = x1 ]; then if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \ && is_path_readable_by_grub "$GRUB_THEME"; then echo "Found theme: $GRUB_THEME" >&2 - prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_THEME"` + prepare_grub_to_access_device `${grub_probe} --target=device "${CHROOT_PATH%/}$GRUB_THEME"` cat << EOF insmod gfxmenu EOF @@ -206,8 +206,8 @@ EOF cat << EOF set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME` EOF - elif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \ - && is_path_readable_by_grub "$GRUB_BACKGROUND"; then + elif [ "x${CHROOT_PATH}$GRUB_BACKGROUND" != x ] && [ -f "${CHROOT_PATH%/}$GRUB_BACKGROUND" ] \ + && is_path_readable_by_grub "${CHROOT_PATH%/}$GRUB_BACKGROUND"; then echo "Found background: $GRUB_BACKGROUND" >&2 case "$GRUB_BACKGROUND" in *.png) reader=png ;; @@ -215,7 +215,7 @@ EOF *.jpg|*.jpeg) reader=jpeg ;; *) echo "Unsupported image format" >&2; exit 1 ;; esac - prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"` + prepare_grub_to_access_device `${grub_probe} --target=device "${CHROOT_PATH%/}$GRUB_BACKGROUND"` cat << EOF insmod $reader background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"` diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 1d1eb40..505aac6 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -31,7 +31,7 @@ CLASS="--class gnu-linux --class gnu --class os" if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU/Linux else - OS="${GRUB_DISTRIBUTOR} GNU/Linux" + OS="${GRUB_DISTRIBUTOR}" CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}" fi @@ -132,12 +132,18 @@ EOF case x`uname -m` 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 + list=`for i in ${CHROOT_PATH%/}/boot/vmlinuz-* \ + ${CHROOT_PATH%/}/vmlinuz-* \ + ${CHROOT_PATH%/}/boot/kernel-* ; do + if grub_file_is_not_garbage "$i" && ! [[ -L $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 + list=`for i in ${CHROOT_PATH%/}/boot/vmlinuz-* \ + ${CHROOT_PATH%/}/boot/vmlinux-* \ + ${CHROOT_PATH%/}/vmlinuz-* \ + ${CHROOT_PATH%/}/vmlinux-* \ + ${CHROOT_PATH%/}/boot/kernel-* ; do + if grub_file_is_not_garbage "$i" && ! [[ -L $i ]] ; then echo -n "$i " ; fi done` ;; esac @@ -150,6 +156,7 @@ while [ "x$list" != "x" ] ; do basename=`basename $linux` dirname=`dirname $linux` rel_dirname=`make_system_path_relative_to_its_root $dirname` + rel_dirname=${rel_dirname#/workspace} version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` alt_version=`echo $version | sed -e "s,\.old$,,g"` linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" @@ -160,7 +167,8 @@ while [ "x$list" != "x" ] ; do "initrd.img-${alt_version}" "initrd-${alt_version}.img" \ "initrd-${alt_version}" "initramfs-${alt_version}.img" \ "initramfs-genkernel-${version}" \ - "initramfs-genkernel-${alt_version}"; do + "initramfs-genkernel-${alt_version}" \ + "initramfs-${version}"; do if test -e "${dirname}/${i}" ; then initrd="$i" break