summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-03-17 17:20:02 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-03-17 17:20:02 +0000
commitf0bc8483bcb43e955862a375161e99658dce49b1 (patch)
tree276202f7f8763d68db149d541d1c10a4af6b79c8
parent969efed0bf6ffea584f378ae89ec28a89e02254f (diff)
downloadurpmi-f0bc8483bcb43e955862a375161e99658dce49b1.tar
urpmi-f0bc8483bcb43e955862a375161e99658dce49b1.tar.gz
urpmi-f0bc8483bcb43e955862a375161e99658dce49b1.tar.bz2
urpmi-f0bc8483bcb43e955862a375161e99658dce49b1.tar.xz
urpmi-f0bc8483bcb43e955862a375161e99658dce49b1.zip
- urpmi:
o tell the user to "restart system" when it is needed
-rw-r--r--NEWS1
-rw-r--r--urpm/main_loop.pm7
-rw-r--r--urpm/sys.pm47
-rwxr-xr-xurpmi4
4 files changed, 58 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 42b19a32..75714cb8 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,5 @@
- urpmi:
+ o tell the user to "restart system" when it is needed
o nicer error message when database is locked (#38923)
Version 5.13 - 17 March 2008, by Pascal "Pixel" Rigaux
diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm
index 14edf494..ff81ee7a 100644
--- a/urpm/main_loop.pm
+++ b/urpm/main_loop.pm
@@ -28,7 +28,7 @@ use urpm::media;
use urpm::select;
use urpm::get_pkgs;
use urpm::signature;
-use urpm::util qw(untaint difference2 member partition);
+use urpm::util qw(untaint difference2 intersection member partition);
# locking is left to callers
sub run {
@@ -305,6 +305,11 @@ if ($nok) {
} elsif ($test && $exit_code == 0) {
#- Warning : the following message is parsed in urpm::parallel_*
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()) {
+ $callbacks->{need_restart}($need_restart_formatted) if $callbacks->{need_restart};
+ }
}
}
}
diff --git a/urpm/sys.pm b/urpm/sys.pm
index f40cc401..08baa0ff 100644
--- a/urpm/sys.pm
+++ b/urpm/sys.pm
@@ -150,6 +150,53 @@ sub check_fs_writable () {
1;
}
+sub _launched_time {
+ my ($component) = @_;
+
+ if ($component eq N_("system")) {
+ my ($uptime) = cat_('/proc/uptime') =~ /(\S+)/;
+ time() - $uptime;
+ } else {
+ 1; # TODO
+ }
+}
+
+sub need_restart() {
+ my $rpm_qf = '%{name} %{installtime} [%{provides}:%{Provideversion} ]\n';
+ open(my $F, "rpm -q --whatprovides should-restart --qf '$rpm_qf' | uniq |");
+
+ my (%need_restart, %launched_time);
+ while (my $line = <$F>) {
+ my ($name, $installtime, $s) = $line =~ /(\S+)\s+(\S+)\s+(.*)/;
+
+ my @should_restart = $s =~ /should-restart:(\S+)/g;
+ foreach my $component (@should_restart) {
+ $launched_time{$component} ||= _launched_time($component);
+
+ if ($launched_time{$component} < $installtime) {
+ push @{$need_restart{$component}}, $name;
+ }
+ }
+ }
+ %need_restart && \%need_restart;
+}
+
+sub need_restart_formatted() {
+ my $need_restart = need_restart() or return;
+
+ foreach (keys %$need_restart) {
+ $need_restart->{$_} = N("You should restart %s for %s", translate($_), join(', ', sort @{$need_restart->{$_}}));
+ }
+ $need_restart;
+}
+
+# useful on command-line: perl -Murpm::sys -e 'urpm::sys::print_need_restart'
+sub print_need_restart() {
+ my $h = need_restart_formatted();
+ print "$_\n" foreach values %$h;
+}
+
+
#- create a plain rpm from an installed rpm and a delta rpm (in the current directory)
#- returns the new rpm filename in case of success
#- params :
diff --git a/urpmi b/urpmi
index 9768304c..9229240a 100755
--- a/urpmi
+++ b/urpmi
@@ -666,6 +666,10 @@ my $exit_code = urpm::main_loop::run($urpm, $state,
my $yesexpr = N("Yy");
$force || message_input_($msg, boolean => 1) =~ /[$yesexpr]/;
},
+ need_restart => sub {
+ my ($need_restart_formatted) = @_;
+ print "$_\n" foreach values %$need_restart_formatted;
+ },
message => sub {
my ($_title, $msg) = @_; # graphical title
print $msg;