mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-05 21:24:46 +02:00
Ensure logger is passed into runcmd function or use sys.stderr.write
Otherwise it might not be defined when an error.needs to be printed. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
1eebd6e525
commit
93ce26f21c
|
@ -43,11 +43,11 @@ def _parse_layer_conf(layerdir, data):
|
||||||
data.expandVarref('LAYERDIR')
|
data.expandVarref('LAYERDIR')
|
||||||
|
|
||||||
|
|
||||||
def init_parser(settings, branch, bitbakepath, enable_tracking=False, nocheckout=False, classic=False):
|
def init_parser(settings, branch, bitbakepath, enable_tracking=False, nocheckout=False, classic=False, logger=None):
|
||||||
if not (nocheckout or classic):
|
if not (nocheckout or classic):
|
||||||
# Check out the branch of BitBake appropriate for this branch and clean out any stale files (e.g. *.pyc)
|
# Check out the branch of BitBake appropriate for this branch and clean out any stale files (e.g. *.pyc)
|
||||||
out = utils.runcmd("git checkout origin/%s" % branch.bitbake_branch, bitbakepath)
|
out = utils.runcmd("git checkout origin/%s" % branch.bitbake_branch, bitbakepath, logger=logger)
|
||||||
out = utils.runcmd("git clean -f -x", bitbakepath)
|
out = utils.runcmd("git clean -f -x", bitbakepath, logger=logger)
|
||||||
|
|
||||||
# Skip sanity checks
|
# Skip sanity checks
|
||||||
os.environ['BB_ENV_EXTRAWHITE'] = 'DISABLE_SANITY_CHECKS'
|
os.environ['BB_ENV_EXTRAWHITE'] = 'DISABLE_SANITY_CHECKS'
|
||||||
|
@ -72,8 +72,8 @@ def init_parser(settings, branch, bitbakepath, enable_tracking=False, nocheckout
|
||||||
core_repodir = os.path.join(fetchdir, core_urldir)
|
core_repodir = os.path.join(fetchdir, core_urldir)
|
||||||
core_layerdir = os.path.join(core_repodir, core_subdir)
|
core_layerdir = os.path.join(core_repodir, core_subdir)
|
||||||
if not nocheckout:
|
if not nocheckout:
|
||||||
out = utils.runcmd("git checkout origin/%s" % core_branchname, core_repodir)
|
out = utils.runcmd("git checkout origin/%s" % core_branchname, core_repodir, logger=logger)
|
||||||
out = utils.runcmd("git clean -f -x", core_repodir)
|
out = utils.runcmd("git clean -f -x", core_repodir, logger=logger)
|
||||||
# The directory above where this script exists should contain our conf/layer.conf,
|
# The directory above where this script exists should contain our conf/layer.conf,
|
||||||
# so add it to BBPATH along with the core layer directory
|
# so add it to BBPATH along with the core layer directory
|
||||||
confparentdir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
|
confparentdir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
|
||||||
|
@ -94,13 +94,13 @@ def init_parser(settings, branch, bitbakepath, enable_tracking=False, nocheckout
|
||||||
|
|
||||||
return (tinfoil, tempdir)
|
return (tinfoil, tempdir)
|
||||||
|
|
||||||
def checkout_layer_branch(layerbranch, repodir):
|
def checkout_layer_branch(layerbranch, repodir, logger=None):
|
||||||
if layerbranch.actual_branch:
|
if layerbranch.actual_branch:
|
||||||
branchname = layerbranch.actual_branch
|
branchname = layerbranch.actual_branch
|
||||||
else:
|
else:
|
||||||
branchname = layerbranch.branch.name
|
branchname = layerbranch.branch.name
|
||||||
out = utils.runcmd("git checkout origin/%s" % branchname, repodir)
|
out = utils.runcmd("git checkout origin/%s" % branchname, repodir, logger=logger)
|
||||||
out = utils.runcmd("git clean -f -x", repodir)
|
out = utils.runcmd("git clean -f -x", repodir, logger=logger)
|
||||||
|
|
||||||
def setup_layer(config_data, fetchdir, layerdir, layer, layerbranch):
|
def setup_layer(config_data, fetchdir, layerdir, layer, layerbranch):
|
||||||
# Parse layer.conf files for this layer and its dependencies
|
# Parse layer.conf files for this layer and its dependencies
|
||||||
|
|
|
@ -139,7 +139,7 @@ def main():
|
||||||
confparentdir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../oe-classic'))
|
confparentdir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../oe-classic'))
|
||||||
os.environ['BBPATH'] = str("%s:%s" % (confparentdir, oeclassicpath))
|
os.environ['BBPATH'] = str("%s:%s" % (confparentdir, oeclassicpath))
|
||||||
try:
|
try:
|
||||||
(tinfoil, tempdir) = recipeparse.init_parser(settings, branch, bitbakepath, nocheckout=True, classic=True)
|
(tinfoil, tempdir) = recipeparse.init_parser(settings, branch, bitbakepath, nocheckout=True, classic=True, logger=logger)
|
||||||
except recipeparse.RecipeParseError as e:
|
except recipeparse.RecipeParseError as e:
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -193,9 +193,9 @@ def main():
|
||||||
out = None
|
out = None
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(repodir):
|
if not os.path.exists(repodir):
|
||||||
out = utils.runcmd("git clone %s %s" % (layer.vcs_url, urldir), fetchdir)
|
out = utils.runcmd("git clone %s %s" % (layer.vcs_url, urldir), fetchdir, logger=logger)
|
||||||
else:
|
else:
|
||||||
out = utils.runcmd("git fetch", repodir)
|
out = utils.runcmd("git fetch", repodir, logger=logger)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Fetch of layer %s failed: %s" % (layer.name, str(e)))
|
logger.error("Fetch of layer %s failed: %s" % (layer.name, str(e)))
|
||||||
failedrepos.append(layer.vcs_url)
|
failedrepos.append(layer.vcs_url)
|
||||||
|
@ -208,12 +208,12 @@ def main():
|
||||||
|
|
||||||
logger.info("Fetching bitbake from remote repository %s" % settings.BITBAKE_REPO_URL)
|
logger.info("Fetching bitbake from remote repository %s" % settings.BITBAKE_REPO_URL)
|
||||||
if not os.path.exists(bitbakepath):
|
if not os.path.exists(bitbakepath):
|
||||||
out = utils.runcmd("git clone %s %s" % (settings.BITBAKE_REPO_URL, 'bitbake'), fetchdir)
|
out = utils.runcmd("git clone %s %s" % (settings.BITBAKE_REPO_URL, 'bitbake'), fetchdir, logger=logger)
|
||||||
else:
|
else:
|
||||||
out = utils.runcmd("git fetch", bitbakepath)
|
out = utils.runcmd("git fetch", bitbakepath, logger=logger)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
(tinfoil, tempdir) = recipeparse.init_parser(settings, branch, bitbakepath, nocheckout=options.nocheckout)
|
(tinfoil, tempdir) = recipeparse.init_parser(settings, branch, bitbakepath, nocheckout=options.nocheckout, logger=logger)
|
||||||
except recipeparse.RecipeParseError as e:
|
except recipeparse.RecipeParseError as e:
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -299,8 +299,8 @@ def main():
|
||||||
if layerbranch.vcs_last_rev != topcommit.hexsha or options.reload:
|
if layerbranch.vcs_last_rev != topcommit.hexsha or options.reload:
|
||||||
# Check out appropriate branch
|
# Check out appropriate branch
|
||||||
if not options.nocheckout:
|
if not options.nocheckout:
|
||||||
out = utils.runcmd("git checkout origin/%s" % branchname, repodir)
|
out = utils.runcmd("git checkout origin/%s" % branchname, repodir, logger=logger)
|
||||||
out = utils.runcmd("git clean -f -x", repodir)
|
out = utils.runcmd("git clean -f -x", repodir, logger=logger)
|
||||||
|
|
||||||
if not os.path.exists(layerdir):
|
if not os.path.exists(layerdir):
|
||||||
if options.branch == 'master':
|
if options.branch == 'master':
|
||||||
|
|
|
@ -26,7 +26,7 @@ def get_layer(layername):
|
||||||
return res[0]
|
return res[0]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def runcmd(cmd, destdir=None, printerr=True):
|
def runcmd(cmd, destdir=None, printerr=True, logger=None):
|
||||||
"""
|
"""
|
||||||
execute command, raise CalledProcessError if fail
|
execute command, raise CalledProcessError if fail
|
||||||
return output if succeed
|
return output if succeed
|
||||||
|
@ -38,7 +38,12 @@ def runcmd(cmd, destdir=None, printerr=True):
|
||||||
except subprocess.CalledProcessError,e:
|
except subprocess.CalledProcessError,e:
|
||||||
out.seek(0)
|
out.seek(0)
|
||||||
if printerr:
|
if printerr:
|
||||||
logger.error("%s" % out.read())
|
output = out.read()
|
||||||
|
if logger:
|
||||||
|
logger.error("%s" % output)
|
||||||
|
else:
|
||||||
|
sys.stderr.write("%s\n" % output)
|
||||||
|
e.output = output
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
out.seek(0)
|
out.seek(0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user