From 5ca06d7f8dcf079d7c29a44d4be136db5e4cdae1 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 26 Oct 2016 22:34:55 +0200 Subject: [PATCH] saving uncommitted changes in /etc prior to emerge run --- grub.d/00_header | 4 ++-- grub.d/10_linux | 6 ++++-- grub.d/20_linux_xen | 6 ++++-- grub.d/30_os-prober | 39 ++++++++++++++++++++++++--------------- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/grub.d/00_header b/grub.d/00_header index fb9b859..0f2f784 100755 --- a/grub.d/00_header +++ b/grub.d/00_header @@ -25,7 +25,7 @@ grub_lang=`echo $LANG | cut -d . -f 1` export TEXTDOMAIN=grub export TEXTDOMAINDIR="${datarootdir}/locale" -. "/usr/share/grub/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" # Do this as early as possible, since other commands might depend on it. # (e.g. the `loadfont' command might need lvm or raid modules) @@ -285,7 +285,7 @@ make_timeout () if [ "x${3}" != "x" ] ; then timeout="${2}" style="${3}" - elif [ "x${1}" != "x" -a "x${1}" != "x0" ] ; then + elif [ "x${1}" != "x" ] && [ "x${1}" != "x0" ] ; then # Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme. timeout="${1}" if [ "x${2}" != "x0" ] ; then diff --git a/grub.d/10_linux b/grub.d/10_linux index 0b2914f..3f77f7b 100755 --- a/grub.d/10_linux +++ b/grub.d/10_linux @@ -21,7 +21,7 @@ prefix="/usr" exec_prefix="/usr" datarootdir="/usr/share" -. "/usr/share/grub/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=grub export TEXTDOMAINDIR="${datarootdir}/locale" @@ -43,9 +43,11 @@ case ${GRUB_DEVICE} in ;; esac +# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter +# and mounting btrfs requires user space scanning, so force UUID in this case. if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ - || uses_abstraction "${GRUB_DEVICE}" lvm; then + || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} diff --git a/grub.d/20_linux_xen b/grub.d/20_linux_xen index efc2725..b3ac854 100755 --- a/grub.d/20_linux_xen +++ b/grub.d/20_linux_xen @@ -21,7 +21,7 @@ prefix="/usr" exec_prefix="/usr" datarootdir="/usr/share" -. "/usr/share/grub/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=grub export TEXTDOMAINDIR="${datarootdir}/locale" @@ -43,9 +43,11 @@ case ${GRUB_DEVICE} in ;; esac +# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter +# and mounting btrfs requires user space scanning, so force UUID in this case. if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ - || uses_abstraction "${GRUB_DEVICE}" lvm; then + || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} diff --git a/grub.d/30_os-prober b/grub.d/30_os-prober index d7e7923..aa66c6e 100755 --- a/grub.d/30_os-prober +++ b/grub.d/30_os-prober @@ -24,13 +24,13 @@ datarootdir="/usr/share" export TEXTDOMAIN=grub export TEXTDOMAINDIR="${datarootdir}/locale" -. "/usr/share/grub/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then exit 0 fi -if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then +if [ -z "`which os-prober 2> /dev/null`" ] || [ -z "`which linux-boot-prober 2> /dev/null`" ] ; then # missing os-prober and/or linux-boot-prober exit 0 fi @@ -71,6 +71,9 @@ EOF fi if [ /kernelcache -nt /System/Library/Extensions ]; then $1 /kernelcache boot-uuid=\${uuid} rd=*uuid + elif [ -f /System/Library/Kernels/kernel ]; then + $1 /System/Library/Kernels/kernel boot-uuid=\${uuid} rd=*uuid + xnu_kextdir /System/Library/Extensions else $1 /mach_kernel boot-uuid=\${uuid} rd=*uuid if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then @@ -112,16 +115,17 @@ for OS in ${OSPROBED} ; do LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`" LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`" BOOT="`echo ${OS} | cut -d ':' -f 4`" - UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`" - EXPUUID="$UUID" + if UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"; then + EXPUUID="$UUID" - if [ x"${DEVICE#*@}" != x ] ; then + if [ x"${DEVICE#*@}" != x ] ; then EXPUUID="${EXPUUID}@${DEVICE#*@}" - fi + fi - if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" -a "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then - echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2 - continue + if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then + echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2 + continue + fi fi BTRFS="`echo ${OS} | cut -d ':' -f 5`" @@ -134,6 +138,9 @@ for OS in ${OSPROBED} ; do LONGNAME="${LABEL}" fi + # os-prober returns text string followed by optional counter + CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')" + gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2 case ${BOOT} in @@ -141,7 +148,7 @@ for OS in ${OSPROBED} ; do onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF -menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' { +menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' { EOF save_default_entry | grub_add_tab prepare_grub_to_access_device ${DEVICE} | grub_add_tab @@ -173,7 +180,7 @@ EOF DEVICE=${DEVICE%@*} onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF -menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' { +menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' { EOF save_default_entry | sed -e "s/^/\t/" prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" @@ -229,7 +236,7 @@ EOF if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then cat << EOF -menuentry '$(echo "$OS $onstr" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' { +menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' { EOF save_default_entry | grub_add_tab printf '%s\n' "${prepare_boot_cache}" @@ -277,9 +284,11 @@ EOF echo "$title_correction_code" ;; macosx) - OSXUUID="${UUID}" - osx_entry xnu_kernel 32 - osx_entry xnu_kernel64 64 + if [ "${UUID}" ]; then + OSXUUID="${UUID}" + osx_entry xnu_kernel 32 + osx_entry xnu_kernel64 64 + fi ;; hurd) onstr="$(gettext_printf "(on %s)" "${DEVICE}")" -- 2.39.5