summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdraklive2158
1 files changed, 114 insertions, 44 deletions
diff --git a/draklive2 b/draklive2
index 0d2d76a..8ffea11 100755
--- a/draklive2
+++ b/draklive2
@@ -471,17 +471,38 @@ sub create_bootloader {
}
my $add_lang_menu = defined $live->{media}{bootloader_langs};
+ my $add_kbd_menu = defined $live->{media}{bootloader_kbds};
if ($add_lang_menu) {
my $lang_names = get_absolute_path($live, $live->{media}{bootloader_langs});
- -e $lang_names or die "cannot find bootloader language file $lang_names\n";
- my @langs = eval(cat_($lang_names)) or die "error in language name file $lang_names\n";
- MDK::Common::File::output_utf8($grub2_dir . '/lang-menu.cfg', build_lang_menu_cfg(@langs));
+ -e $lang_names or die "cannot find bootloader language name file $lang_names\n";
+ my @langs = group_by2(eval(cat_($lang_names))) or die "error in language name file $lang_names\n";
- my $locale_dir = $grub2_dir . '/locale';
- mkdir_p($locale_dir);
+ my $lang_kbds = dirname($lang_names) . '/lang-kbds.txt';
+ my $kbds;
+ if ($add_kbd_menu && -e $lang_kbds) {
+ $kbds = eval(cat_($lang_kbds)) or die "error in language keyboard file $lang_kbds\n";
+ }
+
+ MDK::Common::File::output_utf8($grub2_dir . '/lang-menu.cfg', build_lang_menu_cfg(\@langs, %$kbds));
+ }
+
+ if ($add_kbd_menu) {
+ my $kbd_names = get_absolute_path($live, $live->{media}{bootloader_kbds});
+ -e $kbd_names or die "cannot find bootloader keyboard name file $kbd_names\n";
+ my @kbds = group_by2(eval(cat_($kbd_names))) or die "error in language name file $kbd_names\n";
+
+ my $layouts = dirname($kbd_names) . '/layouts';
+ -d $layouts or die "cannot find bootloader keyboard map directory $layouts\n";
+ cp_f($layouts, $grub2_dir);
+
+ MDK::Common::File::output_utf8($grub2_dir . '/kbd-menu.cfg', build_kbd_menu_cfg(\@kbds));
+ }
- my $messages = get_absolute_path($live, $live->{media}{bootloader_messages});
+ my $messages = get_absolute_path($live, $live->{media}{bootloader_messages});
+ if (defined $messages) {
-d $messages or die "cannot find bootloader messages directory $messages\n";
+ my $locale_dir = $grub2_dir . '/locale';
+ mkdir_p($locale_dir);
cp_f(glob($messages . '/*.mo'), $locale_dir);
}
@@ -502,7 +523,7 @@ sub create_bootloader {
cp_f($grub_cfg_template, $grub2_cfg);
run_("sed", "-i", "s/VOLUME_LABEL/$label/g", $grub2_cfg);
} else {
- output($grub2_cfg, build_grub2_cfg($live, $theme_name, \@theme_fonts, $add_lang_menu));
+ output($grub2_cfg, build_grub2_cfg($live, $theme_name, \@theme_fonts, $add_lang_menu, $add_kbd_menu));
}
my $title = $label =~ s/-/ /gr;
@@ -547,7 +568,7 @@ sub build_grub2_eltorito_img {
my ($live, $output) = @_;
my @modules = qw(biosdisk iso9660 fat part_msdos all_video font png gfxterm gfxmenu linux
- configfile echo gettext ls search test);
+ keylayouts at_keyboard usb_keyboard configfile echo gettext ls search test);
run_('grub2-mkimage',
'--output', $output,
@@ -561,7 +582,7 @@ sub build_grub2_bootx64_efi {
my ($live, $output) = @_;
my @modules = qw(iso9660 fat part_msdos all_video font png gfxterm gfxmenu linux
- configfile echo gettext ls search test);
+ keylayouts at_keyboard usb_keyboard configfile echo gettext ls search test);
run_('grub2-mkimage',
'--output', $output,
@@ -572,53 +593,53 @@ sub build_grub2_bootx64_efi {
}
sub build_grub2_cfg {
- my ($live, $theme_name, $theme_fonts, $add_lang_menu) = @_;
+ my ($live, $theme_name, $theme_fonts, $add_lang_menu, $add_kbd_menu) = @_;
my @loadfonts;
if (defined $theme_name) {
- @loadfonts = map { "loadfont \$prefix/themes/$theme_name/$_" } @$theme_fonts;
+ @loadfonts = map { " loadfont \$prefix/themes/$theme_name/$_" } @$theme_fonts;
}
- my @langs = get_langs($live);
- my $default_lang = $langs[0] || 'en_US';
my $gettext = $add_lang_menu ? '$' : '';
my $boot_dir = $live->get_media_prefix('boot');
join("\n",
- "search --no-floppy --set=root -l '" . $live->{media}->get_media_label . "'",
- "set prefix=(\$root)" . $live->get_media_prefix('boot') . "/grub2",
+ "if [ -z \$initialised ] ; then",
+ " search --no-floppy --set=root -l '" . $live->{media}->get_media_label . "'",
+ " set prefix=(\$root)" . $live->get_media_prefix('boot') . "/grub2",
"",
- "if loadfont \$prefix/fonts/unicode.pf2 ; then",
- " set gfxmode=1024x768,800x600,auto",
- " set gfxpayload=keep",
- " terminal_output gfxterm",
- "fi",
+ " if loadfont \$prefix/fonts/unicode.pf2 ; then",
+ " set gfxmode=1024x768,800x600,auto",
+ " set gfxpayload=keep",
+ " terminal_output gfxterm",
+ " fi",
+ if_($theme_name,
"",
- if_($theme_name,
- "if [ x\$uefi == 'xtrue' ] ; then",
- " set theme=\$prefix/themes/$theme_name/theme-uefi.txt",
- "else",
- " set theme=\$prefix/themes/$theme_name/theme.txt",
- "fi",
- "export theme",
- @loadfonts,
- ),
+ " if [ x\$uefi == 'xtrue' ] ; then",
+ " set theme=\$prefix/themes/$theme_name/theme-uefi.txt",
+ " else",
+ " set theme=\$prefix/themes/$theme_name/theme.txt",
+ " fi",
+ " export theme",
+ @loadfonts,
+ ),
+ " set initialised=true",
+ " export initialised",
+ "fi",
"",
"set default=" . get_bootloader_default($live),
"set timeout=" . get_bootloader_timeout($live),
"",
- if_($add_lang_menu,
- "if [ -z \$lang ] ; then",
- " set lang=$default_lang",
- "fi",
- "export lang",
- "",
- "submenu $gettext\"Language [\$lang]\" {",
- " source \$prefix/lang-menu.cfg",
- "}",
- "",
- ),
+ if_($add_lang_menu,
+ "export lang",
+ "export lkbd",
+ "",
+ ),
+ if_($add_kbd_menu,
+ "export kbd",
+ "",
+ ),
(map {
my ($name, $cmdline) = @$_;
join("\n",
@@ -628,6 +649,22 @@ sub build_grub2_cfg {
"}"
);
} group_by2(@{$live->{media}{bootloader_entries}})),
+ if_($add_lang_menu || $add_kbd_menu,
+ # this acts as a spacer
+ "menuentry '________________________' {",
+ " set dummy=true",
+ "}",
+ ),
+ if_($add_lang_menu,
+ "submenu \"F2: \"$gettext\"Language [\$lang]\" --id language --hotkey f2 {",
+ " source \$prefix/lang-menu.cfg",
+ "}",
+ ),
+ if_($add_kbd_menu,
+ "submenu \"F3: \"$gettext\"Keyboard [\$kbd]\" --id keyboard --hotkey f3 {",
+ " source \$prefix/kbd-menu.cfg",
+ "}",
+ ),
"",
);
}
@@ -647,7 +684,7 @@ sub get_default_append {
my $append = $live->{system}{append};
join(" ",
"root=mgalive:LABEL=" . $live->{media}->get_media_label,
- "lang=\$lang",
+ "lang=\$lang kbd=\$kbd",
if_($append, $append),
if_($live->{system}{vga_mode} && $append !~ /\bvga=\b/,
"vga=" . $live->{system}{vga_mode}),
@@ -655,20 +692,53 @@ sub get_default_append {
}
sub build_lang_menu_cfg {
- my ($langs) = @_;
+ my ($langs, %kbds) = @_;
join("\n",
"function set_language {",
" set lang=\$1",
+ " set lkbd=\$2",
" configfile \$prefix/grub.cfg",
"}",
"",
"set default=\$lang",
"set timeout=-1",
"",
+ "menuentry \$\"[more options after boot]\" { set_language '' '' }",
+ (map {
+ my ($id, $name) = @$_;
+ my $kbd = $kbds{$id};
+ "menuentry '$name' --id $id { set_language $id $kbd }";
+ } (@$langs)),
+ "",
+ );
+}
+
+sub build_kbd_menu_cfg {
+ my ($kbds) = @_;
+ join("\n",
+ "function set_keyboard {",
+ " if [ -z \$kbd ] ; then",
+ " terminal_input at_keyboard",
+ " fi",
+ " set kbd=\$1",
+ " set lkbd=",
+ " keymap \$prefix/layouts/\$kbd.gkb",
+ " configfile \$prefix/grub.cfg",
+ "}",
+ "",
+ "if [ -z \$kbd ] ; then",
+ " set default=\$lkbd",
+ "else",
+ " set default=\$kbd",
+ "fi",
+ "",
+ "set timeout=-1",
+ "",
(map {
my ($id, $name) = @$_;
- "menuentry '$name' --id $id { set_language $id }";
- } group_by2(@$langs)),
+ $name =~ s/"/\\"/g;
+ "menuentry \$\"$name\" --id $id { set_keyboard $id }";
+ } (@$kbds)),
"",
);
}