From 674d1c5593bf6a2f036e4f32992f6c73bc0887a4 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Thu, 5 Mar 2020 15:53:56 +0100 Subject: add support for reinstall (needs rpm >= 4.12.x) --- NEWS | 2 ++ URPM.pm | 5 +++++ URPM.xs | 14 ++++++++++++++ URPM/Resolve.pm | 8 ++++++-- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 593b920..b6b72ab 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +- add support for reinstall (needs rpm >= 4.12.x) + Version 5.24.1 - 17 January 2020 - make test pass on most distros diff --git a/URPM.pm b/URPM.pm index aa2b5f0..7bf696c 100644 --- a/URPM.pm +++ b/URPM.pm @@ -837,6 +837,11 @@ Options are: update => 0 / 1 : indicates whether this is an upgrade excludepath => [ ... ] +=item $trans->addReinstall($pkg) + +Adds a package to be re-installed to the transaction represented by $trans. +$pkg is an C object. + =item $trans->remove($name) Adds a package to be erased to the transaction represented by $trans. diff --git a/URPM.xs b/URPM.xs index 465ed14..0b31798 100644 --- a/URPM.xs +++ b/URPM.xs @@ -2584,6 +2584,20 @@ Trans_add(trans, pkg, ...) OUTPUT: RETVAL +#ifdef RPM4_12_0 +int +Trans_addReinstall(trans, pkg) + URPM::Transaction trans + URPM::Package pkg + CODE: + if ((pkg->flag & FLAG_ID_MASK) <= FLAG_ID_MAX && pkg->h != NULL) + RETVAL = rpmtsAddReinstallElement(trans->ts, pkg->h, (fnpyKey)(1+(long)(pkg->flag & FLAG_ID_MASK))) == 0; + else RETVAL = 0; + OUTPUT: + RETVAL + +#endif + int Trans_remove(trans, name) URPM::Transaction trans diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm index 55f5c64..33504b5 100644 --- a/URPM/Resolve.pm +++ b/URPM/Resolve.pm @@ -1210,7 +1210,7 @@ sub resolve_requested__no_recommends_ { } else { _set_flag_installed_and_upgrade_if_no_newer($db, $pkg); - if ($pkg->flag_installed && !$pkg->flag_upgrade && !$urpm->{options}{downgrade}) { + if ($pkg->flag_installed && !$pkg->flag_upgrade && !$urpm->{options}{downgrade} && !$urpm->{options}{reinstall}) { _no_more_recent_installed_and_providing($urpm, $db, $state, $pkg, $dep->{required}) or next; } } @@ -1417,7 +1417,7 @@ sub _unselect_package_deprecated_by_property { #- remove this package from the list of packages to install, #- unless urpmi was invoked with --allow-force #- (in which case rpm could be invoked with --oldpackage) - if (!$urpm->{options}{'allow-force'} && !$urpm->{options}{downgrade}) { + if (!$urpm->{options}{'allow-force'} && !$urpm->{options}{downgrade} && !$urpm->{options}{reinstall}) { #- since the originally requested packages (or other #- non-installed ones) could be unselected by the following #- operation, remember them, to warn the user @@ -1429,6 +1429,10 @@ sub _unselect_package_deprecated_by_property { } } elsif ($satisfied) { $obsoleted = 1; + } elsif ($urpm->{options}{reinstall}) { + # So that we do not ask for "The following package has to be removed for others to be upgraded: + # foo-V-R (in order to install foo-V-R) (y/N)" + return; } } elsif ($satisfied) { $obsoleted = 1; -- cgit v1.2.1