mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 13:29:49 +00:00
rootfs.py: add log checking ability for deb and ipk
Extract the common codes of log checking and add the ability of log checking for deb and ipk package backend. (From OE-Core rev: d995871b433643958845e1d476813fa12888100e) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
+44
-17
@@ -40,6 +40,43 @@ class Rootfs(object):
|
|||||||
def _log_check(self):
|
def _log_check(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _log_check_warn(self):
|
||||||
|
r = re.compile('^(warn|Warn|NOTE: warn|NOTE: Warn|WARNING:)')
|
||||||
|
log_path = self.d.expand("${T}/log.do_rootfs")
|
||||||
|
with open(log_path, 'r') as log:
|
||||||
|
for line in log.read().split('\n'):
|
||||||
|
if 'log_check' in line or 'NOTE:' in line:
|
||||||
|
continue
|
||||||
|
|
||||||
|
m = r.search(line)
|
||||||
|
if m:
|
||||||
|
bb.warn('log_check: There is a warn message in the logfile')
|
||||||
|
bb.warn('log_check: Matched keyword: [%s]' % m.group())
|
||||||
|
bb.warn('log_check: %s\n' % line)
|
||||||
|
|
||||||
|
def _log_check_error(self):
|
||||||
|
r = re.compile(self.log_check_regex)
|
||||||
|
log_path = self.d.expand("${T}/log.do_rootfs")
|
||||||
|
with open(log_path, 'r') as log:
|
||||||
|
found_error = 0
|
||||||
|
message = "\n"
|
||||||
|
for line in log.read().split('\n'):
|
||||||
|
if 'log_check' in line:
|
||||||
|
continue
|
||||||
|
|
||||||
|
m = r.search(line)
|
||||||
|
if m:
|
||||||
|
found_error = 1
|
||||||
|
bb.warn('log_check: There were error messages in the logfile')
|
||||||
|
bb.warn('log_check: Matched keyword: [%s]\n\n' % m.group())
|
||||||
|
|
||||||
|
if found_error >= 1 and found_error <= 5:
|
||||||
|
message += line + '\n'
|
||||||
|
found_error += 1
|
||||||
|
|
||||||
|
if found_error == 6:
|
||||||
|
bb.fatal(message)
|
||||||
|
|
||||||
def _insert_feed_uris(self):
|
def _insert_feed_uris(self):
|
||||||
if bb.utils.contains("IMAGE_FEATURES", "package-management",
|
if bb.utils.contains("IMAGE_FEATURES", "package-management",
|
||||||
True, False, self.d):
|
True, False, self.d):
|
||||||
@@ -256,7 +293,7 @@ class Rootfs(object):
|
|||||||
class RpmRootfs(Rootfs):
|
class RpmRootfs(Rootfs):
|
||||||
def __init__(self, d, manifest_dir):
|
def __init__(self, d, manifest_dir):
|
||||||
super(RpmRootfs, self).__init__(d)
|
super(RpmRootfs, self).__init__(d)
|
||||||
|
self.log_check_regex = '(unpacking of archive failed|Cannot find package|exit 1|ERR|Fail)'
|
||||||
self.manifest = RpmManifest(d, manifest_dir)
|
self.manifest = RpmManifest(d, manifest_dir)
|
||||||
|
|
||||||
self.pm = RpmPM(d,
|
self.pm = RpmPM(d,
|
||||||
@@ -353,20 +390,6 @@ class RpmRootfs(Rootfs):
|
|||||||
# already saved in /etc/rpm-postinsts
|
# already saved in /etc/rpm-postinsts
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _log_check_warn(self):
|
|
||||||
r = re.compile('^(warn|Warn|NOTE: warn|NOTE: Warn|WARNING:)')
|
|
||||||
log_path = self.d.expand("${T}/log.do_rootfs")
|
|
||||||
with open(log_path, 'r') as log:
|
|
||||||
for line in log.read().split('\n'):
|
|
||||||
if 'log_check' in line or 'NOTE:' in line:
|
|
||||||
continue
|
|
||||||
|
|
||||||
m = r.search(line)
|
|
||||||
if m:
|
|
||||||
bb.warn('log_check: There is a warn message in the logfile')
|
|
||||||
bb.warn('log_check: Matched keyword: [%s]' % m.group())
|
|
||||||
bb.warn('log_check: %s\n' % line)
|
|
||||||
|
|
||||||
def _log_check_error(self):
|
def _log_check_error(self):
|
||||||
r = re.compile('(unpacking of archive failed|Cannot find package|exit 1|ERR|Fail)')
|
r = re.compile('(unpacking of archive failed|Cannot find package|exit 1|ERR|Fail)')
|
||||||
log_path = self.d.expand("${T}/log.do_rootfs")
|
log_path = self.d.expand("${T}/log.do_rootfs")
|
||||||
@@ -417,6 +440,7 @@ class RpmRootfs(Rootfs):
|
|||||||
class DpkgRootfs(Rootfs):
|
class DpkgRootfs(Rootfs):
|
||||||
def __init__(self, d, manifest_dir):
|
def __init__(self, d, manifest_dir):
|
||||||
super(DpkgRootfs, self).__init__(d)
|
super(DpkgRootfs, self).__init__(d)
|
||||||
|
self.log_check_regex = '^E:'
|
||||||
|
|
||||||
bb.utils.remove(self.image_rootfs, True)
|
bb.utils.remove(self.image_rootfs, True)
|
||||||
bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS', True), True)
|
bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS', True), True)
|
||||||
@@ -488,7 +512,8 @@ class DpkgRootfs(Rootfs):
|
|||||||
self.pm.mark_packages("unpacked", registered_pkgs.split())
|
self.pm.mark_packages("unpacked", registered_pkgs.split())
|
||||||
|
|
||||||
def _log_check(self):
|
def _log_check(self):
|
||||||
pass
|
self._log_check_warn()
|
||||||
|
self._log_check_error()
|
||||||
|
|
||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
pass
|
pass
|
||||||
@@ -497,6 +522,7 @@ class DpkgRootfs(Rootfs):
|
|||||||
class OpkgRootfs(Rootfs):
|
class OpkgRootfs(Rootfs):
|
||||||
def __init__(self, d, manifest_dir):
|
def __init__(self, d, manifest_dir):
|
||||||
super(OpkgRootfs, self).__init__(d)
|
super(OpkgRootfs, self).__init__(d)
|
||||||
|
self.log_check_regex = '(exit 1|Collected errors)'
|
||||||
|
|
||||||
self.manifest = OpkgManifest(d, manifest_dir)
|
self.manifest = OpkgManifest(d, manifest_dir)
|
||||||
self.opkg_conf = self.d.getVar("IPKGCONF_TARGET", True)
|
self.opkg_conf = self.d.getVar("IPKGCONF_TARGET", True)
|
||||||
@@ -758,7 +784,8 @@ class OpkgRootfs(Rootfs):
|
|||||||
self.pm.mark_packages("unpacked", registered_pkgs.split())
|
self.pm.mark_packages("unpacked", registered_pkgs.split())
|
||||||
|
|
||||||
def _log_check(self):
|
def _log_check(self):
|
||||||
pass
|
self._log_check_warn()
|
||||||
|
self._log_check_error()
|
||||||
|
|
||||||
def _cleanup(self):
|
def _cleanup(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user