From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1S2ck0-0007mZ-Qc for mharc-grub-devel@gnu.org; Wed, 29 Feb 2012 01:10:20 -0500 Received: from eggs.gnu.org ([208.118.235.92]:43777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2cjx-0007lI-DA for grub-devel@gnu.org; Wed, 29 Feb 2012 01:10:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S2cjr-0002fa-6L for grub-devel@gnu.org; Wed, 29 Feb 2012 01:10:16 -0500 Received: from mail-pw0-f41.google.com ([209.85.160.41]:43297) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S2cjq-0002e2-TW for grub-devel@gnu.org; Wed, 29 Feb 2012 01:10:11 -0500 Received: by pbbro12 with SMTP id ro12so370389pbb.0 for ; Tue, 28 Feb 2012 22:10:08 -0800 (PST) Received-SPF: pass (google.com: domain of jordan.uggla@gmail.com designates 10.68.227.228 as permitted sender) client-ip=10.68.227.228; Authentication-Results: mr.google.com; spf=pass (google.com: domain of jordan.uggla@gmail.com designates 10.68.227.228 as permitted sender) smtp.mail=jordan.uggla@gmail.com; dkim=pass header.i=jordan.uggla@gmail.com Received: from mr.google.com ([10.68.227.228]) by 10.68.227.228 with SMTP id sd4mr2440953pbc.33.1330495808014 (num_hops = 1); Tue, 28 Feb 2012 22:10:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=IezPdEYBV98FshlOFynYO+LkNpsznICiXdxErYoGALQ=; b=PEBg7JOcX+CfTwPoCwFk3hNdLtNWYNjclpABrZWU+t4dKLcqDZ+HZhptghfJUkoCqB 0AyDlzucFcSdzx7tgnsrkVP6PdpqIcJNSieIpxpnzFED0Rzu8mUD7Abh7exvsMDoXAVa ISaN6/cw+Crin4RA7b49URBFEqpTWX8PQ09Oo= Received: by 10.68.227.228 with SMTP id sd4mr2051344pbc.33.1330495807957; Tue, 28 Feb 2012 22:10:07 -0800 (PST) Received: from [192.168.1.2] ([216.57.70.194]) by mx.google.com with ESMTPS id 4sm7147743pbp.76.2012.02.28.22.10.06 (version=SSLv3 cipher=OTHER); Tue, 28 Feb 2012 22:10:07 -0800 (PST) Message-ID: <4F4DC13F.3030402@gmail.com> Date: Tue, 28 Feb 2012 22:10:07 -0800 From: Jordan Uggla User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120217 Thunderbird/11.0 MIME-Version: 1.0 To: Jordan Uggla Subject: Re: [PATCH] Add submenu support to 10_linux (grub-mkconfig) References: <4F4C117D.5090800@gmail.com> In-Reply-To: <4F4C117D.5090800@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.41 Cc: The development of GNU GRUB , cjwatson@ubuntu.com 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: Wed, 29 Feb 2012 06:10:19 -0000 In my first patch I rather stupidly asked gettext for a translation of "%s". Updated patch below does not have this mistake. -- Jordan Uggla (Jordan_U on irc.freenode.net) === modified file 'util/grub-mkconfig.in' --- util/grub-mkconfig.in 2012-02-26 17:37:54 +0000 +++ util/grub-mkconfig.in 2012-02-27 08:22:48 +0000 @@ -206,7 +206,8 @@ GRUB_INIT_TUNE \ GRUB_SAVEDEFAULT \ GRUB_ENABLE_CRYPTODISK \ - GRUB_BADRAM + GRUB_BADRAM \ + GRUB_ENABLE_SUBMENUS if test "x${grub_cfg}" != "x"; then rm -f "${grub_cfg}.new" === modified file 'util/grub.d/10_linux.in' --- util/grub.d/10_linux.in 2012-02-26 16:28:05 +0000 +++ util/grub.d/10_linux.in 2012-02-29 03:03:01 +0000 @@ -63,15 +63,25 @@ { os="$1" version="$2" - recovery="$3" + type="$3" args="$4" - if ${recovery} ; then - title="$(gettext_quoted "%s, with Linux %s (recovery mode)")" + + case $type in + simple) + title="%s" ;; + recovery) + title="$(gettext_quoted "%s, with Linux %s (recovery mode)")" ;; + *) + title="$(gettext_quoted "%s, with Linux %s")" ;; + esac + + if [ "x$type" = "xsimple" ]; then + printf "menuentry '${title}' ${CLASS} {\n" "${os}" else - title="$(gettext_quoted "%s, with Linux %s")" + printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}" fi - printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}" - if ! ${recovery} ; then + + if [ x$type != xrecovery ] ; then save_default_entry | sed -e "s/^/\t/" fi @@ -145,6 +155,11 @@ prepare_boot_cache= prepare_root_cache= +# 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 @@ -189,12 +204,32 @@ linux_root_device_thisversion=${GRUB_DEVICE} fi - linux_entry "${OS}" "${version}" false \ - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" + if [ "x$GRUB_ENABLE_SUBMENUS" = xtrue -a "x$is_first_entry" = xtrue ]; then + linux_entry "${OS}" "${version}" simple \ + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" + + submenu_indentation="\t" + + cat << EOF +submenu '$(gettext_quoted "Advanced options for ${OS}")' { +EOF + fi + + linux_entry "${OS}" "${version}" advanced \ + "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" \ + | sed "s/^/$submenu_indentation/" 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 submenus are enabled, and at least one kernel was found, then we need to +# add a closing '}' for the submenu command. +if [ x"$GRUB_ENABLE_SUBMENUS" = xtrue -a x"$is_first_entry" != xtrue ]; then + echo '}' +fi