From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Llt9d-0004Lo-8v for mharc-grub-devel@gnu.org; Mon, 23 Mar 2009 19:02:01 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Llt9b-0004LD-OF for grub-devel@gnu.org; Mon, 23 Mar 2009 19:01:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Llt9X-0004Jk-Aj for grub-devel@gnu.org; Mon, 23 Mar 2009 19:01:59 -0400 Received: from [199.232.76.173] (port=43733 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Llt9X-0004Jf-4m for grub-devel@gnu.org; Mon, 23 Mar 2009 19:01:55 -0400 Received: from c60.cesmail.net ([216.154.195.49]:21137) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1Llt9W-0004gy-It for grub-devel@gnu.org; Mon, 23 Mar 2009 19:01:54 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 23 Mar 2009 19:01:52 -0400 Received: from [192.168.0.22] (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by smtprelay2.cesmail.net (Postfix) with ESMTPSA id 238F634C6D for ; Mon, 23 Mar 2009 19:02:16 -0400 (EDT) From: Pavel Roskin To: The development of GRUB 2 In-Reply-To: <49C7F035.1090101@gmail.com> References: <49C7F035.1090101@gmail.com> Content-Type: text/plain Date: Mon, 23 Mar 2009 19:01:50 -0400 Message-Id: <1237849310.2783.43.camel@mj> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 (2.24.5-1.fc10) Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [Design] savedefault X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2009 23:01:59 -0000 On Mon, 2009-03-23 at 21:25 +0100, phcoder wrote: > Hello we had a discussion on IRC about implementing savedefault. We've > found 3 possible solutions: > 1) just add support for it in grub-mkimage in following way: > load_env > > menuentry "menu entry 1" { > default=0 > save_env > .... > } > menuentry "menu entry 2" { > default=1 > save_env > .... > } > > This method has disadvantage of the necessity of counting entries in > grub-mkconfig. This is easily broken OS-specific script count entries > wrong. Also it breaks if user adds entries manually in the middle of the > file I agree. Configuration files should be easily editable. > 2) Export a variable selected_menu. Then syntax would be sth like > load_env > > menuentry "menu entry 1" { > default=$selected_menu > save_env Maybe we could have an option for save_env to specify the target name so that it could be done in one operation, e.g. save_env --as default $selected_menu Another approach would be to change the "default" variable in the menu rather than "selected_menu". The original "default" could be saved in the common part if necessary. In any case, I think it's better to save the "default" variable only rather than the whole environment. > 3) Add label support syntax would be sth like: > default=ubuntu > menuentry --label ubuntu "Ubuntu" { > .... > } > And for savedefault it would be something like > load_env > menuentry --label linux_ "Linux" { > default=linux_ > save_env > .... > } That's a good idea. Actually, we could export "selected_menu" or "default" in this case as well to avoid extra statements. The good thing about textual default is that it won't change if new entries are added. I don't think we really need labels. The entry names can be used as labels. They will be unique most of the time. And if they are not, the wrong default won't add much to the preexisting confusion. Here's a far-flung idea. We could use "classes" rather than labels for advanced configuration. Classes won't be unique. For instance, all Fedora entries could have class "fedora". Selecting any Fedora kernel would make the first entry of the "fedora" class load by default. If another Fedora kernel is installed, the latest kernel would load. But if an entry of the "ubuntu" class is selected, the first entry of the "ubuntu" class would be the default. menuentry --class fedora "Fedora Linux 2.6.28.1-195" { save_env --as default selected_class ... } menuentry --class fedora "Fedora Linux 2.6.28-177" { save_env --as default selected_class ... } menuentry --class ubuntu "Ubuntu Linux 2.6.27-5" { save_env --as default selected_class ... } menuentry --class ubuntu "Ubuntu Linux 2.6.27-2" { save_env --as default selected_class ... } menuentry --class windows "Windows XP" { save_env --as default selected_class ... } menuentry --class windows "Windows XP safe mode" { save_env --as default selected_class ... } menuentry "FreeBSD" { # classless entry save_env --as default selected_menu ... } menuentry "memtest86" { # no save_env ... } -- Regards, Pavel Roskin