From 2d334b04228f9ac254b21816567e45a6e08fe9d4 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 18 Mar 2008 09:11:33 +0000 Subject: handle need_restart() rooted (not very useful, except for tests!) --- urpm/main_loop.pm | 2 +- urpm/sys.pm | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm index ff81ee7a..c02e6004 100644 --- a/urpm/main_loop.pm +++ b/urpm/main_loop.pm @@ -307,7 +307,7 @@ if ($nok) { print N("Installation is possible"), "\n"; } elsif (intersection([ keys %{$state->{selected}} ], [ keys %{$urpm->{provides}{'should-restart'}} ])) { - if (my $need_restart_formatted = urpm::sys::need_restart_formatted()) { + if (my $need_restart_formatted = urpm::sys::need_restart_formatted($urpm->{root})) { $callbacks->{need_restart}($need_restart_formatted) if $callbacks->{need_restart}; } } diff --git a/urpm/sys.pm b/urpm/sys.pm index 08baa0ff..acbc5a9e 100644 --- a/urpm/sys.pm +++ b/urpm/sys.pm @@ -161,9 +161,11 @@ sub _launched_time { } } -sub need_restart() { +sub need_restart { + my ($root) = @_; my $rpm_qf = '%{name} %{installtime} [%{provides}:%{Provideversion} ]\n'; - open(my $F, "rpm -q --whatprovides should-restart --qf '$rpm_qf' | uniq |"); + my $options = ($root ? "--root $root " : '') . "-q --whatprovides should-restart --qf '$rpm_qf'"; + open(my $F, "rpm $options | uniq |"); my (%need_restart, %launched_time); while (my $line = <$F>) { @@ -181,8 +183,9 @@ sub need_restart() { %need_restart && \%need_restart; } -sub need_restart_formatted() { - my $need_restart = need_restart() or return; +sub need_restart_formatted { + my ($root) = @_; + my $need_restart = need_restart($root) or return; foreach (keys %$need_restart) { $need_restart->{$_} = N("You should restart %s for %s", translate($_), join(', ', sort @{$need_restart->{$_}})); -- cgit v1.2.1