diff options
Diffstat (limited to 'urpm')
-rw-r--r-- | urpm/main_loop.pm | 2 | ||||
-rw-r--r-- | urpm/select.pm | 21 | ||||
-rw-r--r-- | urpm/sys.pm | 33 |
3 files changed, 56 insertions, 0 deletions
diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm index cb8fc1f2..6e4820ab 100644 --- a/urpm/main_loop.pm +++ b/urpm/main_loop.pm @@ -497,6 +497,8 @@ sub run { my (@errors, @formatted_errors); $exit_code = 0; + urpm::select::migrate_forward_rpmdb_db_if_needed($urpm, $state); + my $migrate_back_rpmdb_db_version = $urpm->{root} && urpm::select::should_we_migrate_back_rpmdb_db_version($urpm, $state); diff --git a/urpm/select.pm b/urpm/select.pm index a015f7a5..dbde19a3 100644 --- a/urpm/select.pm +++ b/urpm/select.pm @@ -756,6 +756,27 @@ sub should_we_migrate_back_rpmdb_db_version { 0; } +sub migrate_forward_rpmdb_db_if_needed { + my ($urpm, $state) = @_; + + my ($pkg) = selected_packages_providing($urpm, $state, 'rpm') or return; + my $rooted_rpm_version = version->new("v" . $pkg->version); # perl_checker: $self = revision + my $rpm_version = _rpm_version(); # perl_checker: $self = revision + + if ($rpm_version ge v4.16.0) { + if ($rooted_rpm_version && $rooted_rpm_version ge v4.16) { + $urpm->{debug} and $urpm->{debug}("chrooted db version used by librpm is at least as good as non-rooted one"); + if (-f "$urpm->{root}/var/lib/rpm/Packages") { + $urpm->{debug} and $urpm->{debug}("Migrating chrooted db"); + $urpm->{need_migrate_rpmdb_now} = '4.16'; + urpm::sys::migrate_forward_rpmdb_db_version($urpm, $urpm->{root}); + return 1; + } + } + } + 0; +} + 1; =back diff --git a/urpm/sys.pm b/urpm/sys.pm index b7cb1220..d8da722a 100644 --- a/urpm/sys.pm +++ b/urpm/sys.pm @@ -288,6 +288,39 @@ sub migrate_back_rpmdb_db_version { clean_rpmdb_shared_regions($root); } +=item migrate_rpmdb_to_sqlite($urpm, $root) + +Migrate rpmdb to the new sqlite backend. + +=cut + +sub migrate_rpmdb_to_sqlite { + my ($urpm, $root) = @_; + $urpm->{info}("migrating db from bdb to sqlite (rpm >= 4.16)"); + # Whatever is the default backend: + URPM::add_macro('_db_backend sqlite'); + if (system('chroot', $root, 'rpm', '--rebuilddb') == 0) { + $urpm->{log}("rpm db converted to sqlite successfully"); + } else { + $urpm->{error}("rpm db conversion failed. You will not be able to run rpm >= 4.17"); + } +} + +=item migrate_forward_rpmdb_db_version($urpm, $root) + +Check if we need to migrate rpmdb to a new backend prior to use it +and do it if needed. + +=cut + +sub migrate_forward_rpmdb_db_version { + my ($urpm, $root) = @_; + + if ($urpm->{need_migrate_rpmdb_now} eq '4.16') { + migrate_rpmdb_to_sqlite($urpm, $root); + } +} + =item apply_delta_rpm($deltarpm, $o_dir, $o_pkg) |