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_<random id> "Linux" { > default=linux_<random id> > 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 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel