summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2003-03-10 18:32:03 +0000
committerFrancois Pons <fpons@mandriva.com>2003-03-10 18:32:03 +0000
commit7351c954a3af9409f486c0b97b3839d7ec911af1 (patch)
tree26a2d5c2cf013cdbb5fe8462c7402ef31dfe40af
parentbde17d9d9c88dd4f3277bf2897fd59baa57655a9 (diff)
downloaddrakx-7351c954a3af9409f486c0b97b3839d7ec911af1.tar
drakx-7351c954a3af9409f486c0b97b3839d7ec911af1.tar.gz
drakx-7351c954a3af9409f486c0b97b3839d7ec911af1.tar.bz2
drakx-7351c954a3af9409f486c0b97b3839d7ec911af1.tar.xz
drakx-7351c954a3af9409f486c0b97b3839d7ec911af1.zip
fix for strange parted behaviour.
-rwxr-xr-xrescue/tree/etc/oem44
-rwxr-xr-xrescue/tree/etc/oem-all26
2 files changed, 41 insertions, 29 deletions
diff --git a/rescue/tree/etc/oem b/rescue/tree/etc/oem
index 1bb35aa12..eef09b484 100755
--- a/rescue/tree/etc/oem
+++ b/rescue/tree/etc/oem
@@ -253,10 +253,9 @@ Type \`\`yes'' and [enter] to go on\n"
#- keep the current partition table, and try to resize the fat partition
#- if the size is not 0.
#- KEEP IN MIND there is only one partition defined.
- open F, "| parted -s /dev/$hd";
if ($resize_fat_size) {
$point = $hd_parts[$fat_pos]{start};
- printf F "resize %d %s %s\n", $hd_parts[$fat_pos]{minor}, correct_start_end(\$point, $point+$resize_fat_size, 'keepstart');
+ push @commands, sprintf "resize %d %s %s", $hd_parts[$fat_pos]{minor}, correct_start_end(\$point, $point+$resize_fat_size, 'keepstart');
} else {
$point = $hd_parts[$fat_pos]{end};
}
@@ -273,37 +272,52 @@ Type \`\`yes'' and [enter] to go on\n"
} while (($yes = <STDIN>) !~ /^\s*yes\s*$/i);
}
#- build a new disk label here.
- open F, "| parted -s /dev/$hd";
- print F "mklabel msdos\n";
+ push @commands, "mklabel msdos";
}
#- at this point, the partition are created.
-my ($instz, $inst, $swap, $root, $var, $home) = ($minor-1, $minor, $minor+1, $minor+2, undef, undef);
+my ($instz, $inst, $swap, $root, $var, $home, $free) = ($minor-1, $minor, $minor+1, $minor+2, undef, undef, undef);
#- all linux partition are stored inside an extended partition, this is easier to manipulate after.
+my $free_point = $point;
if ($minor == 5) {
- print F "mkpart extended $point $hd_size\n";
+ push @commands, sprintf "mkpart extended %s %s", correct_start_end(\$free_point, $hd_size - ($options{free_primary} && $options{free_size}),
+ 'keepstart');
} else {
$hd_parts[0]{type} eq 'extended' or die "first partition assumed to be extended";
$point = $hd_parts[0]{start};
- print F "resize $hd_parts[0]{minor} $point $hd_size\n";
+ push @commands, sprintf "resize %s %s %s", $hd_parts[0]{minor}, correct_start_end(\$free_point,
+ $hd_size - ($options{free_primary} && $options{free_size}),
+ 'keepstart');
}
-printf F "mkpart logical ext2 %s %s\n", correct_start_end(\$point, $point+$inst_size);
-printf F "mkpart logical linux-swap %s %s\n", correct_start_end(\$point, $point+$swap_size);
-printf F "mkpart logical %s %s %s\n", $fs, correct_start_end(\$point, $point+$root_size);
+push @commands, sprintf "mkpart logical ext2 %s %s", correct_start_end(\$point, $point+$inst_size);
+push @commands, sprintf "mkpart logical linux-swap %s %s", correct_start_end(\$point, $point+$swap_size);
+push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $point+$root_size);
if (exists $options{server} && $hd !~ /^rd\//) {
my $var_size = ($hd_size - $point) / 2;
if ($var_size > 1500) {
$var = $root+1;
- printf F "mkpart logical %s %s %s\n", $fs, correct_start_end(\$point, $point+$var_size);
+ push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $point+$var_size);
}
}
-if ($hd_size - $point > 100 && $hd !~ /^rd\//) {
+if ($hd_size - $point - $options{free_size} > 100 && $hd !~ /^rd\//) {
$home = ($var || $root) + 1;
- printf F "mkpart logical %s %s %s\n", $fs, correct_start_end(\$point, $hd_size);
+ push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $hd_size-$options{free_size});
+}
+if ($options{free_size} && $options{free_fs}) {
+ if ($options{free_primary}) {
+ $free = scalar(grep { $_->{type} eq 'primary' } @hd_parts) + 2;
+ if ($free > 4) {
+ $free = ($home || $var || $root) + 1;
+ delete $options{free_primary};
+ print "Unable to use primary partition for free partition, using logical partition.\n";
+ }
+ } else {
+ $free = ($home || $var || $root) + 1;
+ }
+ push @commands, sprintf "mkpart %s %s %s %s", $options{free_primary} ? 'primary' : 'logical', $options{free_fs} =~ /fat/ ? 'fat' : $options{free_fs}, correct_start_end($options{free_primary} ? \$free_point : \$point, $hd_size);
}
-print F "quit\n";
-close F or die "unable to partition the disk $hd";
+system "parted", "-s", "/dev/$hd", @commands == 0 or die "unable to partition the disk $hd";
#- we have to build swap and mount it.
print "Setting swap\n";
diff --git a/rescue/tree/etc/oem-all b/rescue/tree/etc/oem-all
index 9f4b2cd09..1dcc5e004 100755
--- a/rescue/tree/etc/oem-all
+++ b/rescue/tree/etc/oem-all
@@ -237,6 +237,7 @@ unless ($root_size) {
#- point define where we start.
my $minor = defined $resize_fat_size && $hd_parts[0]{type} eq 'extended' ? 6 : 5;
my $point = 0.0;
+my @commands;
if (defined $resize_fat_size) {
do {
@@ -250,10 +251,9 @@ Type \`\`yes'' and [enter] to go on\n"
#- keep the current partition table, and try to resize the fat partition
#- if the size is not 0.
#- KEEP IN MIND there is only one partition defined.
- open F, "| parted -s /dev/$hd";
if ($resize_fat_size) {
$point = $hd_parts[$fat_pos]{start};
- printf F "resize %d %s %s\n", $hd_parts[$fat_pos]{minor}, correct_start_end(\$point, $point+$resize_fat_size, 'keepstart');
+ push @commands, sprintf "resize %d %s %s", $hd_parts[$fat_pos]{minor}, correct_start_end(\$point, $point+$resize_fat_size, 'keepstart');
} else {
$point = $hd_parts[$fat_pos]{end};
}
@@ -270,8 +270,7 @@ Type \`\`yes'' and [enter] to go on\n"
} while (($yes = <STDIN>) !~ /^\s*yes\s*$/i);
}
#- build a new disk label here.
- open F, "| parted -s /dev/$hd";
- print F "mklabel msdos\n";
+ push @commands, "mklabel msdos";
}
#- at this point, the partition are created.
@@ -280,28 +279,28 @@ my ($instz, $inst, $swap, $root, $var, $home, $free) = ($minor-1, $minor, $minor
#- all linux partition are stored inside an extended partition, this is easier to manipulate after.
my $free_point = $point;
if ($minor == 5) {
- printf F "mkpart extended %s %s\n", correct_start_end(\$free_point, $hd_size - ($options{free_primary} && $options{free_size}),
+ push @commands, sprintf "mkpart extended %s %s", correct_start_end(\$free_point, $hd_size - ($options{free_primary} && $options{free_size}),
'keepstart');
} else {
$hd_parts[0]{type} eq 'extended' or die "first partition assumed to be extended";
$point = $hd_parts[0]{start};
- print F "resize %s %s %s\n", $hd_parts[0]{minor}, correct_start_end(\$free_point,
+ push @commands, sprintf "resize %s %s %s", $hd_parts[0]{minor}, correct_start_end(\$free_point,
$hd_size - ($options{free_primary} && $options{free_size}),
'keepstart');
}
-printf F "mkpart logical ext2 %s %s\n", correct_start_end(\$point, $point+$inst_size);
-printf F "mkpart logical linux-swap %s %s\n", correct_start_end(\$point, $point+$swap_size);
-printf F "mkpart logical %s %s %s\n", $fs, correct_start_end(\$point, $point+$root_size);
+push @commands, sprintf "mkpart logical ext2 %s %s", correct_start_end(\$point, $point+$inst_size);
+push @commands, sprintf "mkpart logical linux-swap %s %s", correct_start_end(\$point, $point+$swap_size);
+push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $point+$root_size);
if (exists $options{server} && $hd !~ /^rd\//) {
my $var_size = ($hd_size - $point) / 2;
if ($var_size > 1500) {
$var = $root+1;
- printf F "mkpart logical %s %s %s\n", $fs, correct_start_end(\$point, $point+$var_size);
+ push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $point+$var_size);
}
}
if ($hd_size - $point - $options{free_size} > 100 && $hd !~ /^rd\//) {
$home = ($var || $root) + 1;
- printf F "mkpart logical %s %s %s\n", $fs, correct_start_end(\$point, $hd_size-$options{free_size});
+ push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $hd_size-$options{free_size});
}
if ($options{free_size} && $options{free_fs}) {
if ($options{free_primary}) {
@@ -314,10 +313,9 @@ if ($options{free_size} && $options{free_fs}) {
} else {
$free = ($home || $var || $root) + 1;
}
- printf F "mkpart %s %s %s %s\n", $options{free_primary} ? 'primary' : 'logical', $options{free_fs} =~ /fat/ ? 'fat' : $options{free_fs}, correct_start_end($options{free_primary} ? \$free_point : \$point, $hd_size);
+ push @commands, sprintf "mkpart %s %s %s %s", $options{free_primary} ? 'primary' : 'logical', $options{free_fs} =~ /fat/ ? 'fat' : $options{free_fs}, correct_start_end($options{free_primary} ? \$free_point : \$point, $hd_size);
}
-print F "quit\n";
-close F or die "unable to partition the disk $hd";
+system "parted", "-s", "/dev/$hd", @commands == 0 or die "unable to partition the disk $hd";
#- try to help user if a free space has been set and no fs defined for it.
if ($options{free_size} && !$options{free_fs}) {