summaryrefslogtreecommitdiffstats
path: root/perl-install/install_any.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-08-11 00:27:27 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-08-11 00:27:27 +0000
commit66138cdc6bbd973426a9345c78c8120d9b446670 (patch)
tree63c1ec8ff6f3fff55453c752bbb26092921582a7 /perl-install/install_any.pm
parent40dcd0a59c0cce9b75f40b338799f5f28dd87cf6 (diff)
downloaddrakx-backup-do-not-use-66138cdc6bbd973426a9345c78c8120d9b446670.tar
drakx-backup-do-not-use-66138cdc6bbd973426a9345c78c8120d9b446670.tar.gz
drakx-backup-do-not-use-66138cdc6bbd973426a9345c78c8120d9b446670.tar.bz2
drakx-backup-do-not-use-66138cdc6bbd973426a9345c78c8120d9b446670.tar.xz
drakx-backup-do-not-use-66138cdc6bbd973426a9345c78c8120d9b446670.zip
no_comment
Diffstat (limited to 'perl-install/install_any.pm')
-rw-r--r--perl-install/install_any.pm144
1 files changed, 115 insertions, 29 deletions
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 5bd607909..6e9984f2a 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -584,6 +584,7 @@ sub g_auto_install(;$) {
if ($o->{X}{default_depth} and my $depth = $card->{depth}{$o->{X}{default_depth}}) {
$depth ||= [];
$o->{X}{resolution_wanted} ||= join "x", @{$depth->[0]} unless is_empty_array_ref($depth->[0]);
+ $o->{X}{monitor} = $::o->{X}{monitor} if $::o->{X}{monitor}{manual};
}
}
@@ -873,61 +874,146 @@ sub generate_ks_cfg {
sub partitionWizard {
my ($o, $hds, $fstab, $readonly) = @_;
- my $wizlog;
- my @solutions;
+ my @wizlog;
+ my (@solutions, %solutions);
my $min_linux = 500 << 11;
+ my $max_linux = 2500 << 11;
+ my $min_swap = 50 << 11;
+ my $max_swap = 300 << 11;
my $min_freewin = 100 << 11;
- # each solutions is a [ text, function ], where the function retunrs true if succeeded
+ # each solution is a [ score, text, function ], where the function retunrs true if succeeded
+
if (fsedit::free_space(@$hds) > $min_linux and !$readonly) {
- push @solutions, [ _("Use free space"), sub { fsedit::auto_allocate($hds, $o->{partitions}); 1 } ];
+ $solutions{free_space} = [ 20, _("Use free space"), sub { fsedit::auto_allocate($hds, $o->{partitions}); 1 } ]
} else {
- $wizlog .= _("Not enough free space to allocate new partitions");
+ push @wizlog, _("Not enough free space to allocate new partitions");
}
- if (my @l = grep { isTrueFS($_) } @$fstab) {
- push @solutions, [ _("Use existing partition"), sub { $o->ask_mntpoint_s($o->{fstab}) } ];
+ if (@$fstab) {
+ my $truefs = grep { isTrueFS($_) } @$fstab;
+ #- value twice the ext2 partitions
+ $solutions{existing_part} = [ 6 + $truefs + @$fstab, _("Use existing partition"), sub { $o->ask_mntpoint_s($fstab) } ]
} else {
- $wizlog .= _("There is no existing linux partition to use");
+ push @wizlog, _("There is no existing partition to use");
}
- if (my @l = grep { isFat($_) } @$fstab) {
- fs::df($_) foreach @l;
- my @ok_forloopback = sort { $b->{free} <=> $a->{free} } grep { $_->{free} > $min_linux + $min_freewin } @l
- or $wizlog .= _("There is not enough space left on the FAT partition(s) (or the FAT partition is corrupted)");
-
- push @solutions, [ _("Use the FAT partition for loopback"),
- sub { $o->doPartitionDisksLnx4win(@ok_forloopback) } ];
-
- my @ok_forresizing = grep {
- !$readonly && eval {
- my $resize_fat = resize_fat::main->new($_->{device}, devices::make($_->{device}));
+ my @fats = grep { isFat($_) } @$fstab;
+ fs::df($_) foreach @fats;
+ if (my @ok_forloopback = sort { $b->{free} <=> $a->{free} } grep { $_->{free} > $min_linux + $min_freewin } @fats) {
+ $solutions{loopback} =
+ [ 5 - @fats, _("Use the FAT partition for loopback"),
+ sub {
+ my ($s_root, $s_swap);
+ my $part = $o->ask_from_listf('', _("Which partition do you want to use to put Linux4Win?"), \&partition_table_raw::description, \@ok_forloopback) or return;
+ $o->ask_from_entries_refH('', _("Choose the sizes"), [
+ _("Root partition size in MB: ") => { val => \$s_root, min => 1 + ($min_linux >> 11), max => min($part->{free} - 2 * $max_swap - $min_freewin, $max_linux) >> 11, type => 'range' },
+ _("Swap partition size in MB: ") => { val => \$s_swap, min => 1 + ($min_swap >> 11), max => 2 * $max_swap >> 11, type => 'range' },
+ ]) or return;
+ push @{$part->{loopback}},
+ { type => 0x83, loopback_file => '/lnx4win/linuxsys.img', mntpoint => '/', size => $s_root << 11, device => $part, notFormatted => 1 },
+ { type => 0x82, loopback_file => '/lnx4win/swapfile', mntpoint => 'swap', size => $s_swap << 11, device => $part, notFormatted => 1 };
+ 1;
+ } ];
+ $solutions{resize_fat} =
+ [ 6 - @fats, _("Use the free space on the FAT partition"),
+ sub {
+ my $part = $o->ask_from_listf('', _("Which partition do you want to resize?"), \&partition_table_raw::description, \@ok_forloopback) or return;
+ my $w = $o->wait_message(_("Resizing"), _("Computing FAT filesystem bounds"));
+ my $resize_fat = eval { resize_fat::main->new($part->{device}, devices::make($part->{device})) };
+ $@ and die _("The FAT resizer is unable to handle your partition,
+the following error occured: %s", $@);
my $min_win = $resize_fat->min_size;
- $_->{size} > $min_linux + $min_freewin + $min_win;
- } && !$@;
- } @ok_forloopback or $wizlog .= _("The FAT resizer can't find enough space left on the FAT partition(s)");
+ $part->{size} > $min_linux + $min_freewin + $min_win or die _("Your windows partition is too fragmented, please run ``defrag'' first");
+ $o->ask_okcancel('', _("WARNING!
+
+DrakX will now resize your Windows partition. Be careful: this operation is
+dangerous. If you have not already done so, you should first exit the
+installation, run scandisk under Windows (and optionally run defrag), then
+restart the installation. You should also backup your data.
+When sure, press Ok.")) or return;
+
+ my $size = $part->{size};
+ $o->ask_from_entries_refH('', _("Which size do you want to keep for windows on"), [
+ _("partition %s", partition_table_raw::description($part)) => { val => \$size, min => 1 + ($min_win >> 11), max => ($part->{size} - $min_linux) >> 11, type => 'range' },
+ ]) or return;
+ $size <<= 11;
+
+ local *log::l = sub { $w->set(join(' ', @_)) };
+ eval { $resize_fat->resize($size) };
+ $@ and die _("FAT resizing failed: %s", $@);
+
+ $part->{size} = $size;
+ $part->{isFormatted} = 1;
+
+ my ($hd) = grep { $_->{device} eq $part->{rootDevice} } @$hds;
+ $hd->{isDirty} = $hd->{needKernelReread} = 1;
+ $hd->adjustEnd($part);
+ partition_table::adjust_local_extended($hd, $part);
+ partition_table::adjust_main_extended($hd);
+
+ fsedit::auto_allocate($hds, $o->{partitions});
+ 1;
+ } ] if !$readonly;
} else {
- $wizlog .= _("There is no FAT partitions to resize or to use as loopback");
+ push @wizlog, _("There is no FAT partitions to resize or to use as loopback (or not enough space left)");
}
if (@$fstab && !$readonly) {
require diskdrake;
- push @solutions,
- [ _("Take over the hard drive (beware!)"),
+ $solutions{wipe_drive} =
+ [ 10, fsedit::is_one_big_fat($hds) ? _("Remove Windows(TM)") : _("Take over the hard drive"),
sub {
my $hd = $o->ask_from_listf('', _("You have more than one hard drive, which one do you install linux on?"),
- \&partition_table_raw::description, @$hds) or return;
+ \&partition_table_raw::description, $hds) or return;
$o->ask_okcancel('', _("All existing partitions and their data will be lost on drive %s", $hd->{device})) or return;
partition_table_raw::zero_MBR($hd);
fsedit::auto_allocate($hds, $o->{partitions});
1;
} ];
}
- if (!$readonly) {
- push @solutions,
- [ _("Use diskdrake"), sub { diskdrake::main($hds, $o->{raid}, interactive_gtk->new, $o->{partitions}); 1 } ];
+
+ if (!$readonly && ref($o) =~ /gtk/) { #- diskdrake only available in gtk for now
+ $solutions{diskdrake} =
+ [ 0, _("Use diskdrake"), sub {
+ my $ok = 1;
+ do {
+ diskdrake::main($hds, $o->{raid}, interactive_gtk->new, $o->{partitions});
+ my @fstab = fsedit::get_fstab(@$hds);
+
+ unless (fsedit::get_root(\@fstab)) {
+ $ok = 0;
+ $o->ask_okcancel('', _("You must have a root partition.
+For this, create a partition (or click on an existing one).
+Then choose action ``Mount point'' and set it to `/'"), 1) or return;
+ }
+ if (!grep { isSwap($_) } @fstab) {
+ $o->ask_warn('', _("You must have a swap partition")), $ok=0 if $::beginner;
+ $ok &&= $::expert || $o->ask_okcancel('', _("You don't have a swap partition\n\nContinue anyway?"));
+ }
+ } until $ok;
+ 1;
+ } ];
+ }
+
+ if (!$readonly) { #- diskdrake only available in gtk for now
+ $solutions{fdisk} =
+ [ -10, _("Use fdisk"), sub {
+ $o->suspend;
+ foreach (@$hds) {
+ print "\n" x 10, _("You can now partition %s.
+When you are done, don't forget to save using `w'", partition_table_raw::description($_));
+ print "\n\n";
+ my $pid = fork or exec "fdisk", devices::make($_->{device});
+ waitpid($pid, 0);
+ }
+ $o->resume;
+ 0;
+ } ];
}
+ log::l("partitioning wizard log:\n", (map { ">>wizlog>>$_\n" } @wizlog));
+ %solutions;
}
1;