summaryrefslogtreecommitdiffstats
path: root/perl-install/fsedit.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-03-03 14:11:58 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-03-03 14:11:58 +0000
commita0c99bbcd7be82b0733f314e404147cbd5cc69e1 (patch)
treeaa7702f9ceb3ed721d88ee945a4b934964e777bd /perl-install/fsedit.pm
parenta59816e075d30443a5124dd1787577cc25e5ac22 (diff)
downloaddrakx-a0c99bbcd7be82b0733f314e404147cbd5cc69e1.tar
drakx-a0c99bbcd7be82b0733f314e404147cbd5cc69e1.tar.gz
drakx-a0c99bbcd7be82b0733f314e404147cbd5cc69e1.tar.bz2
drakx-a0c99bbcd7be82b0733f314e404147cbd5cc69e1.tar.xz
drakx-a0c99bbcd7be82b0733f314e404147cbd5cc69e1.zip
- auto allocate: do not create /home if drive is smaller than 7GB
Diffstat (limited to 'perl-install/fsedit.pm')
-rw-r--r--perl-install/fsedit.pm16
1 files changed, 9 insertions, 7 deletions
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index 6260c9271..5c82a2429 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -22,19 +22,19 @@ use fs;
%suggestions = (
N_("simple") => [
{ mntpoint => "/", size => MB(300), fs_type => 'ext3', ratio => 20, maxsize => MB(8000) },
- { mntpoint => "swap", size => MB(64), fs_type => 'swap', ratio => 1, maxsize => MB(4000) },
- { mntpoint => "/home", size => MB(300), fs_type => 'ext3', ratio => 3 },
+ { mntpoint => "swap", size => MB(128), fs_type => 'swap', ratio => 1, maxsize => MB(4000) },
+ { mntpoint => "/home", size => MB(300), fs_type => 'ext3', ratio => 3, min_hd_size => MB(7000) },
], N_("with /usr") => [
- { mntpoint => "/", size => MB(250), fs_type => 'ext3', ratio => 1, maxsize => MB(4000) },
+ { mntpoint => "/", size => MB(250), fs_type => 'ext3', ratio => 1, maxsize => MB(8000) },
{ mntpoint => "swap", size => MB(64), fs_type => 'swap', ratio => 1, maxsize => MB(4000) },
{ mntpoint => "/usr", size => MB(300), fs_type => 'ext3', ratio => 4, maxsize => MB(8000) },
- { mntpoint => "/home", size => MB(100), fs_type => 'ext3', ratio => 3 },
+ { mntpoint => "/home", size => MB(100), fs_type => 'ext3', ratio => 3, min_hd_size => MB(7000) },
], N_("server") => [
- { mntpoint => "/", size => MB(150), fs_type => 'ext3', ratio => 1, maxsize => MB(4000) },
+ { mntpoint => "/", size => MB(150), fs_type => 'ext3', ratio => 1, maxsize => MB(8000) },
{ mntpoint => "swap", size => MB(64), fs_type => 'swap', ratio => 2, maxsize => MB(4000) },
{ mntpoint => "/usr", size => MB(300), fs_type => 'ext3', ratio => 4, maxsize => MB(8000) },
{ mntpoint => "/var", size => MB(200), fs_type => 'ext3', ratio => 3 },
- { mntpoint => "/home", size => MB(150), fs_type => 'ext3', ratio => 3 },
+ { mntpoint => "/home", size => MB(150), fs_type => 'ext3', ratio => 3, min_hd_size => MB(7000) },
{ mntpoint => "/tmp", size => MB(150), fs_type => 'ext3', ratio => 2, maxsize => MB(4000) },
],
);
@@ -346,10 +346,12 @@ sub suggest_part {
fs::type::set_pt_type($_, $_->{pt_type}) if !exists $_->{fs_type};
}
+ my $hd_size = fs::get::part2hd($part, $all_hds)->{totalsectors};
my $has_swap = any { isSwap($_) } fs::get::fstab($all_hds);
my @local_suggestions =
grep { !$_->{mntpoint} && !$_->{VG_name} || !fs::get::has_mntpoint($_->{mntpoint}, $all_hds) || isSwap($_) && !$has_swap }
+ grep { !$_->{min_hd_size} || $_->{min_hd_size} <= $hd_size }
grep { !$_->{hd} || $_->{hd} eq $part->{rootDevice} }
@$suggestions;
@@ -357,7 +359,7 @@ sub suggest_part {
#- one should rather use {ratio} instead
foreach (@local_suggestions) {
if ($_->{percent_size} && $_->{percent_size} =~ /(.+?)%?$/) {
- $_->{size} = $1 / 100 * fs::get::part2hd($part, $all_hds)->{totalsectors};
+ $_->{size} = $1 / 100 * $hd_size;
log::l("in suggestion, setting size=$_->{size} for percent_size=$_->{percent_size}");
}
}
n277'>277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
package interactive_gtk;

use diagnostics;
use strict;
use vars qw(@ISA);

@ISA = qw(interactive);

use interactive;
use common qw(:common :functional);
use my_gtk qw(:helpers :wrappers);

1;

sub new {
    $::windowheight ||= 400 if $::isStandalone;
    goto &interactive::new;
}

#-#- redefine ask_warn
#-sub ask_warn {
#-    my $o = shift;
#-    local $my_gtk::grab = 1;
#-    $o->SUPER::ask_warn(@_);
#-}

sub exit { 
    c::_exit($_[0]) #- workaround 
}

sub ask_from_listW {
    my ($o, $title, $messages, $l, $def) = @_;
    my $r;

    my $w = my_gtk->new(first(deref($title)), %$o);
    $w->{retval} = $def || $l->[0]; #- nearly especially for the X test case (see timeout in Xconfigurator.pm)
    if (@$l < 5) {
	my $defW;
	my $f = sub { $w->{retval} = $_[1]; Gtk->main_quit };
	gtkadd($w->{window},
	       gtkpack(create_box_with_title($w, @$messages),
		       gtkadd(@$l < 3 && sum(map { length $_ } @$l) < 60 ? create_hbox() : create_vbox(),
			      map {
				  my $b = new Gtk::Button($_);
				  $b->signal_connect(clicked => [ $f, $_ ]);
				  $_ eq $def and $defW = $b;
				  $b;
			      } @$l),
		       ),
	       );
	$defW->grab_focus if $defW;
	$w->{rwindow}->set_position('center') if $::isStandalone;
	$r = $w->main;
    } else {
	$w->_ask_from_list($title, $messages, $l, $def);
	$r = $w->main;
    }
    $r or die "ask_from_list cancel";
}

sub ask_from_treelistW {
    my ($o, $title, $messages, $separator, $l, $def) = @_;
    my $sep = quotemeta $separator;
    my $w = my_gtk->new($title);
    my $tree = Gtk::CTree->new(1, 0);

    my %wtree;
    my $parent; $parent = sub {
	if (my $w = $wtree{"$_[0]$separator"}) { return $w }
	my $s;
	foreach (split $sep, $_[0]) {
	    $wtree{"$s$_$separator"} ||= 
	      $tree->insert_node($s ? $parent->($s) : undef, undef, [$_], 5, (undef) x 4, 0, 0);
	    $s .= "$_$separator";
	}
	$wtree{$s};
    };
    my ($root, $leaf, $wdef, $ndef);
    foreach (@$l) {
	($root, $leaf) = /(.*)$sep(.+)/o or ($root, $leaf) = ('', $_);
	my $node = $tree->insert_node($parent->($root), undef, [$leaf], 5, (undef) x 4, 1, 0);

	if ($def eq $_) {
	    $wdef = $node;
	    my $s; $tree->expand($wtree{$s .= "$_$separator"}) foreach split $sep, $root;
	    foreach my $nb (1 .. @$l) {
		if ($tree->node_nth($nb) == $node) {
		    $tree->set_focus_row($nb);
		    Gtk->idle_add(sub { $tree->node_moveto($node, 0, 0.5, 0); 0 });
		    last;
		}
	    }
	}
    }
    undef %wtree;

    my $curr;
    my $leave = sub { 
	$curr->row->is_leaf or return;
	my @l; for (; $curr; $curr = $curr->row->parent) { 
	    unshift @l, first $tree->node_get_pixtext($curr, 0);
	}
	$w->{retval} = join $separator, @l;
	Gtk->main_quit;
    };
    $w->{ok_clicked} = $leave;
    $w->{cancel_clicked} = sub { $w->destroy; die "ask_from_list cancel" }; #- make sure windows doesn't live any more.
    gtkadd($w->{window},
	   gtkpack($w->create_box_with_title(@$messages),
		   gtkpack_(new Gtk::VBox(0,7),
			    1, gtkset_usize(createScrolledWindow($tree), 300, min(400, $::windowheight - 60)),
			    0, $w->create_okcancel)));
    $tree->set_column_auto_resize(0, 1);
    $tree->set_selection_mode('browse');
    $tree->signal_connect(tree_select_row => sub { $curr = $_[1]; });
    $tree->signal_connect(button_press_event => sub { &$leave if $_[1]{type} =~ /^2/ });
    $tree->signal_connect(key_press_event => sub {
        my ($w, $e) = @_;