--- s/10_linux 2017-07-19 19:27:57.718203411 +0200 +++ m/10_linux 2017-07-19 19:27:49.284843301 +0200 @@ -21,17 +21,17 @@ exec_prefix="/usr" datarootdir="/usr/share" -. "${datarootdir}/grub2/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" -export TEXTDOMAIN=grub2 +export TEXTDOMAIN=grub export TEXTDOMAINDIR="${datarootdir}/locale" CLASS="--class gnu-linux --class gnu --class os" if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then - OS=GNU/Linux + OS=Linux else - OS="${GRUB_DISTRIBUTOR}" + OS="${GRUB_DISTRIBUTOR} Linux" CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" fi @@ -53,20 +53,12 @@ LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} fi -if [ "x$GRUB_CONMODE" != "x" ]; then - GRUB_CMDLINE_LINUX="conmode=${GRUB_CONMODE} ${GRUB_CMDLINE_LINUX}" -fi - case x"$GRUB_FS" in xbtrfs) - if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then - GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}" - else rootsubvol="`make_system_path_relative_to_its_root /`" rootsubvol="${rootsubvol#/}" - if [ "x${rootsubvol}" != x ] && [ "x$SUSE_REMOVE_LINUX_ROOT_PARAM" != "xtrue" ]; then + if [ "x${rootsubvol}" != x ]; then GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" - fi fi;; xzfs) rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` @@ -75,27 +67,14 @@ ;; esac -if [ "x$SUSE_REMOVE_LINUX_ROOT_PARAM" = "xtrue" ]; then - LINUX_ROOT_DEVICE="" +intel_ucode= +if test -e "/boot/intel-ucode.img" ; then + gettext_printf "Found Intel Microcode image\n" >&2 + intel_ucode="$(make_system_path_relative_to_its_root /boot/intel-ucode.img)" fi title_correction_code= -hotkey=1 -incr_hotkey() -{ - [ -z "$hotkey" ] && return - expr $hotkey + 1 -} -print_hotkey() -{ - keys="123456789abdfgijklmnoprtuvwyz" - if [ -z "$hotkey" ]||[ $hotkey -eq 0 ]||[ $hotkey -gt 30 ]; then - return - fi - echo "--hotkey=$(expr substr $keys $hotkey 1)" -} - linux_entry () { os="$1" @@ -103,21 +82,17 @@ type="$3" args="$4" - if [ -n "${linux_root_device_thisversion}" ]; then - root_device="root=${linux_root_device_thisversion}" - else - root_device="" - fi - if [ -z "$boot_device_id" ]; then boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" fi if [ x$type != xsimple ] ; then case $type in recovery) - title="$(gettext_printf "%s, with Linux %s (recovery mode)" "${os}" "${version}")" ;; + title="$(gettext_printf "%s (Kernel: %s - recovery mode)" "${os}" "${version}")" ;; + fallback) + title="$(gettext_printf "%s (Kernel: %s - fallback initramfs)" "${os}" "${version}")" ;; *) - title="$(gettext_printf "%s, with Linux %s" "${os}" "${version}")" ;; + title="$(gettext_printf "%s (Kernel: %s)" "${os}" "${version}")" ;; esac if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')" @@ -125,13 +100,11 @@ title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;" grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")" fi - echo "menuentry '$(echo "$title" | grub_quote)' $(print_hotkey) ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" - hotkey=$(incr_hotkey) + echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" else - echo "menuentry '$(echo "$os" | grub_quote)' $(print_hotkey) ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" - hotkey=$(incr_hotkey) + echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" fi - if [ x$type != xrecovery ] ; then + if [ x$type != xrecovery ] && [ x$type != xfallback ] ; then save_default_entry | grub_add_tab fi @@ -152,7 +125,6 @@ echo " insmod gzio" | sed "s/^/$submenu_indentation/" - if [ $PLATFORM != emu ]; then # 'search' does not work for now if [ x$dirname = x/ ]; then if [ -z "${prepare_root_cache}" ]; then prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)" @@ -164,33 +136,19 @@ fi printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" fi - fi - message="$(gettext_printf "Loading Linux %s ..." ${version})" - if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then - sed "s/^/$submenu_indentation/" << EOF - echo '$(echo "$message" | grub_quote)' - linuxefi ${rel_dirname}/${basename} ${root_device} ro ${args} -EOF - else - sed "s/^/$submenu_indentation/" << EOF + + message="$(gettext_printf "Loading Linux %s ..." "${version}")" + sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' - linux ${rel_dirname}/${basename} ${root_device} ${args} + linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} rw ${args} EOF - fi if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" - if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then - sed "s/^/$submenu_indentation/" << EOF - echo '$(echo "$message" | grub_quote)' - initrdefi ${rel_dirname}/${initrd} -EOF - else - sed "s/^/$submenu_indentation/" << EOF + sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' - initrd ${rel_dirname}/${initrd} + initrd ${intel_ucode} ${rel_dirname}/${initrd} EOF - fi fi sed "s/^/$submenu_indentation/" << EOF } @@ -198,19 +156,18 @@ } machine=`uname -m` -case "$machine" in - i?86 | x86_64) klist="/boot/vmlinuz-* /vmlinuz-* /boot/kernel-*" ;; - s390 | s390x) klist="/boot/image-* /boot/kernel-*" ;; - arm*) klist="/boot/zImage-* /zImage-* /boot/kernel-*" ;; - aarch64) klist="/boot/Image-* /boot/kernel-*" ;; - *) klist="/boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* \ - /boot/kernel-*" ;; +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 list="$list $i" ; fi + done ;; + *) + list= + for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do + if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi + done ;; esac -list=`for i in $klist; do - if grub_file_is_not_garbage "$i" ; then - echo -n "$i " ; - fi - done` case "$machine" in i?86) GENKERNEL_ARCH="x86" ;; @@ -220,15 +177,6 @@ *) GENKERNEL_ARCH="$machine" ;; esac -PLATFORM="native" -if [ -d /sys/firmware/efi ]&&[ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then - PLATFORM="efi" -else - case "$machine" in - s390*) PLATFORM="emu" ;; - esac -fi - prepare_boot_cache= prepare_root_cache= boot_device_id= @@ -245,21 +193,31 @@ basename=`basename $linux` dirname=`dirname $linux` rel_dirname=`make_system_path_relative_to_its_root $dirname` - if [ $PLATFORM != "emu" ]; then - hotkey=0 - else - if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] && - [ "x${GRUB_FS}" = "xbtrfs" ] ; then - rel_dirname="\${btrfs_subvol}$dirname" - else - rel_dirname="$dirname" - fi - fi 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}" + if test -e "/etc/manjaro-release" ; then + kbasename="`echo "${basename}" | sed -e 's,vmlinuz-,linux,g'`" + if test -e "${dirname}/${kbasename}.kver" ; then + version="$(cat ${dirname}/${kbasename}.kver)" + fi + kbasename2="`echo "${basename}" | sed -e 's,vmlinuz-,linux-,g'`" + if test -e "${dirname}/${kbasename2}.kver" ; then + version="$(cat ${dirname}/${kbasename2}.kver)" + fi + kbasename3="`echo "${basename}" | sed -e 's,vmlinuz-,linux,g' | sed -e 's,\.,,g'`" + if test -e "${dirname}/${kbasename3}.kver" ; then + version="$(cat ${dirname}/${kbasename3}.kver)" + fi + kbasename4="`echo "${basename}" | sed -e 's,vmlinuz-,linux-,g' | sed -e 's,\.,,g'`" + if test -e "${dirname}/${kbasename4}.kver" ; then + version="$(cat ${dirname}/${kbasename4}.kver)" + fi + fi + initrd= + initramfs_manjaro="`echo "${basename}" | sed -e 's,vmlinuz,initramfs,g'`" for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \ "initrd-${version}" "initramfs-${version}.img" \ "initrd.img-${alt_version}" "initrd-${alt_version}.img" \ @@ -267,7 +225,8 @@ "initramfs-genkernel-${version}" \ "initramfs-genkernel-${alt_version}" \ "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \ - "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do + "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}" \ + "${initramfs_manjaro}.img" ; do if test -e "${dirname}/${i}" ; then initrd="$i" break @@ -282,40 +241,6 @@ fi done - # try to get the kernel config if $linux is a symlink - if test -z "${config}" ; then - lnk_version=`basename \`readlink -f $linux\` | sed -e "s,^[^0-9]*-,,g"` - if (test -n ${lnk_version} && test -e "${dirname}/config-${lnk_version}") ; then - config="${dirname}/config-${lnk_version}" - fi - fi - - # check if we are in xen domU - if [ ! -e /proc/xen/xsd_port -a -e /proc/xen ]; then - # we're running on xen domU guest - dmi=/sys/class/dmi/id - if [ -r "${dmi}/product_name" -a -r "${dmi}/sys_vendor" ]; then - product_name=`cat ${dmi}/product_name` - sys_vendor=`cat ${dmi}/sys_vendor` - if test "${sys_vendor}" = "Xen" -a "${product_name}" = "HVM domU"; then - # xen HVM guest - xen_pv_domU=false - fi - fi - else - # we're running on baremetal or xen dom0 - xen_pv_domU=false - fi - - if test "$xen_pv_domU" = "false" ; then - # prevent xen kernel without pv_opt support from booting - if (grep -qx "CONFIG_XEN=y" "${config}" 2> /dev/null && ! grep -qx "CONFIG_PARAVIRT=y" "${config}" 2> /dev/null); then - echo "Skip xenlinux kernel $linux" >&2 - list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '` - continue - fi - fi - initramfs= if test -n "${config}" ; then initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"` @@ -339,19 +264,29 @@ boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" fi # TRANSLATORS: %s is replaced with an OS name - echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' $(print_hotkey) \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {" - hotkey=$(incr_hotkey) + echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {" is_top_level=false fi linux_entry "${OS}" "${version}" advanced \ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" + + for i in "${initramfs_manjaro}-fallback.img" "initramfs-${version}-fallback.img" ; do + if test -e "${dirname}/${i}" ; then + initrd="${i}" + gettext_printf "Found initrd fallback image: %s\n" "${dirname}/${initrd}" >&2 + linux_entry "${OS}" "${version}" fallback \ + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" + break + fi + done + if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then linux_entry "${OS}" "${version}" recovery \ - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_RECOVERY}" + "single ${GRUB_CMDLINE_LINUX}" fi - list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '` + list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '` done # If at least one kernel was found, then we need to