aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-09-22 17:21:38 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-22 18:13:00 +0100
commitf6b90bceaedf9bad3d111e6ca1fa79e59f472c73 (patch)
treebde6115207d57fa4cee431ae0c634e09fee77805
parent8884875aacfedc69cc72898684e391e69fea00ba (diff)
downloadopenembedded-core-contrib-f6b90bceaedf9bad3d111e6ca1fa79e59f472c73.tar.gz
devtool: build-image: delete bbappend at end of build
Upon further reflection, it seems to me that this bbappend ought to just be deleted at the end of the build. This keeps things simple; you never have to remember to delete any files to get back to where you were before with the image. This means we can also drop the slightly awkward message reminding the user how to do that. I've also updated the test to look at the image manifest to determine if the command has worked instead of looking for the (now deleted) bbappend. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/devtool.py22
-rw-r--r--scripts/lib/devtool/build-image.py53
2 files changed, 38 insertions, 37 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index 6e731d6777..3a8168c2d5 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -919,7 +919,8 @@ class DevtoolTests(DevtoolBase):
self.add_command_to_tearDown('bitbake -c clean %s' % image)
bitbake('%s -c clean' % image)
# Add target and native recipes to workspace
- for recipe in ('mdadm', 'parted-native'):
+ recipes = ['mdadm', 'parted-native']
+ for recipe in recipes:
tempdir = tempfile.mkdtemp(prefix='devtoolqa')
self.track_for_cleanup(tempdir)
self.add_command_to_tearDown('bitbake -c clean %s' % recipe)
@@ -927,12 +928,19 @@ class DevtoolTests(DevtoolBase):
# Try to build image
result = runCmd('devtool build-image %s' % image)
self.assertNotEqual(result, 0, 'devtool build-image failed')
- # Check if image.bbappend has required content
- bbappend = os.path.join(workspacedir, 'appends', image+'.bbappend')
- self.assertTrue(os.path.isfile(bbappend), 'bbappend not created %s' % result.output)
- # NOTE: native recipe parted-native should not be in IMAGE_INSTALL_append
- self.assertTrue('IMAGE_INSTALL_append = " mdadm"\n' in open(bbappend).readlines(),
- 'IMAGE_INSTALL_append = " mdadm" not found in %s' % bbappend)
+ # Check if image contains expected packages
+ deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
+ image_link_name = get_bb_var('IMAGE_LINK_NAME', image)
+ reqpkgs = [item for item in recipes if not item.endswith('-native')]
+ with open(os.path.join(deploy_dir_image, image_link_name + '.manifest'), 'r') as f:
+ for line in f:
+ splitval = line.split()
+ if splitval:
+ pkg = splitval[0]
+ if pkg in reqpkgs:
+ reqpkgs.remove(pkg)
+ if reqpkgs:
+ self.fail('The following packages were not present in the image as expected: %s' % ', '.join(reqpkgs))
def test_devtool_upgrade(self):
# Check preconditions
diff --git a/scripts/lib/devtool/build-image.py b/scripts/lib/devtool/build-image.py
index a6c7d81586..05c1d75c67 100644
--- a/scripts/lib/devtool/build-image.py
+++ b/scripts/lib/devtool/build-image.py
@@ -70,40 +70,33 @@ def build_image(args, config, basepath, workspace):
else:
raise DevtoolError('Specified recipe %s is not an image recipe' % image)
- if workspace:
- packages = _get_packages(tinfoil, workspace, config)
- if packages:
- with open(appendfile, 'w') as afile:
- # include packages from workspace recipes into the image
- afile.write('IMAGE_INSTALL_append = " %s"\n' % ' '.join(packages))
-
- # Generate notification callback devtool_warn_image_extended
- afile.write('do_rootfs[prefuncs] += "devtool_warn_image_extended"\n\n')
- afile.write("python devtool_warn_image_extended() {\n")
- afile.write(" bb.plain('NOTE: %%s: building with additional '\n"
- " 'packages due to \"devtool build-image\"'"
- " %% d.getVar('PN', True))\n"
- " bb.plain('NOTE: delete %%s to clear this' %% \\\n"
- " '%s')\n" % os.path.relpath(appendfile, basepath))
- afile.write("}\n")
-
- logger.info('Building image %s with the following '
- 'additional packages: %s', image, ' '.join(packages))
+ try:
+ if workspace:
+ packages = _get_packages(tinfoil, workspace, config)
+ if packages:
+ with open(appendfile, 'w') as afile:
+ # include packages from workspace recipes into the image
+ afile.write('IMAGE_INSTALL_append = " %s"\n' % ' '.join(packages))
+ logger.info('Building image %s with the following '
+ 'additional packages: %s', image, ' '.join(packages))
+ else:
+ logger.warning('No packages to add, building image %s unmodified', image)
else:
- logger.warning('No packages to add, building image %s unmodified', image)
- else:
- logger.warning('No recipes in workspace, building image %s unmodified', image)
+ logger.warning('No recipes in workspace, building image %s unmodified', image)
- deploy_dir_image = tinfoil.config_data.getVar('DEPLOY_DIR_IMAGE', True)
+ deploy_dir_image = tinfoil.config_data.getVar('DEPLOY_DIR_IMAGE', True)
- tinfoil.shutdown()
+ tinfoil.shutdown()
- # run bitbake to build image
- try:
- exec_build_env_command(config.init_path, basepath,
- 'bitbake %s' % image, watch=True)
- except ExecutionError as err:
- return err.exitcode
+ # run bitbake to build image
+ try:
+ exec_build_env_command(config.init_path, basepath,
+ 'bitbake %s' % image, watch=True)
+ except ExecutionError as err:
+ return err.exitcode
+ finally:
+ if os.path.isfile(appendfile):
+ os.unlink(appendfile)
logger.info('Successfully built %s. You can find output files in %s'
% (image, deploy_dir_image))