summaryrefslogtreecommitdiffstats
path: root/urpm/select.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-09-09 08:06:28 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-09-09 08:06:28 +0000
commitd8cf4a35e631ca6ca54c18d247a5283cbb9bfcc4 (patch)
tree1a53003791e480bee0d0d7bc1be15eb0b16f3c4d /urpm/select.pm
parent740c2e83717643482caf3ba4133c5cf83b07563f (diff)
downloadurpmi-d8cf4a35e631ca6ca54c18d247a5283cbb9bfcc4.tar
urpmi-d8cf4a35e631ca6ca54c18d247a5283cbb9bfcc4.tar.gz
urpmi-d8cf4a35e631ca6ca54c18d247a5283cbb9bfcc4.tar.bz2
urpmi-d8cf4a35e631ca6ca54c18d247a5283cbb9bfcc4.tar.xz
urpmi-d8cf4a35e631ca6ca54c18d247a5283cbb9bfcc4.zip
- urpmi
o after installing in chroot, migrate back rpmdb db version to one compatible with the rpm in the chroot
Diffstat (limited to 'urpm/select.pm')
-rw-r--r--urpm/select.pm43
1 files changed, 43 insertions, 0 deletions
diff --git a/urpm/select.pm b/urpm/select.pm
index 6ae72bcb..3183eac8 100644
--- a/urpm/select.pm
+++ b/urpm/select.pm
@@ -10,6 +10,8 @@ use URPM;
my $default_priority_list = 'rpm,perl-URPM,perl-MDV-Distribconf,urpmi,meta-task,glibc';
my @priority_list = split(',', $default_priority_list);
+my $evr_re = qr/[^\-]*-[^\-]*\.[^\.\-]*$/;
+
sub add_packages_to_priority_upgrade_list {
@priority_list = uniq(@priority_list, @_);
}
@@ -573,6 +575,21 @@ sub translate_why_unselected_one {
$fullname . ($s ? " ($s)" : '');
}
+sub selected_packages_providing {
+ my ($urpm, $state, $name) = @_;
+ map { $urpm->{depslist}[$_] } grep { $state->{selected}{$_} } keys %{$urpm->{provides}{$name} || {}};
+}
+
+sub was_pkg_name_installed {
+ my ($rejected, $name) = @_;
+
+ foreach (keys %$rejected) {
+ /^\Q$name\E-$evr_re/ or next;
+ $rejected->{$_}{obsoleted} and return 1;
+ }
+ 0;
+}
+
sub removed_packages {
my (undef, $state) = @_;
grep {
@@ -623,4 +640,30 @@ sub translate_why_removed_one {
$fullname . ($s ? "\n ($s)" : '');
}
+sub _libdb_version { $_[0] =~ /libdb-(\S+)\.so/ ? eval "v$1" : () }
+
+sub should_we_migrate_back_rpmdb_db_version {
+ my ($urpm, $state) = @_;
+
+ my ($pkg) = urpm::select::selected_packages_providing($urpm, $state, 'rpm') or return;
+ urpm::select::was_pkg_name_installed($state->{rejected}, 'rpm') and return;
+ my ($rooted_librpm_version) = map { _libdb_version($_) } $pkg->requires;
+
+ my $urpmi_librpm_version = _libdb_version(scalar `ldd /bin/rpm`);
+
+ if ($urpmi_librpm_version ge v4.6) {
+ if ($rooted_librpm_version && $rooted_librpm_version ge v4.6) {
+ $urpm->{debug} and $urpm->{debug}("chrooted db version used by librpm is at least as good as non-rooted one");
+ } else {
+ foreach my $bin ('db_dump', 'db42_load') {
+ urpm::sys::whereis_binary($bin)
+ or $urpm->{error}("can not migrate rpm db from Hash version 9 to Hash version 8 without $bin"),
+ return;
+ }
+ return 1;
+ }
+ }
+ 0;
+}
+
1;