update: allow preserving temp directory

If you're diagnosing problems with the bitbake server when running the
update script, then you need to be able to look at
bitbake-cookerdaemon.log, but you couldn't do that after the fact
because the temporary directory it gets written out to was being
unconditionally deleted. Add a --keep-temp option which preserves it and
some debug messages to tell you where it is.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2017-10-03 11:40:22 +13:00
parent fdcde00710
commit 36d315972b
2 changed files with 14 additions and 1 deletions

View File

@ -85,6 +85,8 @@ def prepare_update_layer_command(options, branch, layer, initial=False):
cmd += ' -d' cmd += ' -d'
elif options.loglevel == logging.ERROR: elif options.loglevel == logging.ERROR:
cmd += ' -q' cmd += ' -q'
if options.keep_temp:
cmd += ' --keep-temp'
return cmd return cmd
def update_actual_branch(layerquery, fetchdir, branch, options, update_bitbake, bitbakepath): def update_actual_branch(layerquery, fetchdir, branch, options, update_bitbake, bitbakepath):
@ -165,6 +167,9 @@ def main():
parser.add_option("-q", "--quiet", parser.add_option("-q", "--quiet",
help = "Hide all output except error messages", help = "Hide all output except error messages",
action="store_const", const=logging.ERROR, dest="loglevel") action="store_const", const=logging.ERROR, dest="loglevel")
parser.add_option("", "--keep-temp",
help = "Preserve temporary directory at the end instead of deleting it",
action="store_true")
options, args = parser.parse_args(sys.argv) options, args = parser.parse_args(sys.argv)
if len(args) > 1: if len(args) > 1:

View File

@ -194,6 +194,9 @@ def main():
parser.add_option("-q", "--quiet", parser.add_option("-q", "--quiet",
help = "Hide all output except error messages", help = "Hide all output except error messages",
action="store_const", const=logging.ERROR, dest="loglevel") action="store_const", const=logging.ERROR, dest="loglevel")
parser.add_option("", "--keep-temp",
help = "Preserve temporary directory at the end instead of deleting it",
action="store_true")
options, args = parser.parse_args(sys.argv) options, args = parser.parse_args(sys.argv)
if len(args) > 1: if len(args) > 1:
@ -258,6 +261,7 @@ def main():
except recipeparse.RecipeParseError as e: except recipeparse.RecipeParseError as e:
logger.error(str(e)) logger.error(str(e))
sys.exit(1) sys.exit(1)
logger.debug('Using temp directory %s' % tempdir)
# Clear the default value of SUMMARY so that we can use DESCRIPTION instead if it hasn't been set # Clear the default value of SUMMARY so that we can use DESCRIPTION instead if it hasn't been set
tinfoil.config_data.setVar('SUMMARY', '') tinfoil.config_data.setVar('SUMMARY', '')
# Clear the default value of DESCRIPTION so that we can see where it's not set # Clear the default value of DESCRIPTION so that we can see where it's not set
@ -702,6 +706,10 @@ def main():
if LooseVersion(bb.__version__) > LooseVersion("1.27"): if LooseVersion(bb.__version__) > LooseVersion("1.27"):
tinfoil.shutdown() tinfoil.shutdown()
if options.keep_temp:
logger.debug('Preserving temp directory %s' % tempdir)
else:
logger.debug('Deleting temp directory')
shutil.rmtree(tempdir) shutil.rmtree(tempdir)
sys.exit(0) sys.exit(0)