diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2005-09-02 15:39:15 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2005-09-02 15:39:15 +0000 |
commit | b8a0b61228f4086bedb20590d65b5d2060e2565b (patch) | |
tree | 907eeb08722855c99b29aabdc665c5051e080a9b /perl-install/pkgs.pm | |
parent | 81ea6be5a28c7575227cd5658947246261f9ffa4 (diff) | |
download | drakx-b8a0b61228f4086bedb20590d65b5d2060e2565b.tar drakx-b8a0b61228f4086bedb20590d65b5d2060e2565b.tar.gz drakx-b8a0b61228f4086bedb20590d65b5d2060e2565b.tar.bz2 drakx-b8a0b61228f4086bedb20590d65b5d2060e2565b.tar.xz drakx-b8a0b61228f4086bedb20590d65b5d2060e2565b.zip |
- new functionality: upgrade_by_removing_pkgs, enabled when upgrading redhat and conectiva distributions
- add file upgrade-map.conectiva.10 for precise choice of packages
- save /etc/xxx-release into /root/drakx/xxx-release.upgrading when starting
- release_file(): look for xxx-release.upgrading first
- find_root_parts(): better logging about upgrade_by_removing_pkgs, and factorize code
- when all packages are installed, remove xxx-release.upgrading and rename pkgs::removed_pkgs_to_upgrade_file()
Diffstat (limited to 'perl-install/pkgs.pm')
-rw-r--r-- | perl-install/pkgs.pm | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index 799f95a46..3eb471b5c 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -1230,6 +1230,87 @@ sub install { fs::loopback::save_boot($loop_boot); } +sub upgrade_by_removing_pkgs { + my ($packages, $callback, $extension, $o_map) = @_; + + log::l("upgrade_by_removing_pkgs (extension=$extension, map=$o_map)"); + + #- put the release file in /root/drakx so that we continue an upgrade even if the file has gone + my $f = common::release_file($::prefix); + if (dirname($f) eq '/etc') { + output_p("$::prefix/root/drakx/" . basename($f) . '.upgrading', cat_("$::prefix$f")); + } + my $busy_var_tmp = "$::prefix/var/tmp/ensure-rpm-does-not-remove-this-dir"; + touch($busy_var_tmp); + + my @was_installed = remove_pkgs_to_upgrade($packages, $callback, $extension); + + { + my @restore_files = qw(/etc/passwd /etc/group /etc/ld.so.conf); + foreach (@restore_files) { + rename "$::prefix$_.rpmsave", "$::prefix$_"; + } + install_any::create_minimal_files(); + unlink $busy_var_tmp; + } + + if ($o_map) { + my @l = glob("$o_map*"); + @l == 0 and log::l("upgrade_by_removing_pkgs: no map matching $o_map*"); + @l > 1 and log::l("upgrade_by_removing_pkgs: many maps (" . join(' ', @l) . ")"); + $o_map = $l[0]; + } + my %map = map { + chomp; + my ($name, @new) = split; + $name => \@new; + } $o_map ? cat_($o_map) : (); + + log::l("upgrade_by_removing_pkgs: map $o_map gave " . (int keys %map) . " rules"); + + my $log; + my @to_install = uniq(map { + $log .= " $_=>" . join('+', @{$map{$_}}) if $map{$_}; + $map{$_} ? @{$map{$_}} : $_; + } @was_installed); + log::l("upgrade_by_removing_pkgs special maps:$log"); + log::l("upgrade_by_removing_pkgs: wanted packages: ", join(' ', sort @to_install)); + + @to_install; +} + +sub removed_pkgs_to_upgrade_file() { "$::prefix/root/drakx/removed_pkgs_to_upgrade" } + +sub remove_pkgs_to_upgrade { + my ($packages, $callback, $extension) = @_; + + my @to_remove; + my @was_installed; + { + $packages->{rpmdb} ||= pkgs::rpmDbOpen(); + $packages->{rpmdb}->traverse(sub { + my ($pkg) = @_; + if ($pkg->release =~ /$extension$/) { + push @was_installed, $pkg->name; + push @to_remove, scalar $pkg->fullname; + } + }); + } + if (-e removed_pkgs_to_upgrade_file()) { + log::l("removed_pkgs_to_upgrade: using saved installed packages list ", removed_pkgs_to_upgrade_file()); + @was_installed = chomp_(cat_(removed_pkgs_to_upgrade_file())); + } else { + log::l("removed_pkgs_to_upgrade: saving (old) installed packages in ", removed_pkgs_to_upgrade_file()); + output_p(removed_pkgs_to_upgrade_file(), map { "$_\n" } @was_installed); + } + + delete $packages->{rpmdb}; #- make sure rpmdb is closed before. + + remove(\@to_remove, $callback, noscripts => 1); + + @was_installed; +} + sub remove_marked_ask_remove { my ($packages, $callback) = @_; |