From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1S3s6P-0006Jb-1v for mharc-grub-devel@gnu.org; Sat, 03 Mar 2012 11:46:37 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3s63-0006I2-FA for grub-devel@gnu.org; Sat, 03 Mar 2012 11:46:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S3s60-00079X-Ds for grub-devel@gnu.org; Sat, 03 Mar 2012 11:46:15 -0500 Received: from mail-ey0-f169.google.com ([209.85.215.169]:61658) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3s5z-00079H-V6 for grub-devel@gnu.org; Sat, 03 Mar 2012 11:46:12 -0500 Received: by eaal1 with SMTP id l1so981700eaa.0 for ; Sat, 03 Mar 2012 08:46:10 -0800 (PST) Received-SPF: pass (google.com: domain of phcoder@gmail.com designates 10.213.32.2 as permitted sender) client-ip=10.213.32.2; Authentication-Results: mr.google.com; spf=pass (google.com: domain of phcoder@gmail.com designates 10.213.32.2 as permitted sender) smtp.mail=phcoder@gmail.com; dkim=pass header.i=phcoder@gmail.com Received: from mr.google.com ([10.213.32.2]) by 10.213.32.2 with SMTP id a2mr1946126ebd.39.1330793170043 (num_hops = 1); Sat, 03 Mar 2012 08:46:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=6j6N1KpjzccQen5SnWrR3sk7ShqkEPUxkCFRzFYyLqs=; b=C1eyy4suO6qx6W3vQT0zVkhaTdPCo2VK5JSvpcMV98f5a5uyj6AD0W2az/RmGG5s6b QZO5NRf7eoLmr8Y9L1uc/F0utzkExd17Dp2iK9ZeGIzgjgaW2Uy+H5fo9Xk4bOORgU4X dv3Y6lGrCHRP3GiUH/zd+3b0OCKE3tZo+Xh5QeXCPaQKkD5Onj5NCN2PBmDOxap94V8L 6a7IKT/TEGLxLtdyDglYHoxnEvSsmcU7NpLkBNNCrSNah68QZ761vm14bKPzRjMXDPvf K2ny2j9/4wYHdEV0kRmtYzeLfgb1cjpAvVokKw2Poms3+7wdhMrBnBSeQyl2z5BBTHp1 Gusg== Received: by 10.213.32.2 with SMTP id a2mr1490663ebd.39.1330793169968; Sat, 03 Mar 2012 08:46:09 -0800 (PST) Received: from debian.x201.phnet (103-234.197-178.cust.bluewin.ch. [178.197.234.103]) by mx.google.com with ESMTPS id n53sm3257166eea.9.2012.03.03.08.46.07 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 03 Mar 2012 08:46:08 -0800 (PST) Message-ID: <4F524ACD.1090507@gmail.com> Date: Sat, 03 Mar 2012 17:46:05 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20120216 Icedove/8.0 MIME-Version: 1.0 To: The development of GNU GRUB , Colin Watson Subject: Re: [PATCH] Add submenu support to 10_linux (grub-mkconfig) References: <4F4C117D.5090800@gmail.com> <4F4DC13F.3030402@gmail.com> <4F5228C0.2020409@gmail.com> <4F522DA1.4020705@gmail.com> In-Reply-To: <4F522DA1.4020705@gmail.com> Content-Type: multipart/mixed; boundary="------------020401030303000706040205" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.215.169 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Mar 2012 16:46:35 -0000 This is a multi-part message in MIME format. --------------020401030303000706040205 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Update On 03.03.2012 15:41, Vladimir 'φ-coder/phcoder' Serbinenko wrote: > >> Right now I believe that (1) is the most reasonable >> > Somethine like in the attached patch. I haven't tested it yet in real > migration scenario though > > > -- Regards Vladimir 'φ-coder/phcoder' Serbinenko --------------020401030303000706040205 Content-Type: text/x-diff; name="menu.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="menu.diff" === modified file 'util/grub-mkconfig.in' --- util/grub-mkconfig.in 2012-03-03 12:05:08 +0000 +++ util/grub-mkconfig.in 2012-03-03 14:39:52 +0000 @@ -40,6 +40,7 @@ self=`basename $0` grub_probe="${sbindir}/`echo grub-probe | sed "${transform}"`" +grub_editenv="${bindir}/`echo grub-editenv | sed "${transform}"`" grub_script_check="${bindir}/`echo grub-script-check | sed "${transform}"`" export TEXTDOMAIN=@PACKAGE@ @@ -165,6 +166,11 @@ esac done +GRUB_ACTUAL_DEFAULT="$GRUB_DEFAULT" + +if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub_editenv}" - list | sed -n '/^saved_entry=/ s,^saved_entry=,,p'`" ; fi + + # These are defined in this script, export them here so that user can # override them. export GRUB_DEVICE \ @@ -173,7 +179,8 @@ GRUB_DEVICE_BOOT_UUID \ GRUB_FS \ GRUB_FONT \ - GRUB_PRELOAD_MODULES + GRUB_PRELOAD_MODULES \ + GRUB_ACTUAL_DEFAULT # These are optional, user-defined variables. export GRUB_DEFAULT \ === modified file 'util/grub-mkconfig_lib.in' --- util/grub-mkconfig_lib.in 2012-03-03 12:12:41 +0000 +++ util/grub-mkconfig_lib.in 2012-03-03 16:21:25 +0000 @@ -249,7 +249,7 @@ gettext_printf () { gettext_printf_format="$1" shift - printf "$(gettext_quoted "$gettext_printf_format")" "$@" + printf "$(gettext "$gettext_printf_format")" "$@" } uses_abstraction () { === modified file 'util/grub.d/10_linux.in' --- util/grub.d/10_linux.in 2012-03-03 12:12:41 +0000 +++ util/grub.d/10_linux.in 2012-03-03 16:42:34 +0000 @@ -66,77 +66,81 @@ GRUB_CMDLINE_LINUX="boot=zfs rpool=${RPOOL} bootfs=${RPOOL}${bootfs} ${cmdline} ${GRUB_CMDLINE_LINUX}";; esac +title_correction_code= + linux_entry () { os="$1" version="$2" - recovery="$3" + type="$3" args="$4" - if ${recovery} ; then - title="$(gettext_quoted "%s, with Linux %s (recovery mode)")" - else - title="$(gettext_quoted "%s, with Linux %s")" - fi + if [ -z "$boot_device_id" ]; then boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" fi - printf "menuentry '${title}' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$recovery-$boot_device_id' {\n" "${os}" "${version}" - if ! ${recovery} ; then + if [ x$type != xsimple ] ; then + case $type in + recovery) + title="$(gettext_printf "%s, with Linux %s (recovery mode)" "${os}" "${version}")" ;; + *) + title="$(gettext_printf "%s, with Linux %s" "${os}" "${version}")" ;; + esac + replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')" + if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then + quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | sed "s/'/'\\\\\\\\''/g")" + title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | sed "s/'/'\\\\\\\\''/g")'; 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} | sed "s/'/'\\\\\\\\''/g")' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" + else + echo "menuentry '$(echo ${os} | sed "s/'/'\\\\\\\\''/g")' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" + fi + if [ x$type != xrecovery ] ; then save_default_entry | sed -e "s/^/\t/" fi # Use ELILO's generic "efifb" when it's known to be available. # FIXME: We need an interface to select vesafb in case efifb can't be used. if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then - cat << EOF - load_video -EOF + echo " load_video" | sed "s/^/$submenu_indentation/" if grep -qx "CONFIG_FB_EFI=y" "${config}" 2> /dev/null \ && grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" "${config}" 2> /dev/null; then - cat << EOF - set gfxpayload=keep -EOF + echo " set gfxpayload=keep" | sed "s/^/$submenu_indentation/" fi else if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then - cat << EOF - load_video -EOF + echo " load_video" | sed "s/^/$submenu_indentation/" fi - cat << EOF - set gfxpayload=$GRUB_GFXPAYLOAD_LINUX -EOF + echo " set gfxpayload=$GRUB_GFXPAYLOAD_LINUX" | sed "s/^/$submenu_indentation/" fi - cat << EOF - insmod gzio -EOF + echo " insmod gzio" | sed "s/^/$submenu_indentation/" if [ x$dirname = x/ ]; then if [ -z "${prepare_root_cache}" ]; then prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/")" fi - printf '%s\n' "${prepare_root_cache}" + printf '%s\n' "${prepare_root_cache}" | sed "s/^/$submenu_indentation/" else if [ -z "${prepare_boot_cache}" ]; then prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" fi - printf '%s\n' "${prepare_boot_cache}" + printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" fi message="$(gettext_printf "Loading Linux %s ..." ${version})" - cat << EOF + sed "s/^/$submenu_indentation/" << EOF echo '$message' linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then # TRANSLATORS: ramdisk isn't identifier. Should be translated. message="$(gettext_printf "Loading initial ramdisk ...")" - cat << EOF + sed "s/^/$submenu_indentation/" << EOF echo '$message' initrd ${rel_dirname}/${initrd} EOF fi - cat << EOF + sed "s/^/$submenu_indentation/" << EOF } EOF } @@ -155,7 +159,13 @@ prepare_boot_cache= prepare_root_cache= boot_device_id= - +title_correction_code= + +# Extra indentation to add to menu entries in a submenu. We're not in a submenu +# yet, so it's empty. In a submenu it will be equal to '\t' (one tab). +submenu_indentation="" + +is_first_entry=true while [ "x$list" != "x" ] ; do linux=`version_find_latest $list` gettext_printf "Found linux image: %s\n" "$linux" >&2 @@ -200,12 +210,36 @@ linux_root_device_thisversion=${GRUB_DEVICE} fi - linux_entry "${OS}" "${version}" false \ - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" + if [ "x$is_first_entry" = xtrue ]; then + linux_entry "${OS}" "${version}" simple \ + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" + + submenu_indentation="\t" + + if [ -z "$boot_device_id" ]; then + boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" + fi + cat << EOF +submenu '$(gettext_quoted "Advanced options for ${OS}")' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' { +EOF + fi + + linux_entry "${OS}" "${version}" advanced \ + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then - linux_entry "${OS}" "${version}" true \ - "single ${GRUB_CMDLINE_LINUX}" + linux_entry "${OS}" "${version}" recovery \ + "single ${GRUB_CMDLINE_LINUX}" \ + | sed "s/^/$submenu_indentation/" fi list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '` + is_first_entry=false done + +# If at least one kernel was found, then we need to +# add a closing '}' for the submenu command. +if [ x"$is_first_entry" != xtrue ]; then + echo '}' +fi + +echo "$title_correction_code" --------------020401030303000706040205--