mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
bitbake: bb.parse: properly error out on filesystem errors
We've had a long-standing bug where a legitimate error reading a file (IOError or OSError) is always suppressed as though it was a 'file not found' case. As a concrete example, if you do a `chmod 000 conf/local.conf`, it'll silently not parse local.conf, rather than erroring to let the user know about the problem. Fix this by handling the ENOENT case specifically. (Bitbake rev: e691312a3add222b04e7b2f52f8df6abcb9068bf) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
75fc6bf0a0
commit
22078d5e53
@@ -26,9 +26,10 @@ File parsers for the BitBake build tools.
|
|||||||
|
|
||||||
handlers = []
|
handlers = []
|
||||||
|
|
||||||
|
import errno
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import logging
|
|
||||||
import bb
|
import bb
|
||||||
import bb.utils
|
import bb.utils
|
||||||
import bb.siggen
|
import bb.siggen
|
||||||
@@ -122,12 +123,12 @@ def resolve_file(fn, d):
|
|||||||
for af in attempts:
|
for af in attempts:
|
||||||
mark_dependency(d, af)
|
mark_dependency(d, af)
|
||||||
if not newfn:
|
if not newfn:
|
||||||
raise IOError("file %s not found in %s" % (fn, bbpath))
|
raise IOError(errno.ENOENT, "file %s not found in %s" % (fn, bbpath))
|
||||||
fn = newfn
|
fn = newfn
|
||||||
|
|
||||||
mark_dependency(d, fn)
|
mark_dependency(d, fn)
|
||||||
if not os.path.isfile(fn):
|
if not os.path.isfile(fn):
|
||||||
raise IOError("file %s not found" % fn)
|
raise IOError(errno.ENOENT, "file %s not found" % fn)
|
||||||
|
|
||||||
return fn
|
return fn
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,9 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
import re, os
|
import errno
|
||||||
import logging
|
import re
|
||||||
|
import os
|
||||||
import bb.utils
|
import bb.utils
|
||||||
from bb.parse import ParseError, resolve_file, ast, logger, handle
|
from bb.parse import ParseError, resolve_file, ast, logger, handle
|
||||||
|
|
||||||
@@ -92,11 +93,17 @@ def include(parentfn, fn, lineno, data, error_out):
|
|||||||
logger.warn("Duplicate inclusion for %s in %s" % (fn, data.getVar('FILE', True)))
|
logger.warn("Duplicate inclusion for %s in %s" % (fn, data.getVar('FILE', True)))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ret = bb.parse.handle(fn, data, True)
|
bb.parse.handle(fn, data, True)
|
||||||
except (IOError, OSError):
|
except (IOError, OSError) as exc:
|
||||||
if error_out:
|
if exc.errno == errno.ENOENT:
|
||||||
raise ParseError("Could not %(error_out)s file %(fn)s" % vars(), parentfn, lineno)
|
if error_out:
|
||||||
logger.debug(2, "CONF file '%s' not found", fn)
|
raise ParseError("Could not %s file %s" % (error_out, fn), parentfn, lineno)
|
||||||
|
logger.debug(2, "CONF file '%s' not found", fn)
|
||||||
|
else:
|
||||||
|
if error_out:
|
||||||
|
raise ParseError("Could not %s file %s: %s" % (error_out, fn, exc.strerror), parentfn, lineno)
|
||||||
|
else:
|
||||||
|
raise ParseError("Error parsing %s: %s" % (fn, exc.strerror), parentfn, lineno)
|
||||||
|
|
||||||
# We have an issue where a UI might want to enforce particular settings such as
|
# We have an issue where a UI might want to enforce particular settings such as
|
||||||
# an empty DISTRO variable. If configuration files do something like assigning
|
# an empty DISTRO variable. If configuration files do something like assigning
|
||||||
|
|||||||
Reference in New Issue
Block a user