On Wed, Oct 22, 2014 at 07:35:40AM +0200, Alexandre Detiste wrote:
> control: reopen -1
>
> Since this change, the mail I receive contains the changes from all previous
> days.
>
> See multiple 'Log Started' in attached mail.
Thanks for your bugreport.
The attached patch should fix this problem. It will be part of the
next upload to unstable.
Cheers,
Michael
=== modified file 'test/test_mail.py'
--- test/test_mail.py 2014-02-06 00:06:25 +0000
+++ test/test_mail.py 2014-10-28 10:49:03 +0000
@@ -5,6 +5,7 @@
import apt_pkg
import os
import sys
+from textwrap import dedent
import unittest
from io import StringIO
@@ -18,9 +19,12 @@
class CommonTestsForMailxAndSendmail(object):
EXPECTED_MAIL_CONTENT_STRINGS = [
- "logfile_dpkg text",
+ "random logfile_dpkg text",
"mem_log text",
]
+ NOT_EXPECTED_MAIL_CONTENT_STRINGS = [
+ "old logfile text",
+ ]
def common_setup(self):
# monkey patch to make it testable
@@ -49,12 +53,25 @@
""")
logfile_dpkg = "./apt-term.log"
with open("./apt-term.log", "w") as fp:
- fp.write("logfile_dpkg text")
+ # note that we intentionally not have a "Log ended:" here
+ # because this may happen if something crashes power goes
+ # down etc
+ fp.write(dedent("""\
+ Log started: 2014-10-28 10:00
+ random logfile_dpkg text
+
+ Log started: 2013-01-01 12:00
+ old logfile text
+ Log ended: 2013-01-01 12:20
+ """))
return (pkgs, res, pkgs_kept_back, mem_log, logfile_dpkg)
def _verify_common_mail_content(self, mail_txt):
for expected_string in self.EXPECTED_MAIL_CONTENT_STRINGS:
self.assertTrue(expected_string in mail_txt)
+ for not_expected_string in self.NOT_EXPECTED_MAIL_CONTENT_STRINGS:
+ self.assertFalse(not_expected_string in mail_txt)
+ self.assertEqual(mail_txt.count("Log started: "), 1)
def test_summary_mail_reboot(self):
with open("./reboot-required", "w") as fp:
=== modified file 'unattended-upgrade'
--- unattended-upgrade 2014-10-15 08:05:10 +0000
+++ unattended-upgrade 2014-10-28 10:48:02 +0000
@@ -790,7 +790,10 @@
if os.path.exists(logfile_dpkg):
body += _("Package installation log:") + "\n"
with open(logfile_dpkg) as fp:
- body += fp.read()
+ for i, line in enumerate(fp.readlines()):
+ if i > 0 and line.startswith("Log started: "):
+ break
+ body += line
body += "\n\n"
body += _("Unattended-upgrades log:\n")
body += mem_log.getvalue()