summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/build_image.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-03-02 23:44:21 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-07 00:11:38 +0000
commit25d9c4e02a90b1fd8c6a2036d29fd2cf87eca098 (patch)
tree29242ee8c4d7a9a12d7da5f40080f17d511a15ec /scripts/lib/devtool/build_image.py
parent41eb36dc4ce7feece2f63c7cae80478f5376459e (diff)
downloadpoky-25d9c4e02a90b1fd8c6a2036d29fd2cf87eca098.tar.gz
devtool: add build-sdk subcommand
Add a build-sdk command which is only available within the extensible SDK that builds a derivative extensible SDK. The idea is recipes in the workspace become a part of the new SDK - for example, this allows taking a vendor provided SDK, adding a few libs and then producing a new SDK with those included. When normally building the extensible SDK, the workspace is excluded; here we need to copy into the new SDK (renaming it in the process); the recipes' task signatures become locked and thus the sources are no longer needed, so they are removed along with the workspace bbappends which would interfere with the locked signatures. Additionally we need to just copy the configuration files (i.e. local.conf and auto.conf) rather than filtering and appending to them since that work has already been done when constructing the original SDK. The extra sstate artifacts from workspace recipes are also determined and copied into the new SDK in minimal mode (on the assumption that you won't set up a new sstate mirror). This reuses some code from build-image, so that needed to be generalised to allow that. Implements [YOCTO #8892]. (From OE-Core rev: 59e207ff6dd4b50a8905e14bc9292cf2794f4e7a) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool/build_image.py')
-rw-r--r--scripts/lib/devtool/build_image.py79
1 files changed, 57 insertions, 22 deletions
diff --git a/scripts/lib/devtool/build_image.py b/scripts/lib/devtool/build_image.py
index ff764fa833..e51d766474 100644
--- a/scripts/lib/devtool/build_image.py
+++ b/scripts/lib/devtool/build_image.py
@@ -25,6 +25,9 @@ from devtool import exec_build_env_command, setup_tinfoil, parse_recipe, Devtool
25 25
26logger = logging.getLogger('devtool') 26logger = logging.getLogger('devtool')
27 27
28class TargetNotImageError(Exception):
29 pass
30
28def _get_packages(tinfoil, workspace, config): 31def _get_packages(tinfoil, workspace, config):
29 """Get list of packages from recipes in the workspace.""" 32 """Get list of packages from recipes in the workspace."""
30 result = [] 33 result = []
@@ -51,6 +54,24 @@ def build_image(args, config, basepath, workspace):
51 if not image: 54 if not image:
52 raise DevtoolError('Unable to determine image to build, please specify one') 55 raise DevtoolError('Unable to determine image to build, please specify one')
53 56
57 try:
58 if args.add_packages:
59 add_packages = args.add_packages.split(',')
60 else:
61 add_packages = None
62 result, outputdir = build_image_task(config, basepath, workspace, image, add_packages)
63 except TargetNotImageError:
64 if auto_image:
65 raise DevtoolError('Unable to determine image to build, please specify one')
66 else:
67 raise DevtoolError('Specified recipe %s is not an image recipe' % image)
68
69 if result == 0:
70 logger.info('Successfully built %s. You can find output files in %s'
71 % (image, outputdir))
72 return result
73
74def build_image_task(config, basepath, workspace, image, add_packages=None, task=None, extra_append=None):
54 appendfile = os.path.join(config.workspace_path, 'appends', 75 appendfile = os.path.join(config.workspace_path, 'appends',
55 '%s.bbappend' % image) 76 '%s.bbappend' % image)
56 77
@@ -63,46 +84,60 @@ def build_image(args, config, basepath, workspace):
63 rd = parse_recipe(config, tinfoil, image, True) 84 rd = parse_recipe(config, tinfoil, image, True)
64 if not rd: 85 if not rd:
65 # Error already shown 86 # Error already shown
66 return 1 87 return (1, None)
67 if not bb.data.inherits_class('image', rd): 88 if not bb.data.inherits_class('image', rd):
68 if auto_image: 89 raise TargetNotImageError()
69 raise DevtoolError('Unable to determine image to build, please specify one')
70 else:
71 raise DevtoolError('Specified recipe %s is not an image recipe' % image)
72 90
91 outputdir = None
73 try: 92 try:
74 if workspace or args.add_packages: 93 if workspace or add_packages:
75 if args.add_packages: 94 if add_packages:
76 packages = args.add_packages.split(',') 95 packages = add_packages
77 else: 96 else:
78 packages = _get_packages(tinfoil, workspace, config) 97 packages = _get_packages(tinfoil, workspace, config)
79 if packages: 98 else:
80 with open(appendfile, 'w') as afile: 99 packages = None
100 if not task:
101 if not packages and not add_packages and workspace:
102 logger.warning('No recipes in workspace, building image %s unmodified', image)
103 elif not packages:
104 logger.warning('No packages to add, building image %s unmodified', image)
105
106 if packages or extra_append:
107 bb.utils.mkdirhier(os.path.dirname(appendfile))
108 with open(appendfile, 'w') as afile:
109 if packages:
81 # include packages from workspace recipes into the image 110 # include packages from workspace recipes into the image
82 afile.write('IMAGE_INSTALL_append = " %s"\n' % ' '.join(packages)) 111 afile.write('IMAGE_INSTALL_append = " %s"\n' % ' '.join(packages))
83 logger.info('Building image %s with the following ' 112 if not task:
84 'additional packages: %s', image, ' '.join(packages)) 113 logger.info('Building image %s with the following '
85 else: 114 'additional packages: %s', image, ' '.join(packages))
86 logger.warning('No packages to add, building image %s unmodified', image) 115 if extra_append:
116 for line in extra_append:
117 afile.write('%s\n' % line)
118
119 if task in ['populate_sdk', 'populate_sdk_ext']:
120 outputdir = rd.getVar('SDK_DEPLOY', True)
87 else: 121 else:
88 logger.warning('No recipes in workspace, building image %s unmodified', image) 122 outputdir = rd.getVar('DEPLOY_DIR_IMAGE', True)
89
90 deploy_dir_image = tinfoil.config_data.getVar('DEPLOY_DIR_IMAGE', True)
91 123
92 tinfoil.shutdown() 124 tinfoil.shutdown()
93 125
94 # run bitbake to build image 126 options = ''
127 if task:
128 options += '-c %s' % task
129
130 # run bitbake to build image (or specified task)
95 try: 131 try:
96 exec_build_env_command(config.init_path, basepath, 132 exec_build_env_command(config.init_path, basepath,
97 'bitbake %s' % image, watch=True) 133 'bitbake %s %s' % (options, image), watch=True)
98 except ExecutionError as err: 134 except ExecutionError as err:
99 return err.exitcode 135 return (err.exitcode, None)
100 finally: 136 finally:
101 if os.path.isfile(appendfile): 137 if os.path.isfile(appendfile):
102 os.unlink(appendfile) 138 os.unlink(appendfile)
139 return (0, outputdir)
103 140
104 logger.info('Successfully built %s. You can find output files in %s'
105 % (image, deploy_dir_image))
106 141
107def register_commands(subparsers, context): 142def register_commands(subparsers, context):
108 """Register devtool subcommands from the build-image plugin""" 143 """Register devtool subcommands from the build-image plugin"""