The following commit has been merged in the master branch:
commit 9fac3bb4985e11a54b3192742149c34f444c3997
Author: Raphael Hertzog <hert...@debian.org>
Date:   Sat Feb 21 18:40:18 2009 +0100

    update-alternatives: add logging to /var/log/dpkg.log
    
    Add logging statements in update-alternatives for all calls that can
    modify the status of the link group. Also log explicitely alternative
    removal, auto-reparation and update. Closes: #445270

diff --git a/ChangeLog b/ChangeLog
index f8dd03e..59f5a57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-02-22  Raphael Hertzog  <hert...@debian.org>
 
+       * scripts/update-alternatives.pl: Add logging to
+       /var/log/dpkg.log.
+
+2009-02-22  Raphael Hertzog  <hert...@debian.org>
+
        * man/update-alternatives.8: The vocabulary used was misleading
        and not really uniform. Try to standardize and make it match with
        the vocabulary used in the source code too.
diff --git a/debian/changelog b/debian/changelog
index 06275f4..49d0f70 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -156,6 +156,7 @@ dpkg (1.15.0) UNRELEASED; urgency=low
   * Rewrite update-alternatives (so that we can understand it again) and
     implement new features on top of it:
     - the --config output is now sorted. Closes: #437060
+    - it now logs information to /var/log/dpkg.log. Closes: #445270
 
   [ Pierre Habouzit ]
   * Add a --query option to update-alternatives. Closes: #336091, #441904
diff --git a/scripts/update-alternatives.pl b/scripts/update-alternatives.pl
index dd98260..5076d84 100755
--- a/scripts/update-alternatives.pl
+++ b/scripts/update-alternatives.pl
@@ -32,6 +32,7 @@ $| = 1;
 # Main program
 #
 
+my @COPY_ARGV = @ARGV;
 while (@ARGV) {
     $_ = shift(@ARGV);
     last if m/^--$/;
@@ -136,6 +137,7 @@ if ($action eq 'display') {
 }
 
 # Actions below might modify the system
+log_msg("run with @COPY_ARGV");
 
 my $current_choice = '';
 if ($alternative->has_current_link()) {
@@ -245,13 +247,15 @@ if ($action eq 'set') {
 
 # No choice left, remove everything
 if (not scalar($alternative->choices())) {
+    log_msg("link group " . $alternative->name() . " fully removed");
     $alternative->remove();
     exit 0;
 }
 
 # New choice wanted
-#print "NEW: $new_choice, was $current_choice\n";
 if (defined($new_choice) and ($current_choice ne $new_choice)) {
+    log_msg("link group " . $alternative->name() .
+            " updated to point to " . $new_choice);
     printf _g("Using '%s' to provide '%s' in %s.") . "\n", $new_choice,
            $alternative->name(),
            ($alternative->status() eq "auto" ? _g("auto mode") : _g("manual 
mode"))
@@ -259,6 +263,7 @@ if (defined($new_choice) and ($current_choice ne 
$new_choice)) {
     $alternative->prepare_install($new_choice);
 } elsif ($alternative->is_broken()) {
     # TODO: warn & log
+    log_msg("auto-repair link group " . $alternative->name());
     $alternative->prepare_install($current_choice) if $current_choice;
 }
 
@@ -350,6 +355,24 @@ sub set_action {
     $action = $value;
 }
 
+{
+    my $fh_log;
+    sub log_msg {
+        my ($msg) = @_;
+        # XXX: the C rewrite must use the std function to get the
+        # filename from /etc/dpkg/dpkg.cfg or from command line
+        if (!defined($fh_log) and -w "/var/log/dpkg.log") {
+            open($fh_log, ">>", "/var/log/dpkg.log") ||
+                quit(_g("Can't append to %s"), "/var/log/dpkg.log");
+        }
+        if (defined($fh_log)) {
+            $msg = POSIX::strftime("%Y-%m-%d %H:%M:%S", localtime()) .
+                   " $progname: $msg\n";
+            print $fh_log $msg;
+        }
+    }
+}
+
 sub config_all {
     opendir(ADMINDIR, $admdir)
         or quit(_g("can't readdir %s: %s"), $admdir, $!);
@@ -525,6 +548,7 @@ sub set_status {
     if (!defined($self->status()) or $status ne $self->status()) {
         $self->{modified} = 1;
     }
+    main::log_msg("status of link group " . $self->name() . " set to $status");
     $self->{status} = $status;
 }
 sub set_link {

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to