summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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):
919 self.add_command_to_tearDown('bitbake -c clean %s' % image) 919 self.add_command_to_tearDown('bitbake -c clean %s' % image)
920 bitbake('%s -c clean' % image) 920 bitbake('%s -c clean' % image)
921 # Add target and native recipes to workspace 921 # Add target and native recipes to workspace
922 for recipe in ('mdadm', 'parted-native'): 922 recipes = ['mdadm', 'parted-native']
923 for recipe in recipes:
923 tempdir = tempfile.mkdtemp(prefix='devtoolqa') 924 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
924 self.track_for_cleanup(tempdir) 925 self.track_for_cleanup(tempdir)
925 self.add_command_to_tearDown('bitbake -c clean %s' % recipe) 926 self.add_command_to_tearDown('bitbake -c clean %s' % recipe)
@@ -927,12 +928,19 @@ class DevtoolTests(DevtoolBase):
927 # Try to build image 928 # Try to build image
928 result = runCmd('devtool build-image %s' % image) 929 result = runCmd('devtool build-image %s' % image)
929 self.assertNotEqual(result, 0, 'devtool build-image failed') 930 self.assertNotEqual(result, 0, 'devtool build-image failed')
930 # Check if image.bbappend has required content 931 # Check if image contains expected packages
931 bbappend = os.path.join(workspacedir, 'appends', image+'.bbappend') 932 deploy_dir_image = get_bb_var('DEPLOY_DIR_IMAGE')
932 self.assertTrue(os.path.isfile(bbappend), 'bbappend not created %s' % result.output) 933 image_link_name = get_bb_var('IMAGE_LINK_NAME', image)
933 # NOTE: native recipe parted-native should not be in IMAGE_INSTALL_append 934 reqpkgs = [item for item in recipes if not item.endswith('-native')]
934 self.assertTrue('IMAGE_INSTALL_append = " mdadm"\n' in open(bbappend).readlines(), 935 with open(os.path.join(deploy_dir_image, image_link_name + '.manifest'), 'r') as f:
935 'IMAGE_INSTALL_append = " mdadm" not found in %s' % bbappend) 936 for line in f:
937 splitval = line.split()
938 if splitval:
939 pkg = splitval[0]
940 if pkg in reqpkgs:
941 reqpkgs.remove(pkg)
942 if reqpkgs:
943 self.fail('The following packages were not present in the image as expected: %s' % ', '.join(reqpkgs))
936 944
937 def test_devtool_upgrade(self): 945 def test_devtool_upgrade(self):
938 # Check preconditions 946 # 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):
70 else: 70 else:
71 raise DevtoolError('Specified recipe %s is not an image recipe' % image) 71 raise DevtoolError('Specified recipe %s is not an image recipe' % image)
72 72
73 if workspace: 73 try:
74 packages = _get_packages(tinfoil, workspace, config) 74 if workspace:
75 if packages: 75 packages = _get_packages(tinfoil, workspace, config)
76 with open(appendfile, 'w') as afile: 76 if packages:
77 # include packages from workspace recipes into the image 77 with open(appendfile, 'w') as afile:
78 afile.write('IMAGE_INSTALL_append = " %s"\n' % ' '.join(packages)) 78 # include packages from workspace recipes into the image
79 79 afile.write('IMAGE_INSTALL_append = " %s"\n' % ' '.join(packages))
80 # Generate notification callback devtool_warn_image_extended 80 logger.info('Building image %s with the following '
81 afile.write('do_rootfs[prefuncs] += "devtool_warn_image_extended"\n\n') 81 'additional packages: %s', image, ' '.join(packages))
82 afile.write("python devtool_warn_image_extended() {\n") 82 else:
83 afile.write(" bb.plain('NOTE: %%s: building with additional '\n" 83 logger.warning('No packages to add, building image %s unmodified', image)
84 " 'packages due to \"devtool build-image\"'"
85 " %% d.getVar('PN', True))\n"
86 " bb.plain('NOTE: delete %%s to clear this' %% \\\n"
87 " '%s')\n" % os.path.relpath(appendfile, basepath))
88 afile.write("}\n")
89
90 logger.info('Building image %s with the following '
91 'additional packages: %s', image, ' '.join(packages))
92 else: 84 else:
93 logger.warning('No packages to add, building image %s unmodified', image) 85 logger.warning('No recipes in workspace, building image %s unmodified', image)
94 else:
95 logger.warning('No recipes in workspace, building image %s unmodified', image)
96 86
97 deploy_dir_image = tinfoil.config_data.getVar('DEPLOY_DIR_IMAGE', True) 87 deploy_dir_image = tinfoil.config_data.getVar('DEPLOY_DIR_IMAGE', True)
98 88
99 tinfoil.shutdown() 89 tinfoil.shutdown()
100 90
101 # run bitbake to build image 91 # run bitbake to build image
102 try: 92 try:
103 exec_build_env_command(config.init_path, basepath, 93 exec_build_env_command(config.init_path, basepath,
104 'bitbake %s' % image, watch=True) 94 'bitbake %s' % image, watch=True)
105 except ExecutionError as err: 95 except ExecutionError as err:
106 return err.exitcode 96 return err.exitcode
97 finally:
98 if os.path.isfile(appendfile):
99 os.unlink(appendfile)
107 100
108 logger.info('Successfully built %s. You can find output files in %s' 101 logger.info('Successfully built %s. You can find output files in %s'
109 % (image, deploy_dir_image)) 102 % (image, deploy_dir_image))