summaryrefslogtreecommitdiffstats
path: root/perl-install/install_any.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2005-08-10 15:53:58 +0000
committerPascal Rigaux <pixel@mandriva.com>2005-08-10 15:53:58 +0000
commitf786204348dddd142915a70ad2d728a39853bc7e (patch)
treea0ef4f526ba519bc058d69c460283ee2cf90d294 /perl-install/install_any.pm
parent54af75fc5ae98319025da96056938cd6918f320e (diff)
downloaddrakx-backup-do-not-use-f786204348dddd142915a70ad2d728a39853bc7e.tar
drakx-backup-do-not-use-f786204348dddd142915a70ad2d728a39853bc7e.tar.gz
drakx-backup-do-not-use-f786204348dddd142915a70ad2d728a39853bc7e.tar.bz2
drakx-backup-do-not-use-f786204348dddd142915a70ad2d728a39853bc7e.tar.xz
drakx-backup-do-not-use-f786204348dddd142915a70ad2d728a39853bc7e.zip
- if we have a lot of memory, keep the clp in tmpfs
- check the size available in $::prefix/tmp for the case it's on its own filesystem (bug #15377) - also check the size available in other cases
Diffstat (limited to 'perl-install/install_any.pm')
-rw-r--r--perl-install/install_any.pm46
1 files changed, 36 insertions, 10 deletions
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 8da749fed..203d87058 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -1888,20 +1888,46 @@ sub write_fstab {
fs::write_fstab($o->{all_hds}, $o->{prefix}) if !$o->{isUpgrade} || $o->{migrate_device_names};
}
-my $clp_name = 'mdkinst.clp';
-sub clp_on_tmpfs() { "/tmp/$clp_name" }
-sub clp_on_disk() { "$::prefix/tmp/$clp_name" }
+sub move_clp_to_disk {
+ my ($fstab) = @_;
-sub move_clp_to_disk() {
- return if -e clp_on_disk() || $::local_install;
+ our $clp_on_disk;
+ return if $clp_on_disk || $::local_install;
+ my $clp_name = 'mdkinst.clp';
my ($loop, $current_clp) = devices::find_clp_loop($clp_name) or return;
- log::l("move_clp_to_disk: copying $current_clp to ", clp_on_disk());
- cp_af($current_clp, clp_on_disk());
- run_program::run('losetup', '-r', $loop, clp_on_disk());
+ my $clp_size = (-s $current_clp) / 1024; #- put in KiB
+
+ my $clp_dir;
+ if (availableRamMB() > 400) {
+ $clp_dir = '/tmp'; #- on tmpfs
+ } else {
+ my $tmp = fs::get::mntpoint2part('/tmp', $fstab);
+ if ($tmp && fs::df($tmp, $::prefix) / 2 > $clp_size * 1.2) { #- we want at least 20% free afterwards
+ $clp_dir = "$::prefix/tmp";
+ } else {
+ my $root = fs::get::mntpoint2part('/', $fstab);
+ my $root_free_MB = fs::df($root, $::prefix) / 2 / 1024;
+ my $wanted_size_MB = $o->{isUpgrade} || fs::get::mntpoint2part('/usr', $fstab) ? 150 : 300;
+ log::l("clp: root free $root_free_MB MB, wanted at least $wanted_size_MB MB");
+ if ($root_free_MB > $wanted_size_MB) {
+ $clp_dir = $tmp ? $::prefix : "$::prefix/tmp";
+ } else {
+ $clp_dir = '/tmp'; #- on tmpfs
+ if (availableRamMB() < 200) {
+ log::l("ERROR: not much ram (" . availableRamMB() . " MB), we're going in the wall!");
+ }
+ }
+ }
+ }
+ $clp_on_disk = "$clp_dir/$clp_name";
- #- in $current_clp eq "/tmp/$clp_name"
- unlink clp_on_tmpfs();
+ if ($current_clp ne $clp_on_disk) {
+ log::l("move_clp_to_disk: copying $current_clp to $clp_on_disk");
+ cp_af($current_clp, $clp_on_disk);
+ run_program::run('losetup', '-r', $loop, $clp_on_disk);
+ unlink $current_clp if $current_clp eq "/tmp/$clp_name";
+ }
}
#-###############################################################################