diff options
-rw-r--r-- | perl-install/install2.pm | 4 | ||||
-rw-r--r-- | perl-install/install_any.pm | 10 | ||||
-rw-r--r-- | perl-install/install_steps.pm | 4 | ||||
-rw-r--r-- | perl-install/install_steps_interactive.pm | 6 | ||||
-rw-r--r-- | perl-install/pkgs.pm | 88 |
5 files changed, 72 insertions, 40 deletions
diff --git a/perl-install/install2.pm b/perl-install/install2.pm index 5dd74dbb9..37b97a844 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -329,7 +329,7 @@ sub selectInstallClass { if ($o->{steps}{choosePackages}{entered} >= 1 && !$o->{steps}{doInstallStep}{done}) { $o->setPackages(\@install_classes); - $o->findPackagesToUpgrade() if $o->{isUpgrade}; + $o->selectPackagesToUpgrade() if $o->{isUpgrade}; } } @@ -404,7 +404,7 @@ sub formatPartitions { #-PADTODO sub choosePackages { $o->setPackages($o, \@install_classes) if $_[1] == 1; - $o->findPackagesToUpgrade($o) if $o->{isUpgrade} && $_[1] == 1; + $o->selectPackagesToUpgrade($o) if $o->{isUpgrade} && $_[1] == 1; $o->choosePackages($o->{packages}, $o->{compss}); $o->{packages}{$_}{selected} = 1 foreach @{$o->{base}}; } diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index 4bb4e9bc4..56e5be526 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -99,8 +99,8 @@ sub getAvailableSpace { do { $_->{mntpoint} eq '/' and return $_->{size} * 512 } foreach @{$o->{fstab}}; if ($::testing) { - log::l("taking 200MB for testing"); - return 200 << 20; + log::l("taking 2000MB for testing"); + return 2000 << 20; } die "missing root partition"; } @@ -132,13 +132,13 @@ sub setPackages($$) { } pkgs::setShowFromCompss($o->{compss}, $o->{installClass}, $o->{lang}); - ($o->{packages_}{ind}, $o->{packages_}{select_level}) = pkgs::setSelectedFromCompssList($o->{compssListLevels}, $o->{packages}, getAvailableSpace($o) * 0.7, $o->{installClass}, $o->{lang}); + ($o->{packages_}{ind}, $o->{packages_}{select_level}) = pkgs::setSelectedFromCompssList($o->{compssListLevels}, $o->{packages}, getAvailableSpace($o) * 0.7, $o->{installClass}, $o->{lang}, $o->{isUpgrade}); } -sub findPackagesToUpgrade($) { +sub selectPackagesToUpgrade($) { my ($o) = @_; - pkgs::findPackagesToUpgrade($o->{packages}, $o->{prefix}); + pkgs::selectPackagesToUpgrade($o->{packages}, $o->{prefix}); } sub addToBeDone(&$) { diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 545fa9677..26bb636af 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -131,9 +131,9 @@ sub setPackages { my ($o, $install_classes) = @_; install_any::setPackages($o, $install_classes); } -sub findPackagesToUpgrade { +sub selectPackagesToUpgrade { my ($o) = @_; - install_any::findPackagesToUpgrade($o); + install_any::selectPackagesToUpgrade($o); } sub choosePackages($$$) { diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index db357c342..b2e84025a 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -155,10 +155,10 @@ sub setPackages { $o->SUPER::setPackages($install_classes); } #------------------------------------------------------------------------------ -sub findPackagesToUpgrade { +sub selectPackagesToUpgrade { my ($o) = @_; - my $w = $o->wait_message('', _("Finding package to upgrade")); - $o->SUPER::findPackagesToUpgrade(); + my $w = $o->wait_message('', _("Finding packages to upgrade")); + $o->SUPER::selectPackagesToUpgrade(); } #------------------------------------------------------------------------------ sub configureNetwork($) { diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index 489c2dc83..bc873e86c 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -37,18 +37,22 @@ sub allpackages { sub select($$;$) { my ($packages, $p, $base) = @_; my ($n, $v); - $p->{base} ||= $base; - $p->{selected} = -1; #- selected by user - my %l; @l{@{$p->{deps} || die "missing deps file"}} = (); - while (do { my %l = %l; while (($n, $v) = each %l) { last if $v != 1; } $n }) { - $l{$n} = 1; - my $i = Package($packages, $n) or next; - $i->{base} ||= $base; - $i->{deps} or log::l("missing deps for $n"); - unless ($i->{selected}) { - $l{$_} ||= 0 foreach @{$i->{deps} || []}; + unless ($p->{installed}) { #- if the same or better version is installed, do not select. + $p->{base} ||= $base; + $p->{selected} = -1; #- selected by user + my %l; @l{@{$p->{deps} || die "missing deps file"}} = (); + while (do { my %l = %l; while (($n, $v) = each %l) { last if $v != 1; } $n }) { + $l{$n} = 1; + my $i = Package($packages, $n) or next; + $i->{base} ||= $base; + $i->{deps} or log::l("missing deps for $n"); + unless ($i->{installed}) { + unless ($i->{selected}) { + $l{$_} ||= 0 foreach @{$i->{deps} || []}; + } + $i->{selected}++ unless $i->{selected} == -1; + } } - $i->{selected}++ unless $i->{selected} == -1; } 1; } @@ -231,8 +235,8 @@ sub setShowFromCompss($$$) { } } -sub setSelectedFromCompssList($$$$$) { - my ($compssListLevels, $packages, $size, $install_class, $lang) = @_; +sub setSelectedFromCompssList($$$$$$) { + my ($compssListLevels, $packages, $size, $install_class, $lang, $isUpgrade) = @_; my ($level, $ind) = 100; my @packages = values %$packages; @@ -249,13 +253,13 @@ sub setSelectedFromCompssList($$$$$) { last if $level == 0; verif_lang($p, $lang) or next; - &select($packages, $p); + &select($packages, $p) unless $isUpgrade; my $nb = 0; foreach (@packages) { $nb += $_->{size} if $_->{selected}; } if ($nb > $size) { - unselect($packages, $p, $nb - $size); + unselect($packages, $p, $nb - $size) unless $isUpgrade; last; } } @@ -288,7 +292,7 @@ sub getHeader($) { $p->{header}; } -sub findPackagesToUpgrade($$) { +sub selectPackagesToUpgrade($$) { my ($packages, $prefix) = @_; log::l("reading /usr/lib/rpm/rpmrc"); @@ -296,13 +300,19 @@ sub findPackagesToUpgrade($$) { log::l("\tdone"); my $db = c::rpmdbOpenForTraversal($prefix) or die "unable to open $prefix/var/lib/rpm/packages.rpm"; - my %installedFilesToRemove; #- files installed but not present in the package to upgrade -> to remove. + my %installedFilesForUpgrade; #- help searching package to upgrade in regard to already installed files. - #- mark all files which are not in /etc/rc.d/ for packages which are already installed. + #- mark all files which are not in /etc/rc.d/ for packages which are already installed but which + #- are not in the packages list to upgrade. c::rpmdbTraverse($db, sub { my ($header) = @_; - my @filenames = c::headerGetEntry($header, 'filenames'); - @installedFilesToRemove{grep { $_ !~ m@/etc/rc.d/@ } @filenames} = (); + my $p = $packages->{c::headerGetEntry($header, 'name')}; + if ($p) { + $p->{installed} = 1 if c::headerGetEntry($header, 'version') ge $p->{version}; + } else { + my @installedFiles = c::headerGetEntry($header, 'filenames'); + @installedFilesForUpgrade{grep { $_ !~ m@^/etc/rc.d/@ } @installedFiles} = (); + } }); #- find new packages to upgrade. @@ -313,17 +323,32 @@ sub findPackagesToUpgrade($$) { my ($header) = @_; $skipThis ||= (c::headerGetEntry($header, 'version') ge $p->{version}); }) == 0; #- skip if not installed (package not found in current install). + #- select the package if it is already installed with a lower version or simply not installed. - pkgs::select($packages, $p) unless ($skipThis || $p->{selected}); + unless ($skipThis) { + pkgs::select($packages, $p) unless $p->{selected}; + + #- keep in mind installed files which are not being updated. doing this costs in + #- execution time but use less memory, else hash all installed files and unhash + #- all file for package marked for upgrade. + c::rpmdbNameTraverse($db, $p->{name}, sub { + my ($header) = @_; + my @installedFiles = c::headerGetEntry($header, 'filenames'); + @installedFilesForUpgrade{ grep { $_ !~ m@^/etc/rc.d/@ } @installedFiles} = (); + }); + my @availFiles = $p->{header} ? c::headerGetEntry($p->{header}, 'filenames') : (); + map { delete $installedFilesForUpgrade{$_} } grep { $_ !~ m@^/etc/rc.d/@ } @availFiles; + } } - #- unmark all files for all packages marked for upgrade. + #- unmark all files for all packages marked for upgrade. it may not have been done above + #- since some packages may have been selected by depsList. foreach (values %$packages) { my $p = $_; if ($p->{selected}) { - my @availFiles = $p->{filename} ? c::headerGetEntry($p->{header}, 'filename') : (); - map { delete $installedFilesToRemove{$_} } grep { $_ !~ m@/etc/rc.d/@ } @availFiles; + my @availFiles = $p->{header} ? c::headerGetEntry($p->{header}, 'filenames') : (); + map { delete $installedFilesForUpgrade{$_} } grep { $_ !~ m@^/etc/rc.d/@ } @availFiles; } } @@ -332,15 +357,22 @@ sub findPackagesToUpgrade($$) { my $p = $_; unless ($p->{selected}) { - my @availFiles = $p->{filename} ? c::headerGetEntry($p->{header}, 'filename') : (); + my @availFiles = $p->{header} ? c::headerGetEntry($p->{header}, 'filenames') : (); my $toSelect = 0; - map { if (exists $installedFilesToRemove{$_}) { - $toSelect = 1; delete $installedFilesToRemove{$_} } } grep { $_ !~ m@/etc/rc.d/@ } @availFiles; + map { if (exists $installedFilesForUpgrade{$_}) { + $toSelect = 1; delete $installedFilesForUpgrade{$_} } } grep { $_ !~ m@^/etc/rc.d/@ } @availFiles; pkgs::select($packages, $p) if ($toSelect); } } - #- select packages which obseletes other package, TODO. + #- select packages which obseletes other package, obselete package are not removed, + #- should we remove them ? this could be dangerous ! + foreach (values %$packages) { + my $p = $_; + + my @obsoletes = $p->{header} ? c::headerGetEntry($p->{header}, 'obsoletes') : (); + map { pkgs::select($packages, $p) if c::rpmdbNameTraverse($db, $_) > 0 } @obsoletes; + } #- consistency check: deselect all packages with a version lower to already existing. foreach (values %$packages) { |