Package: unattended-upgrades
Version: 0.82.8
Severity: wishlist
Tags: patch

Dear Maintainer,

I would like to have:

- the output of apt-listchanges for the upgraded packages in my
  unattended-upgrades mails

- the output of apt-listchanges for all other packages in an
  apt-listchanges mail

This permit to know why a package was automatically upgraded directly in
unattended-upgrades mail.

I provide a patch to override “APT_LISTCHANGES_FRONTEND” only when
apt-listchanges email address is configured and no sendmail is found,
there is no need to force it to none otherwise. 

Regards.

From a1026d1e2b3806c5830c7b309dcc93bc61eafe3f Mon Sep 17 00:00:00 2001
From: Daniel Dehennin <daniel.dehen...@baby-gnu.org>
Date: Thu, 24 Jul 2014 07:40:24 +0200
Subject: [PATCH] Remove useless override of apt-listchanges frontend
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Configuring apt-listchanges frontend to text must permit to get
apt-listchanges ouptut in unattended-upgrades logs and mail.

* unattended-upgrade (setup_apt_listchanges): Override
  “APT_LISTCHANGES_FRONTEND” only when apt-listchanges email address is
  configured and no sendmail exists.
---
 unattended-upgrade | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/unattended-upgrade b/unattended-upgrade
index 16b8cde..e98ce4b 100755
--- a/unattended-upgrade
+++ b/unattended-upgrade
@@ -37,7 +37,7 @@ import signal
 import string
 import subprocess
 import sys
-
+import configparser
 
 from email.message import Message
 from gettext import gettext as _
@@ -670,15 +670,19 @@ def wrap(t, width=70, subsequent_indent=""):
 
 
 def setup_apt_listchanges(conf="/etc/apt/listchanges.conf"):
-    """ deal with apt-listchanges """
-    # apt-listchanges will always send a mail if there is a mail address
-    # set in the config regardless of the frontend used, so set it to
-    # mail if we have a sendmail and to none if not (as it appears to
-    # not check if sendmail is there or not), debian bug #579733
-    if os.path.exists(SENDMAIL_BINARY):
-        os.environ["APT_LISTCHANGES_FRONTEND"] = "mail"
-    else:
-        os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
+    """deal with apt-listchanges
+
+    apt-listchanges will always send a mail if there is a mail address
+    set in the config regardless of the frontend used, so force it to
+    none if we don't have a sendmail (as it appears to not check if
+    sendmail is there or not), debian bug #579733
+
+    """
+    config = configparser.ConfigParser()
+    config.read(conf)
+    if "apt" in config and config["apt"].get("email_address"):
+        if not os.path.exists(SENDMAIL_BINARY):
+            os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
 
 
 def _send_mail_using_mailx(to_address, subject, body):
-- 
2.0.1


-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (90, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.15-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages unattended-upgrades depends on:
ii  apt                    1.0.6
ii  apt-utils              1.0.6
ii  debconf [debconf-2.0]  1.5.53
ii  init-system-helpers    1.19
ii  lsb-base               4.1+Debian13
ii  lsb-release            4.1+Debian13
ii  python3                3.4.1-1
ii  python3-apt            0.9.3.8
ii  ucf                    3.0030
ii  xz-utils               5.1.1alpha+20120614-2

unattended-upgrades recommends no packages.

Versions of packages unattended-upgrades suggests:
ii  bsd-mailx                                  8.1.2-0.20131005cvs-1
ii  exim4-daemon-light [mail-transport-agent]  4.82.1-1+b1

-- debconf information:
* unattended-upgrades/enable_auto_updates: false

-- 
Daniel Dehennin
Récupérer ma clef GPG: gpg --recv-keys 0xCC1E9E5B7A6FE2DF
Fingerprint: 3E69 014E 5C23 50E8 9ED6  2AAD CC1E 9E5B 7A6F E2DF

Attachment: signature.asc
Description: PGP signature

Reply via email to