summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2009-06-29 13:37:51 +0000
committerOlivier Blin <oblin@mandriva.com>2009-06-29 13:37:51 +0000
commit3149aad3d719e969ee95517ff98fa14443dd7b44 (patch)
tree075dda3eb17ae31c80ff013abf50f7e4b27382a4
parent929940d535f8eda0e29d2b014d2292499643dea3 (diff)
downloaddrakiso-3149aad3d719e969ee95517ff98fa14443dd7b44.tar
drakiso-3149aad3d719e969ee95517ff98fa14443dd7b44.tar.gz
drakiso-3149aad3d719e969ee95517ff98fa14443dd7b44.tar.bz2
drakiso-3149aad3d719e969ee95517ff98fa14443dd7b44.tar.xz
drakiso-3149aad3d719e969ee95517ff98fa14443dd7b44.zip
allow to add an OEM rescue partition in the master (quite hackish, using $live->{oem_rescue})
-rwxr-xr-xdraklive69
1 files changed, 65 insertions, 4 deletions
diff --git a/draklive b/draklive
index d01bfad..465bb56 100755
--- a/draklive
+++ b/draklive
@@ -128,6 +128,12 @@ sub build_grub_cfg_raw {
"kernel $grub_part" . $boot . "/vmlinuz " . get_default_append($live, $opts) . if_($cmdline, " $cmdline"),
if_($initrd, "initrd " . $boot . $initrd);
} group_by2('' => '', @{$live->{system}{boot_entries}})),
+ if_(defined $opts->{oem_rescue_idx},
+ #- FIXME: factorize with above, build_grub_cfg_entry($media)
+ "title " . $live->{oem_rescue}{media}{title},
+ "kernel (hd0,$opts->{oem_rescue_idx})" . $boot . "/vmlinuz " . $live->{oem_rescue}{append},
+ "initrd (hd0,$opts->{oem_rescue_idx})" . $boot . $media->get_initrd_path,
+ ),
"",
);
}
@@ -560,7 +566,8 @@ sub create_classical_bootloader {
my $initrd_prefix = "/initrd.img";
my $initrd = $live->get_system_root . $live->get_media_prefix('boot') . $initrd_prefix;
my $part_idx = $live->{media}->find_partition_index('/');
- output_p($live->get_system_root . '/boot/grub/menu.lst', build_grub_cfg_raw($live, $live->{media}, -e $initrd && $initrd_prefix, {}, $part_idx));
+ my $oem_rescue_idx = $live->{media}->find_partition_index('OEM_RESCUE');
+ output_p($live->get_system_root . '/boot/grub/menu.lst', build_grub_cfg_raw($live, $live->{media}, -e $initrd && $initrd_prefix, { oem_rescue_idx => $oem_rescue_idx }, $part_idx));
}
sub set_device_label {
@@ -687,11 +694,42 @@ sub allocate_master {
my $slash = find { $_->{mntpoint} eq '/' } @{$media->{partitions}};
$slash->{fs_type} = $fs;
- #- FIXME: use parted?
+ #- FIXME: use fsedit::allocatePartitions and $media->{partitions}?
require fs::type;
my $pt_type = sprintf('%x', fs::type::fs_type2subpart($fs)->{pt_type});
open(my $fdisk, "| fdisk -C $cylinders -S $sectors_per_track -H $heads $dest");
- print $fdisk <<EOF;
+
+ my $oem_rescue_idx = $media->find_partition_index('OEM_RESCUE');
+ if (defined $oem_rescue_idx) {
+ my $rescue_partition = $media->{partitions}[$oem_rescue_idx];
+ $rescue_partition->{fs_type} = $live->{oem_rescue}{media}->get_media_setting('fs');
+ my $rescue_pt_type = sprintf('%x', fs::type::fs_type2subpart($rescue_partition->{fs_type})->{pt_type});
+
+ #- FIXME: respect partitions layout from $media->{partitions} (currently hardcoded here :/)
+ print $fdisk <<EOF;
+o
+n
+p
+1
+
++4G
+n
+p
+2
+
+
+t
+1
+$rescue_pt_type
+t
+2
+$pt_type
+a
+2
+w
+EOF
+ } else {
+ print $fdisk <<EOF;
o
n
p
@@ -704,6 +742,8 @@ a
1
w
EOF
+}
+
close($fdisk) or die "unable to run fdisk\n" . ("$!" ? "Error closing fdisk pipe: $!" : "Exit status $? from fdisk");
my $inode_size = $media->get_media_setting('inode_size');
@@ -719,13 +759,17 @@ sub create_disk_master {
directory_usage($live->get_builddir . $live->{prefix}{build}{boot}) +
directory_usage($live->get_builddir . $live->{prefix}{build}{files}) +
70000000) :
- directory_usage($live->get_system_root) + 200000000;
+ directory_usage($live->get_system_root) + 200000000 + 4500000000; #- FIXME: use size from $live->{media}{partitions}
my @loops = allocate_master($live->{media}, $dest, $disk_size, $live->{media}->get_media_setting('fs'));
my $slash_idx = $live->{media}->find_partition_index('/');
local $opts->{device} = $loops[$slash_idx];
local $opts->{disk_device} = $dest;
record_master($live, $opts);
+ my $oem_rescue_idx = $live->{media}->find_partition_index('OEM_RESCUE');
+ if (defined $oem_rescue_idx) {
+ record_oem_rescue($live, $loops[$oem_rescue_idx], $opts);
+ }
run_('losetup', '-d', $_) foreach @loops;
}
@@ -1068,6 +1112,9 @@ sub record_rescue_files {
}
}
+ #- FIXME
+ chmod 0755, $mnt . '/' . 'oem-rescue.sh';
+
if ($failed) {
run_('umount', $mnt);
maybe_umount_device($device);
@@ -1075,6 +1122,20 @@ sub record_rescue_files {
}
}
+sub record_oem_rescue {
+ my ($live, $device, $opts) = @_;
+ my $media = $live->{oem_rescue}{media};
+ my $media_boot = $live->get_media_prefix('boot');
+ mkdir_p($live->{mnt});
+ run_('mount', if_(-f $device, '-o', 'loop'), $device, $live->{mnt})
+ or die "unable to mount $device\n";
+
+ record_rescue_files($live->{mnt}, $device, [ get_rescue_files($live, $live->{oem_rescue}) ]);
+
+ run_('umount', $live->{mnt});
+ maybe_umount_device($device);
+}
+
sub get_disk_replicator_path {
my ($live) = @_;
$live->get_builddir . $live->{prefix}{build}{dist} . '/' . $live->get_name . '.rest.img';