[yocto] [PATCH 1/7] Add buildhistory-diff as attachment to email
Marius Avram
marius.avram at intel.com
Wed Aug 13 06:32:02 PDT 2014
buildhistory-diff is useful in the case new files have been
added to the package.
Signed-off-by: Marius Avram <marius.avram at intel.com>
---
bitbake.py | 28 ++++++++++++++++++++++++++++
recipe.py | 3 +--
upgradehelper.py | 21 ++++++++++++++-------
3 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/bitbake.py b/bitbake.py
index e56ee6d..2207634 100644
--- a/bitbake.py
+++ b/bitbake.py
@@ -24,6 +24,7 @@
import os
import logging as log
+from logging import info as I
from logging import debug as D
from logging import error as E
import sys
@@ -97,3 +98,30 @@ class Bitbake(object):
def dependency_graph(self, package_list):
return self._cmd(package_list, "-g")
+
+class BuildHistory(object):
+ def __init__(self, build_dir):
+ self.build_dir = build_dir
+ self.work_dir = None
+
+ def set_work_dir(self, work_dir):
+ self.work_dir = work_dir
+
+ # Return True if buildhistory-diff gives output
+ def diff(self, revision_steps):
+ os.chdir(self.build_dir)
+ cmd = "buildhistory-diff HEAD~" + str(revision_steps)
+
+ try:
+ stdout, stderr = bb.process.run(cmd)
+ # Write diff output to log file if there is any
+ if stdout and os.path.exists(self.work_dir):
+ with open(os.path.join(self.work_dir, "buildhistory.txt"), "w+") as log:
+ log.write(stdout)
+ return True
+ except bb.process.ExecutionError as e:
+ D("%s returned:\n%s" % (cmd, e.__str__()))
+ raise Error("\'" + cmd + "\' failed", e.stdout, e.stderr)
+
+ return False
+
diff --git a/recipe.py b/recipe.py
index cbb8ded..a495b49 100644
--- a/recipe.py
+++ b/recipe.py
@@ -408,7 +408,7 @@ class Recipe(object):
failed_tasks[task_log_match.group(2)] = (task_log_match.group(3), task_log_match.group(1))
elif qa_issue_match:
# Improvise path to log file
- failed_tasks[qa_issue_match.group(1)] = ("do_package", self.bb.get_stdout_log())
+ failed_tasks[qa_issue_match.group(1)] = ("do_package", self.bb.get_stdout_log())
elif machine_match:
machine = machine_match.group(1)
@@ -647,4 +647,3 @@ class Recipe(object):
# throw a compilation exception for everything else. It
# doesn't really matter
raise CompilationError()
-
diff --git a/upgradehelper.py b/upgradehelper.py
index 006dd0b..091881f 100755
--- a/upgradehelper.py
+++ b/upgradehelper.py
@@ -123,6 +123,7 @@ class Updater(object):
os.mkdir(self.uh_dir)
self.bb = Bitbake(get_build_dir())
+ self.buildhistory = BuildHistory(get_build_dir())
self.git = None
self.author = None
@@ -253,6 +254,14 @@ class Updater(object):
I(" %s: compiling for %s ..." % (self.pn, machine))
self.recipe.compile(machine)
+ def _review(self):
+ # Check build_history
+ if not self.skip_compilation:
+ I(" %s: Checking buildhistory ..." % self.pn)
+ self.buildhistory.set_work_dir(self.workdir)
+ if self.buildhistory.diff(len(self.machines)):
+ I(" %s: Wrote buildhistory-diff output ..." % self.pn)
+
def _check_upstream_versions(self, packages=[("universe", None, None)]):
I(" Fetching upstream version(s) ...")
@@ -605,14 +614,12 @@ class UniverseUpdater(Updater, Email):
msg_body += self.mail_footer
+ # Add possible attachments to list
attachments = []
- if self.patch_file is not None:
- attachments.append(self.patch_file)
- # License issue
- if status == "LicenseError":
- attachments.append(self.recipe.license_diff_file)
- elif err is not None:
- attachments.append(os.path.join(self.workdir, "bitbake_log.txt"))
+ for attachment in os.listdir(self.workdir):
+ attachment_fullpath = os.join(self.workdir, attachment)
+ if isfile(attachment_fullpath):
+ attachments.append(attachment_fullpath)
self.send_email(to_addr, subject, msg_body, attachments)
--
1.7.9.5
More information about the yocto
mailing list