summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2017-11-29 17:52:30 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2017-11-29 18:11:33 +0000
commit86ab49fcdbfe8a9a8a02f37c286cd90c8693c2bb (patch)
tree164b1eeb0807749ae5020de192eb44a4116d9a68
parent9f6bcca4f004606e29e63d6162029f80297732c8 (diff)
downloaddrakiso-86ab49fcdbfe8a9a8a02f37c286cd90c8693c2bb.tar
drakiso-86ab49fcdbfe8a9a8a02f37c286cd90c8693c2bb.tar.gz
drakiso-86ab49fcdbfe8a9a8a02f37c286cd90c8693c2bb.tar.bz2
drakiso-86ab49fcdbfe8a9a8a02f37c286cd90c8693c2bb.tar.xz
drakiso-86ab49fcdbfe8a9a8a02f37c286cd90c8693c2bb.zip
draklive2: build grub2 images if they are not supplied by the user.
-rwxr-xr-xdraklive289
1 files changed, 81 insertions, 8 deletions
diff --git a/draklive2 b/draklive2
index 18e1a06..bad49ee 100755
--- a/draklive2
+++ b/draklive2
@@ -66,6 +66,15 @@ sub umount_external_fs {
eval { fs::mount::umount($live->get_system_root . $_) } foreach map { "/mnt/$_" } all($live->get_system_root . "/mnt");
}
+sub get_absolute_path {
+ my ($live, $path) = @_;
+ if (defined $path && substr($path, 0, 1) ne '/') {
+ $live->{settings}{config_root} . '/' . $path;
+ } else {
+ $path;
+ }
+}
+
###############################################################################
# Install Phase
###############################################################################
@@ -454,9 +463,13 @@ sub create_bootloader {
@theme_fonts = map { basename($_) } glob("$theme/*.pf2");
}
- my $eltorito_img = $live->{settings}{config_root} . '/' . $live->{media}{eltorito_img};
- -e $eltorito_img or die "cannot find grub2 eltorito.img $eltorito_img\n";
- cp_f($eltorito_img, $grub2_dir . '/eltorito.img');
+ my $eltorito_img = get_absolute_path($live, $live->{media}{eltorito_img});
+ if (defined $eltorito_img) {
+ -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);
+ }
my $label = $live->{media}->get_media_label;
@@ -478,14 +491,17 @@ sub create_bootloader {
return if $live->{settings}{arch} ne 'x86_64';
- my $bootx64_efi = $live->{settings}{config_root} . '/' . $live->{media}{bootx64_efi};
- -e $bootx64_efi or die "cannot find grub2 bootx64.efi $bootx64_efi\n";
-
my $efi_root_dir = $live->get_builddir . $live->{prefix}{build}{EFI};
my $efi_boot_dir = $efi_root_dir . '/BOOT';
mkdir_p($efi_boot_dir);
- cp_f($bootx64_efi, $efi_boot_dir);
+ my $bootx64_efi = get_absolute_path($live, $live->{media}{bootx64_efi});
+ if (defined $bootx64_efi) {
+ -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);
+ }
output($efi_boot_dir . '/grub.cfg', build_uefi_grub2_cfg($live));
@@ -504,6 +520,52 @@ sub create_bootloader {
run_("mcopy", "-s", "-i", $esp_image, $efi_root_dir, "::");
}
+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 @modules = qw(biosdisk iso9660 fat part_msdos all_video font png gfxterm gfxmenu linux configfile
+ echo ls search test);
+ my $output = '/boot/grub2/eltorito.img';
+
+ run_({ root => $live->get_system_root }, '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 @modules = qw(iso9660 fat part_msdos all_video font png gfxterm gfxmenu linux configfile
+ echo ls search test);
+ my $output = '/boot/grub2/bootx64.efi';
+
+ run_({ root => $live->get_system_root }, '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 {
my ($live, $theme_name, $theme_fonts) = @_;
@@ -604,7 +666,18 @@ 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 = $live->{settings}{config_root} . '/' . $live->{media}{mbr_boot_img};
+ 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 $esp_image = $live->get_builddir . $live->{prefix}{build}{images} . '/esp.img';