diff options
author | Olivier Blin <oblin@mandriva.com> | 2008-11-12 14:16:50 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.com> | 2008-11-12 14:16:50 +0000 |
commit | 87605d8be1c3e4939f208c4df271fae7cfb89eec (patch) | |
tree | 9adba97b8b13f46e521e15ba653ea9ef89a9f6bd | |
parent | 2a3e7597f277a8cecb8cdb6bb64bc02d68fd5b1d (diff) | |
download | drakiso-87605d8be1c3e4939f208c4df271fae7cfb89eec.tar drakiso-87605d8be1c3e4939f208c4df271fae7cfb89eec.tar.gz drakiso-87605d8be1c3e4939f208c4df271fae7cfb89eec.tar.bz2 drakiso-87605d8be1c3e4939f208c4df271fae7cfb89eec.tar.xz drakiso-87605d8be1c3e4939f208c4df271fae7cfb89eec.zip |
write a /boot/grub/install.sh script when installing grub, and run grub in chroot (requires to bind-mount the image inside its mount point)
-rwxr-xr-x | draklive | 35 |
1 files changed, 27 insertions, 8 deletions
@@ -705,16 +705,35 @@ sub record_cdrom_master { sub install_grub_to_image { my ($live, $img) = @_; - cp_af(glob_($live->get_system_root . "/lib/grub/i386-mandriva/*"), $live->{mnt} . "/boot/grub"); - open(my $grub, "| /sbin/grub --batch --no-floppy"); - # using disk loopback fails, have to use image path - print $grub <<EOF; -device (hd0) $img + my $grub_dir = "/boot/grub"; + my $grub_script = $grub_dir . "/install.sh"; + my $grub_device_map = $grub_dir . "/device.map"; + cp_af(glob_($live->get_system_root . "/lib/grub/i386-mandriva/*"), $live->{mnt} . $grub_dir); + + output($live->{mnt} . $grub_script, <<EOG); +grub --device-map=/boot/grub/device.map --batch <<EOF root (hd0,0) -setup (hd0) +setup --stage2=/boot/grub/stage2 (hd0) +quit EOF - close ($grub) or die "unable to run grub\n"; - print "\n"; +EOG + + my $hd_tmp = !-b $img && "/tmp/hd0.img"; + if ($hd_tmp) { + touch($live->{mnt} . $hd_tmp); + run_("mount", "--bind", $img, $live->{mnt} . $hd_tmp); + } + my $hd0 = $hd_tmp || $img; + + # using disk loopback fails, have to use image path + output($live->{mnt} . $grub_device_map, "(hd0) $hd0"); + run_({ root => $live->{mnt} }, $grub_script); + unlink $live->{mnt} . $grub_device_map; + + if ($hd_tmp) { + run_("umount", $live->{mnt} . $hd_tmp); + unlink $live->{mnt} . $hd_tmp; + } } sub install_usb_bootloader { |