diff mbox series

[AUH,2/2] upgrade-helper: attach a tarball with patches and other artefacts to summary emails

Message ID 20220719105052.638381-2-alex@linutronix.de
State New
Headers show
Series [AUH,1/2] emailhandler: correctly send binary attachments | expand

Commit Message

Alexander Kanavin July 19, 2022, 10:50 a.m. UTC
This is optional, enabled by default, and allows easy extraction of patches
and other information to one's local disk (no need to go over individual maintainer
emails).

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 upgrade-helper.conf |  4 ++++
 upgrade-helper.py   | 14 ++++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/upgrade-helper.conf b/upgrade-helper.conf
index 5696564..251c36a 100644
--- a/upgrade-helper.conf
+++ b/upgrade-helper.conf
@@ -57,6 +57,10 @@ 
 # public url with AUH results to include in statistics summary (optional)
 #publish_work_url=http://auh.somehost.com/work
 
+# whether to attach a tarball with AUH artefacts (patches, log, buildhistory, etc.)
+# to the summary email
+#summary_includes_tarball=True
+
 # clean sstate directory before upgrading
 # Generally not necessary, as bitbake can handle this automatically.
 #clean_sstate=no
diff --git a/upgrade-helper.py b/upgrade-helper.py
index ecdabb0..4393589 100755
--- a/upgrade-helper.py
+++ b/upgrade-helper.py
@@ -411,7 +411,7 @@  class Updater(object):
             I(" %s: %s" % (pkg_ctx['PN'], e.stdout))
             raise e
 
-    def send_status_mail(self, statistics_summary):
+    def send_status_mail(self, statistics_summary, attachments):
         if "status_recipients" not in settings:
             E(" Could not send status email, no recipients set!")
             return -1
@@ -425,7 +425,7 @@  class Updater(object):
             subject = "[AUH] Upgrade status: " + date.isoformat(date.today())
 
         if self.statistics.total_attempted:
-            self.email_handler.send_email(to_list, subject, statistics_summary)
+            self.email_handler.send_email(to_list, subject, statistics_summary, attachments)
         else:
             W("No recipes attempted, not sending status mail!")
 
@@ -536,9 +536,10 @@  class Updater(object):
 
         if attempted_pkgs > 0:
             publish_work_url = settings.get('publish_work_url', '')
+            attach_tarball = settings.get('summary_includes_tarball', True)
             work_tarball = os.path.join(self.uh_base_work_dir,
                     os.path.basename(self.uh_work_dir) + '.tar.gz')
-            if publish_work_url:
+            if publish_work_url or attach_tarball:
                 I(" Generating work tarball in %s ..." % work_tarball)
                 tar_cmd = ["tar", "-chzf", work_tarball, "-C", self.uh_base_work_dir, os.path.basename(self.uh_work_dir)]
                 import subprocess
@@ -546,6 +547,7 @@  class Updater(object):
                     E(" Work tarball (%s) generation failed..." % (work_tarball))
                     E(" Tar command: %s" % (" ".join(tar_cmd)))
                     publish_work_url = ''
+                    attach_tarball = False
 
             statistics_summary = self.statistics.get_summary(
                     publish_work_url, os.path.basename(self.uh_work_dir))
@@ -557,8 +559,12 @@  class Updater(object):
 
             I(" %s" % statistics_summary)
 
+            attachments = []
+            if attach_tarball:
+                attachments.append(work_tarball)
+
             if self.opts['send_email']:
-                self.send_status_mail(statistics_summary)
+                self.send_status_mail(statistics_summary, attachments)
 
 class UniverseUpdater(Updater):
     def __init__(self, args):