diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2000-08-04 00:29:32 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2000-08-04 00:29:32 +0000 |
commit | a3d551a6468bd1799197187d185689e3ac9cb4db (patch) | |
tree | 4e07ef60416129b6bd1b514536346c33c922791b /perl-install | |
parent | 299573a7ecaf76b17411611dabd08c822f9b6f53 (diff) | |
download | drakx-a3d551a6468bd1799197187d185689e3ac9cb4db.tar drakx-a3d551a6468bd1799197187d185689e3ac9cb4db.tar.gz drakx-a3d551a6468bd1799197187d185689e3ac9cb4db.tar.bz2 drakx-a3d551a6468bd1799197187d185689e3ac9cb4db.tar.xz drakx-a3d551a6468bd1799197187d185689e3ac9cb4db.zip |
no_comment
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/ChangeLog | 21 | ||||
-rw-r--r-- | perl-install/commands.pm | 9 | ||||
-rw-r--r-- | perl-install/common.pm | 21 | ||||
-rw-r--r-- | perl-install/install_any.pm | 13 | ||||
-rw-r--r-- | perl-install/install_steps_interactive.pm | 38 | ||||
-rw-r--r-- | perl-install/loopback.pm | 15 | ||||
-rw-r--r-- | perl-install/pkgs.pm | 16 | ||||
-rw-r--r-- | perl-install/share/list.i386 | 1 |
8 files changed, 90 insertions, 44 deletions
diff --git a/perl-install/ChangeLog b/perl-install/ChangeLog index 3cbfc1ac2..64b05d633 100644 --- a/perl-install/ChangeLog +++ b/perl-install/ChangeLog @@ -1,3 +1,24 @@ +2000-08-04 Pixel <pixel@mandrakesoft.com> + + * pkgs.pm (setSelectedFromCompssList): save $nb to able to restore + it in case of max_size reached. only purpose is the log! + + * install_steps_interactive.pm (choosePackages): in newbie, ask + between Small/Medium/Full install + * install_steps_interactive.pm (choosePackages): in expert, have + the min_mark be 0 instead of 1 + + * common.pm (find_index): added this nice function + + * install_any.pm (getAvailableSpace_mounted): use common::df + * loopback.pm (getFree): use common::df + * commands.pm (df): use common::df + * common.pm (df): added + + * diskdrake.pm (Resize)): add resizing of reiserfs + * share/list.i386: add resize_reiserfs + + 2000-08-02 dam's <damien@mandrakesoft.com> * Xconfigurator.pm : autologin is functionall. When wmsession.d is diff --git a/perl-install/commands.pm b/perl-install/commands.pm index f2ec0d154..dd8393e12 100644 --- a/perl-install/commands.pm +++ b/perl-install/commands.pm @@ -472,7 +472,7 @@ $l{Destination}, $l{Gateway}, $l{Mask}, $l{Iface} sub df { my ($h) = getopts(\@_, qw(h)); - my ($dev, $blocksize, $size, $free, $used, $use, $mntpoint); + my ($dev, $size, $free, $used, $use, $mntpoint); open DF, ">&STDOUT"; format DF_TOP = Filesystem Size Used Avail Use Mounted on @@ -487,12 +487,7 @@ $dev, $size, $used, $free, $use, $mntpoint $h{$dev} = $mntpoint; } foreach $dev (sort keys %h) { - $mntpoint = $h{$dev}; - my $buf = ' ' x 20000; - syscall_('statfs', $mntpoint, $buf) or next; - (undef, $blocksize, $size, undef, $free, undef) = unpack "L2L4", $buf; - $_ *= $blocksize / 1024 foreach $size, $free; - + ($size, $free) = common::df($mntpoint = $h{$dev}); $size or next; $use = int (100 * ($size - $free) / $size); diff --git a/perl-install/common.pm b/perl-install/common.pm index 1ad2f85b1..3afcfc371 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -7,7 +7,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $printable_chars $sizeof_int $bitof_int @ISA = qw(Exporter); %EXPORT_TAGS = ( common => [ qw(__ even odd arch better_arch compat_arch min max sqr sum and_ or_ sign product bool invbool listlength bool2text bool2yesno text2bool to_int to_float ikeys member divide is_empty_array_ref is_empty_hash_ref add2hash add2hash_ set_new set_add round round_up round_down first second top uniq translate untranslate warp_text formatAlaTeX formatLines deref) ], - functional => [ qw(fold_left compose mapgrep map_index grep_index map_each grep_each list2kv map_tab_hash mapn mapn_ difference2 before_leaving catch_cdie cdie combine) ], + functional => [ qw(fold_left compose mapgrep map_index grep_index find_index map_each grep_each list2kv map_tab_hash mapn mapn_ difference2 before_leaving catch_cdie cdie combine) ], file => [ qw(dirname basename touch all glob_ cat_ output symlinkf chop_ mode typeFromMagic expand_symlinks) ], system => [ qw(sync makedev unmakedev psizeof strcpy gettimeofday syscall_ salt getVarsFromSh setVarsInSh setVarsInCsh substInFile availableRam availableMemory removeXiBSuffix template2file formatTime unix2dos setVirtual) ], constant => [ qw($printable_chars $sizeof_int $bitof_int $SECTORSIZE %compat_arch) ], @@ -176,6 +176,16 @@ sub grep_index(&@) { my $v; local $::i = 0; grep { $v = &$f($::i); $::i++; $v } @_; } +sub find_index(&@) { + my $f = shift; + local $_; + for (my $i = 0; $i < @_; $i++) { + $_ = $_[$i]; + &$f and return $i; + } + die "find_index failed in @_"; +} + sub map_each(&%) { my ($f, %h) = @_; my @l; @@ -537,6 +547,15 @@ sub formatTime($) { sprintf "%02d:%02d:%02d", $h, $m, $s; } +#- return the size of the partition and its free space in KiB +sub df { + my ($mntpoint) = @_; + my ($blocksize, $size, $free); + my $buf = ' ' x 20000; + syscall_('statfs', $mntpoint, $buf) or return; + (undef, $blocksize, $size, undef, $free, undef) = unpack "L2L4", $buf; + map { $_ * ($blocksize / 1024) } $size, $free; +} #-###################################################################################### #- Wonderful perl :( diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index 1f9782140..3fd665cd4 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -235,17 +235,16 @@ sub getAvailableSpace { #- 50mb may be a good choice to avoid almost all problem of insuficient space left... my $minAvailableSize = 50 * sqr(1024); - int ((getAvailableSpace_mounted($o->{prefix}) || getAvailableSpace_raw($o->{fstab}) * 512 / 1.07) - $minAvailableSize); + int ((!$::testing && + getAvailableSpace_mounted($o->{prefix}) || + getAvailableSpace_raw($o->{fstab}) * 512 / 1.07) - $minAvailableSize); } sub getAvailableSpace_mounted { my ($prefix) = @_; - my $buf = ' ' x 20000; my $dir = -d "$prefix/usr" ? "$prefix/usr" : "$prefix"; - syscall_('statfs', $dir, $buf) or return; - my (undef, $blocksize, $size, undef, $free, undef) = unpack "L2L4", $buf; - log::l("space free on $dir is $free blocks of $blocksize bytes"); - $free * $blocksize || 1; + my ($free, undef) = common::df($dir) or return; + $free || 1; } sub getAvailableSpace_raw { my ($fstab) = @_; @@ -254,7 +253,7 @@ sub getAvailableSpace_raw { do { $_->{mntpoint} eq '/' and return $_->{size} } foreach @$fstab; if ($::testing) { - my $nb = 650; + my $nb = 450; log::l("taking ${nb}MB for testing"); return $nb << 11; } diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index 998ac5c07..0291af4b4 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -153,13 +153,14 @@ You will be allowed to make powerful but dangerous things here."), sub selectMouse { my ($o, $force) = @_; - if ($o->{mouse}{unsafe} || $::expert || $force) { + $force ||= $o->{mouse}{unsafe} || $::expert; + if ($force) { my $name = $o->ask_from_list_('', _("Please, choose the type of your mouse."), [ mouse::names() ], $o->{mouse}{FULLNAME}); $o->{mouse} = mouse::name2mouse($name); } $o->{mouse}{XEMU3} = 'yes' if $o->{mouse}{nbuttons} < 3; #- if $o->{mouse}{nbuttons} < 3 && $o->ask_yesorno('', _("Emulate third button?"), 1); - if ($o->{mouse}{device} eq "ttyS") { + if ($force && $o->{mouse}{device} eq "ttyS") { $o->set_help('selectSerialPort'); $o->{mouse}{device} = mouse::serial_ports_names2dev( $o->ask_from_list(_("Mouse Port"), @@ -297,21 +298,24 @@ sub choosePackages { #- avoid reselection of package if individual selection is requested and this is not the first time. if ($first_time || !$individual) { - my $min_mark = $::beginner ? 25 : 1; - my @l = values %{$packages->[0]}; - my @flags = map { pkgs::packageFlagSelected($_) } @l; - pkgs::setSelectedFromCompssList($o->{compssListLevels}, $packages, $min_mark, 0, $o->{installClass}); - my $max_size = 1 + pkgs::selectedSize($packages); #- avoid division by zero. - mapn { pkgs::packageSetFlagSelected(@_) } \@l, \@flags; - -#- if (!$::beginner && $max_size > $availableC) { -#- $o->ask_okcancel('', -#-_("You need %dMB for a full install of the groups you selected. -#-You can go on anyway, but be warned that you won't get all packages", $max_size / sqr(1024)), 1) or goto &choosePackages -#- } - my $size2install = $::beginner && $first_time ? $availableC * 0.7 : - $o->chooseSizeToInstall($packages, $min_size, $max_size, $availableC, $individual) or goto &choosePackages; - + my $min_mark = $::beginner ? 10 : $::expert ? 0 : 1; + my ($size, $level) = pkgs::fakeSetSelectedFromCompssList($o->{compssListLevels}, $packages, $min_mark, 0, $o->{installClass}); + my $max_size = 1 + $size; #- avoid division by zero. + + my $size2install = do { + if ($::beginner) { + #- TODO: check the max_size > 700, otherwise remove Full entry, and even maybe Medium + #- in any case, ensure the result < $max_size + my @sizes = (300, 700, round_up(min($max_size, $availableC) / 1024 / 1024, 100)); + my @l = mapn { _ ($_[0], $_[1]) } [ __("Small(%dMB)"), __("Normal (%dMB)"), __("Full (%dMB)") ], \@sizes; + $sizes[2] > $sizes[1] + 200 or splice(@l, 1, 1), splice(@sizes, 1, 1); #- not worth proposing too alike stuff + $sizes[1] > $sizes[0] + 100 or splice(@l, 1, 1), splice(@sizes, 1, 1); + my $choice = $o->ask_from_list('', 'TODOMESSAGE', \@l); + $sizes[find_index { $_ eq $choice } @l] * 1024 * 1024; + } else { + $o->chooseSizeToInstall($packages, $min_size, $max_size, $availableC, $individual) || goto &choosePackages; + } + }; ($o->{packages_}{ind}) = pkgs::setSelectedFromCompssList($o->{compssListLevels}, $packages, $min_mark, $size2install, $o->{installClass}); } diff --git a/perl-install/loopback.pm b/perl-install/loopback.pm index da89f1e5e..1a90e1091 100644 --- a/perl-install/loopback.pm +++ b/perl-install/loopback.pm @@ -99,18 +99,9 @@ sub inspect { sub getFree { my ($dir, $part) = @_; - my ($freespace); - - if ($dir) { - my $buf = ' ' x 20000; - syscall_('statfs', $dir, $buf) or return; - my (undef, $blocksize, $size, undef, $free, undef) = unpack "L2L4", $buf; - $_ *= $blocksize / 512 foreach $free; - - $freespace = $free; - } else { - $freespace = $part->{size}; - } + my $freespace = $dir ? + 2 * (common::df($dir))[1] : #- df in KiB + $part->{size}; $freespace - sum map { $_->{size} } @{$part->{loopback} || []}; } diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index af23fe99d..dc3813baf 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -36,6 +36,7 @@ use c; ); #- HACK: rating += 50 for some packages (like kapm, cf install_any::setPackages) #- HACK: rating += 10 if the group is selected and it is not a kde package (aka name !~ /^k/) +#- HACK: rating += 1 if the group is selected and it is a kde package (aka name !~ /^k/) @skip_list = qw( @@ -706,10 +707,12 @@ sub setSelectedFromCompssList { selectPackage($packages, $p, 0, \%newSelection); #- this enable an incremental total size. + my $old_nb = $nb; foreach (grep { $newSelection{$_} } keys %newSelection) { $nb += packageSize($packages->[0]{$_}); } if ($max_size && $nb > $max_size) { + $nb = $old_nb; $min_level = $p->{values}[$ind]; last; } @@ -721,6 +724,19 @@ sub setSelectedFromCompssList { $ind, $min_level; } +#- usefull to know the size it would take for a given min_level/max_size +#- just saves the selected packages, call setSelectedFromCompssList and restores the selected packages +sub fakeSetSelectedFromCompssList { + my ($compssListLevels, $packages, $min_level, $max_size, $install_class) = @_; + my @l = values %{$packages->[0]}; + my @flags = map { pkgs::packageFlagSelected($_) } @l; + my (undef, $level) = setSelectedFromCompssList($compssListLevels, $packages, $min_level, $max_size, $install_class); + my $size = pkgs::selectedSize($packages); + mapn { pkgs::packageSetFlagSelected(@_) } \@l, \@flags; + $size, $level; +} + + sub init_db { my ($prefix, $isUpgrade) = @_; diff --git a/perl-install/share/list.i386 b/perl-install/share/list.i386 index 7ef3bed87..9575f3896 100644 --- a/perl-install/share/list.i386 +++ b/perl-install/share/list.i386 @@ -1,5 +1,6 @@ /sbin/ifport /sbin/mkdosfs +/sbin/resize_reiserfs /usr/X11R6/bin/XF86_FBDev /usr/X11R6/bin/XF86_VGA16 /usr/X11R6/bin/xmodmap |