diff options
-rwxr-xr-x | draklive2 | 81 |
1 files changed, 31 insertions, 50 deletions
@@ -445,20 +445,29 @@ sub create_bootloader { my $grub2_dir = $boot_dir . '/grub2'; mkdir_p($grub2_dir); - my $fonts_dir = $grub2_dir . '/fonts'; - mkdir_p($fonts_dir); - - my $font = $root . '/usr/share/grub/unicode.pf2'; - cp_f($font, $fonts_dir) if -e $font; - - my $themes_dir = $grub2_dir . '/themes'; - mkdir_p($themes_dir); + my $font = get_absolute_path($live, $live->{media}{bootloader_font}); + if (defined $font) { + -e $font or die "cannot find bootloader font $font\n"; + } else { + $font = '/usr/share/grub/unicode.pf2'; + } + if (-e $font) { + my $fonts_dir = $grub2_dir . '/fonts'; + mkdir_p($fonts_dir); + cp_f($font, $fonts_dir); + } - my $theme_name = $live->{media}{bootloader_theme}; + my $theme = get_absolute_path($live, $live->{media}{bootloader_theme}); + if (defined $theme) { + -d $theme or die "cannot find bootloader theme $theme\n"; + } else { + $theme = '/boot/grub2/themes/maggy'; + } + my $theme_name = basename($theme); my @theme_fonts; - if (defined $theme_name) { - my $theme = $root . '/boot/grub2/themes/' . $theme_name; - -e $theme or die "cannot find grub2 $theme_name theme\n"; + if (-d $theme) { + my $themes_dir = $grub2_dir . '/themes'; + mkdir_p($themes_dir); cp_f($theme, $themes_dir); @theme_fonts = map { basename($_) } glob("$theme/*.pf2"); } @@ -483,7 +492,7 @@ sub create_bootloader { -e $eltorito_img or die "cannot find grub2 Eltorito boot image $eltorito_img\n"; cp_f($eltorito_img, $grub2_dir . '/eltorito.img'); } else { - build_grub2_eltorito_img($live, $grub2_dir); + build_grub2_eltorito_img($live, $grub2_dir . '/eltorito.img'); } my $label = $live->{media}->get_media_label; @@ -502,7 +511,7 @@ sub create_bootloader { $title =~ s/-/ /gr; my $base_theme_txt = $grub2_dir . "/themes/$theme_name/theme.txt"; - if (defined $theme_name && -e $base_theme_txt) { + if (-e $base_theme_txt) { run_('sed', '-i', qq(s/title-text:.*/title-text: "$title"/), $base_theme_txt); } @@ -517,12 +526,12 @@ sub create_bootloader { -e $bootx64_efi or die "cannot find grub2 EFI boot image $bootx64_efi\n"; cp_f($bootx64_efi, $efi_boot_dir . '/bootx64.efi'); } else { - build_grub2_bootx64_efi($live, $efi_boot_dir); + build_grub2_bootx64_efi($live, $efi_boot_dir . '/bootx64.efi'); } output($efi_boot_dir . '/grub.cfg', build_uefi_grub2_cfg($live)); - if (defined $theme_name && -e $base_theme_txt) { + if (-e $base_theme_txt) { my $uefi_theme_txt = $grub2_dir . "/themes/$theme_name/theme-uefi.txt"; cp_f($base_theme_txt, $uefi_theme_txt); run_('sed', '-i', qq(s/title-text:.*/title-text: "$title (UEFI)"/), $uefi_theme_txt); @@ -538,49 +547,31 @@ sub create_bootloader { } sub build_grub2_eltorito_img { - my ($live, $dest_dir) = @_; - - # temporary hack to workaround grub2/grub2-efi conflict - run_({ root => $live->get_system_root }, 'urpmi', '-q', '--force', 'grub2'); + my ($live, $output) = @_; my @modules = qw(biosdisk iso9660 fat part_msdos all_video font png gfxterm gfxmenu linux configfile echo gettext ls search test); - my $output = '/boot/grub2/eltorito.img'; - run_({ root => $live->get_system_root }, 'grub2-mkimage', + run_('grub2-mkimage', '--output', $output, '--prefix', $live->get_media_prefix('boot') . '/grub2', '--format', 'i386-pc-eltorito', @modules ); - - mv($live->get_system_root . $output, $dest_dir) or die "cannot move eltorito.img: $!\n"; - - # temporary hack to workaround grub2/grub2-efi conflict - run_({ root => $live->get_system_root }, 'rpm', '-e', '--nodeps', 'grub2'); } sub build_grub2_bootx64_efi { - my ($live, $dest_dir) = @_; - - # temporary hack to workaround grub2/grub2-efi conflict - run_({ root => $live->get_system_root }, 'urpmi', '-q', '--force', 'grub2-efi'); + my ($live, $output) = @_; my @modules = qw(iso9660 fat part_msdos all_video font png gfxterm gfxmenu linux configfile echo gettext ls search test); - my $output = '/boot/grub2/bootx64.efi'; - run_({ root => $live->get_system_root }, 'grub2-mkimage', + run_('grub2-mkimage', '--output', $output, '--prefix', $live->get_media_prefix('EFI') . '/BOOT', '--format', 'x86_64-efi', @modules ); - - mv($live->get_system_root . $output, $dest_dir) or die "cannot move bootx64.efi: $!\n"; - - # temporary hack to workaround grub2/grub2-efi conflict - run_({ root => $live->get_system_root }, 'rpm', '-e', '--nodeps', 'grub2-efi'); } sub build_grub2_cfg { @@ -717,18 +708,8 @@ sub create_iso_master { my $label = $live->{media}->get_media_label or die "the source device must be described by a label\n"; - my $mbr_image = get_absolute_path($live, $live->{media}{mbr_boot_img}); - if (!defined $mbr_image) { - $mbr_image = $live->get_system_root . '/usr/lib/grub/i386-pc/boot_hybrid.img'; - - # temporary hack to workaround grub2/grub2-efi conflict - my $images_dir = $live->get_builddir . $live->{prefix}{build}{images}; - mkdir_p($images_dir); - run_({ root => $live->get_system_root }, 'urpmi', '-q', '--force', 'grub2'); - cp_f($mbr_image, $images_dir . '/mbr_boot.img'); - run_({ root => $live->get_system_root }, 'rpm', '-e', '--nodeps', 'grub2'); - $mbr_image = $images_dir . '/mbr_boot.img'; - } + my $mbr_image = get_absolute_path($live, $live->{media}{mbr_boot_img}) // '/usr/lib/grub/i386-pc/boot_hybrid.img'; + -e $mbr_image or die "cannot find MBR boot image $mbr_image\n"; my $esp_image = $live->get_builddir . $live->{prefix}{build}{images} . '/esp.img'; |