Patchwork [bitbake-devel,RFC] parse: Return IOError when including file with absolute path

login
register
mail settings
Submitter Martin Jansa
Date Aug. 23, 2013, 4:48 p.m.
Message ID <1377276538-20486-1-git-send-email-Martin.Jansa@gmail.com>
Download mbox | patch
Permalink /patch/56427/
State Accepted, archived
Headers show

Comments

Martin Jansa - Aug. 23, 2013, 4:48 p.m.
* resolve_file was behaving different when relative and absolute
  paths were passed to it

* include relative-path/non-existent-file.inc
  works correctly resolve_file throws IOError, BBHandler.py:handle()
  doesn't catch it, ConfHandler.py:include() catches IOError and shows:
  DEBUG: CONF file 'relative-path/non-existent-file.inc' not found
* include /absolute-path/non-existent-file.inc
  was failing, because resolve_file just returns fn,
  BBHandler.py:handle() calls bb.parse.mark_dependency(d, abs_fn)
  which throws:
  OSError: [Errno 2] No such file or directory: '/absolute-path/non-existent-file.inc'
  and parsing fails.
  Ad isfile() test for absolute fn and throw IOError to make
  resolve_file behavior consistent for both paths.

* I know we had some issues with -b relative-path-to-recipe.bb and
  absolute path, so consider this patch only as RFC and documentation of
  this problem

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 lib/bb/parse/__init__.py | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/lib/bb/parse/__init__.py b/lib/bb/parse/__init__.py
index 3f93ad2..c973f6f 100644
--- a/lib/bb/parse/__init__.py
+++ b/lib/bb/parse/__init__.py
@@ -107,6 +107,9 @@  def resolve_file(fn, d):
             raise IOError("file %s not found in %s" % (fn, bbpath))
         fn = newfn
 
+    if not os.path.isfile(fn):
+        raise IOError("file %s not found" % fn)
+
     logger.debug(2, "LOAD %s", fn)
     return fn