summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-07-31 14:59:59 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-06 10:24:26 (GMT)
commit546c32753b2f0c2174c360ba83a7d2f7ffbb33f7 (patch)
tree85adaffbf373b0c2d4c94e9b8fba7ef9835ccd3b
parentd9cb21854b139e9f8620ee256a3957db542494da (diff)
downloadpoky-546c32753b2f0c2174c360ba83a7d2f7ffbb33f7.tar.gz
classes/lib: Remove bb.build.FuncFailed
Whilst seemingly a good idea, this exception doesn't really serve any purpose that bb.fatal() doesn't cover. Wrapping exceptions within exceptions isn't pythonic. Its not used in many places, lets clean up those and remove usage of it entirely. It may ultimately be dropped form bitbake entirely. (From OE-Core rev: efe87ce4b2154c6f1c591ed9d8f770c229b044ad) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/go.bbclass18
-rw-r--r--meta/classes/image.bbclass7
-rw-r--r--meta/lib/oe/gpg_sign.py5
-rw-r--r--meta/lib/oe/useradd.py2
-rw-r--r--meta/lib/oe/utils.py2
-rw-r--r--meta/lib/oeqa/selftest/cases/bbtests.py7
-rw-r--r--meta/lib/oeqa/targetcontrol.py4
-rw-r--r--meta/lib/oeqa/utils/commands.py4
8 files changed, 22 insertions, 27 deletions
diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
index f303a15..e40e556 100644
--- a/meta/classes/go.bbclass
+++ b/meta/classes/go.bbclass
@@ -71,17 +71,13 @@ python go_do_unpack() {
71 if len(src_uri) == 0: 71 if len(src_uri) == 0:
72 return 72 return
73 73
74 try: 74 fetcher = bb.fetch2.Fetch(src_uri, d)
75 fetcher = bb.fetch2.Fetch(src_uri, d) 75 for url in fetcher.urls:
76 for url in fetcher.urls: 76 if fetcher.ud[url].type == 'git':
77 if fetcher.ud[url].type == 'git': 77 if fetcher.ud[url].parm.get('destsuffix') is None:
78 if fetcher.ud[url].parm.get('destsuffix') is None: 78 s_dirname = os.path.basename(d.getVar('S'))
79 s_dirname = os.path.basename(d.getVar('S')) 79 fetcher.ud[url].parm['destsuffix'] = os.path.join(s_dirname, 'src', d.getVar('GO_IMPORT')) + '/'
80 fetcher.ud[url].parm['destsuffix'] = os.path.join(s_dirname, 'src', 80 fetcher.unpack(d.getVar('WORKDIR'))
81 d.getVar('GO_IMPORT')) + '/'
82 fetcher.unpack(d.getVar('WORKDIR'))
83 except bb.fetch2.BBFetchException as e:
84 raise bb.build.FuncFailed(e)
85} 81}
86 82
87go_list_packages() { 83go_list_packages() {
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 682858d..7fa4ff2 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -305,11 +305,8 @@ fakeroot python do_image_qa () {
305 bb.build.exec_func(cmd, d) 305 bb.build.exec_func(cmd, d)
306 except oe.utils.ImageQAFailed as e: 306 except oe.utils.ImageQAFailed as e:
307 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description) 307 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description)
308 except bb.build.FuncFailed as e: 308 except Exception as e:
309 qamsg = qamsg + '\tImage QA function %s failed' % e.name 309 qamsg = qamsg + '\tImage QA function %s failed\n' % cmd
310 if e.logfile:
311 qamsg = qamsg + ' (log file is located at %s)' % e.logfile
312 qamsg = qamsg + '\n'
313 310
314 if qamsg: 311 if qamsg:
315 imgname = d.getVar('IMAGE_NAME') 312 imgname = d.getVar('IMAGE_NAME')
diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py
index 2fd8c3b..d762480 100644
--- a/meta/lib/oe/gpg_sign.py
+++ b/meta/lib/oe/gpg_sign.py
@@ -89,8 +89,7 @@ class LocalSigner(object):
89 (_, stderr) = job.communicate(passphrase.encode("utf-8")) 89 (_, stderr) = job.communicate(passphrase.encode("utf-8"))
90 90
91 if job.returncode: 91 if job.returncode:
92 raise bb.build.FuncFailed("GPG exited with code %d: %s" % 92 bb.fatal("GPG exited with code %d: %s" % (job.returncode, stderr.decode("utf-8")))
93 (job.returncode, stderr.decode("utf-8")))
94 93
95 except IOError as e: 94 except IOError as e:
96 bb.error("IO error (%s): %s" % (e.errno, e.strerror)) 95 bb.error("IO error (%s): %s" % (e.errno, e.strerror))
@@ -108,7 +107,7 @@ class LocalSigner(object):
108 ver_str = subprocess.check_output(cmd).split()[2].decode("utf-8") 107 ver_str = subprocess.check_output(cmd).split()[2].decode("utf-8")
109 return tuple([int(i) for i in ver_str.split("-")[0].split('.')]) 108 return tuple([int(i) for i in ver_str.split("-")[0].split('.')])
110 except subprocess.CalledProcessError as e: 109 except subprocess.CalledProcessError as e:
111 raise bb.build.FuncFailed("Could not get gpg version: %s" % e) 110 bb.fatal("Could not get gpg version: %s" % e)
112 111
113 112
114 def verify(self, sig_file): 113 def verify(self, sig_file):
diff --git a/meta/lib/oe/useradd.py b/meta/lib/oe/useradd.py
index bedfe0e..8fc7756 100644
--- a/meta/lib/oe/useradd.py
+++ b/meta/lib/oe/useradd.py
@@ -14,7 +14,7 @@ class myArgumentParser(argparse.ArgumentParser):
14 error(message) 14 error(message)
15 15
16 def error(self, message): 16 def error(self, message):
17 raise bb.build.FuncFailed(message) 17 bb.fatal(message)
18 18
19def split_commands(params): 19def split_commands(params):
20 params = re.split('''[ \t]*;[ \t]*(?=(?:[^'"]|'[^']*'|"[^"]*")*$)''', params.strip()) 20 params = re.split('''[ \t]*;[ \t]*(?=(?:[^'"]|'[^']*'|"[^"]*")*$)''', params.strip())
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index d686ce1..652b2be 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -486,7 +486,7 @@ def write_ld_so_conf(d):
486 f.write(d.getVar("base_libdir") + '\n') 486 f.write(d.getVar("base_libdir") + '\n')
487 f.write(d.getVar("libdir") + '\n') 487 f.write(d.getVar("libdir") + '\n')
488 488
489class ImageQAFailed(bb.build.FuncFailed): 489class ImageQAFailed(Exception):
490 def __init__(self, description, name=None, logfile=None): 490 def __init__(self, description, name=None, logfile=None):
491 self.description = description 491 self.description = description
492 self.name = name 492 self.name = name
diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py
index 17da0fd..0693ba8 100644
--- a/meta/lib/oeqa/selftest/cases/bbtests.py
+++ b/meta/lib/oeqa/selftest/cases/bbtests.py
@@ -75,8 +75,11 @@ class BitbakeTests(OESelftestTestCase):
75 result = bitbake('man-db -c patch', ignore_status=True) 75 result = bitbake('man-db -c patch', ignore_status=True)
76 self.delete_recipeinc('man-db') 76 self.delete_recipeinc('man-db')
77 bitbake('-cclean man-db') 77 bitbake('-cclean man-db')
78 line = self.getline(result, "Function failed: patch_do_patch") 78 found = False
79 self.assertTrue(line and line.startswith("ERROR:"), msg = "Incorrectly formed patch application didn't fail. bitbake output: %s" % result.output) 79 for l in result.output.split('\n'):
80 if l.startswith("ERROR:") and "failed" in l and "do_patch" in l:
81 found = l
82 self.assertTrue(found and found.startswith("ERROR:"), msg = "Incorrectly formed patch application didn't fail. bitbake output: %s" % result.output)
80 83
81 def test_force_task_1(self): 84 def test_force_task_1(self):
82 # test 1 from bug 5875 85 # test 1 from bug 5875
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index 15e617c..1445e3e 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -175,7 +175,7 @@ class QemuTarget(BaseTarget):
175 if os.path.exists(self.qemulog): 175 if os.path.exists(self.qemulog):
176 with open(self.qemulog, 'r') as f: 176 with open(self.qemulog, 'r') as f:
177 bb.error("Qemu log output from %s:\n%s" % (self.qemulog, f.read())) 177 bb.error("Qemu log output from %s:\n%s" % (self.qemulog, f.read()))
178 raise bb.build.FuncFailed("%s - FAILED to start qemu - check the task log and the boot log" % self.pn) 178 raise RuntimeError("%s - FAILED to start qemu - check the task log and the boot log" % self.pn)
179 179
180 def check(self): 180 def check(self):
181 return self.runner.is_alive() 181 return self.runner.is_alive()
@@ -192,7 +192,7 @@ class QemuTarget(BaseTarget):
192 self.server_ip = self.runner.server_ip 192 self.server_ip = self.runner.server_ip
193 self.connection = SSHControl(ip=self.ip, logfile=self.sshlog) 193 self.connection = SSHControl(ip=self.ip, logfile=self.sshlog)
194 else: 194 else:
195 raise bb.build.FuncFailed("%s - FAILED to re-start qemu - check the task log and the boot log" % self.pn) 195 raise RuntimError("%s - FAILED to re-start qemu - check the task log and the boot log" % self.pn)
196 196
197 def run_serial(self, command, timeout=60): 197 def run_serial(self, command, timeout=60):
198 return self.runner.run_serial(command, timeout=timeout) 198 return self.runner.run_serial(command, timeout=timeout)
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 59ebfbe..7140bc7 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -337,8 +337,8 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None,
337 qemu.deploy() 337 qemu.deploy()
338 try: 338 try:
339 qemu.start(params=qemuparams, ssh=ssh, runqemuparams=runqemuparams, launch_cmd=launch_cmd, discard_writes=discard_writes) 339 qemu.start(params=qemuparams, ssh=ssh, runqemuparams=runqemuparams, launch_cmd=launch_cmd, discard_writes=discard_writes)
340 except bb.build.FuncFailed: 340 except EXception as e:
341 msg = 'Failed to start QEMU - see the logs in %s' % logdir 341 msg = str(e) + '\nFailed to start QEMU - see the logs in %s' % logdir
342 if os.path.exists(qemu.qemurunnerlog): 342 if os.path.exists(qemu.qemurunnerlog):
343 with open(qemu.qemurunnerlog, 'r') as f: 343 with open(qemu.qemurunnerlog, 'r') as f:
344 msg = msg + "Qemurunner log output from %s:\n%s" % (qemu.qemurunnerlog, f.read()) 344 msg = msg + "Qemurunner log output from %s:\n%s" % (qemu.qemurunnerlog, f.read())