summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2009-07-31 13:44:59 +0000
committerOlivier Blin <oblin@mandriva.com>2009-07-31 13:44:59 +0000
commit637c9dc0d7a80cb1e5551939637046fb57cb7555 (patch)
treec48e99a57bfea123b0ef3db6511c249cf9a7dbe4
parentde8879188195f04fc804650ed3bf2aaf377475fb (diff)
downloaddrakiso-637c9dc0d7a80cb1e5551939637046fb57cb7555.tar
drakiso-637c9dc0d7a80cb1e5551939637046fb57cb7555.tar.gz
drakiso-637c9dc0d7a80cb1e5551939637046fb57cb7555.tar.bz2
drakiso-637c9dc0d7a80cb1e5551939637046fb57cb7555.tar.xz
drakiso-637c9dc0d7a80cb1e5551939637046fb57cb7555.zip
use partition_table module instead of hardcoded fdisk commands
-rwxr-xr-xdraklive72
1 files changed, 17 insertions, 55 deletions
diff --git a/draklive b/draklive
index b94d9e5..141fc2c 100755
--- a/draklive
+++ b/draklive
@@ -693,62 +693,24 @@ sub allocate_master {
MDV::Draklive::Utils::device_allocate_file($dest, $disk_size);
- my $slash = find { $_->{mntpoint} eq '/' } @{$media->{partitions}};
- my $fs = $slash->{fs_type};
-
- #- FIXME: use fsedit::allocatePartitions and $media->{partitions}?
- # foreach (@{$media->{partitions}}) { # set pt_type }
-
- require fs::type;
- my $pt_type = sprintf('%x', fs::type::fs_type2subpart($fs)->{pt_type});
- open(my $fdisk, "| fdisk -C $geom->{cylinders} -S $geom->{sectors} -H $geom->{heads} $dest");
-
- 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
-1
-
-
-t
-$pt_type
-a
-1
-w
-EOF
-}
+ my $hd = bless {
+ totalsectors => $geom->{cylinders} * $geom->{heads} * $geom->{sectors},
+ geom => $geom,
+ file => $dest,
+ }, 'partition_table::dos';
+
+ partition_table::raw::zero_MBR($hd);
+
+ #- FIXME: maybe use fsedit::allocatePartitions to factorize even more?
+ foreach my $part (@{$media->{partitions}}) {
+ my $hole = find { fs::type::isEmpty($_) && $_->{size} >= $part->{size} } partition_table::get_normal_parts_and_holes($hd)
+ or die "not enough room for $part->{mntpoint}";
+ $part->{start} = $hole->{start};
+ fs::type::set_fs_type($part, $part->{fs_type});
+ partition_table::add($hd, $part, 'Primary');
+ }
- close($fdisk) or die "unable to run fdisk\n" . ("$!" ? "Error closing fdisk pipe: $!" : "Exit status $? from fdisk");
+ partition_table::write($hd);
my $inode_size = $media->get_media_setting('inode_size');
map_index { allocate_partition($dest, $::i, $sector_size, $_->{fs_type}, $inode_size) } @{$media->{partitions}};