diff options
Diffstat (limited to 'scripts/lib/devtool/sdk.py')
-rw-r--r-- | scripts/lib/devtool/sdk.py | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/scripts/lib/devtool/sdk.py b/scripts/lib/devtool/sdk.py index 80ea8711cc..12de9423e7 100644 --- a/scripts/lib/devtool/sdk.py +++ b/scripts/lib/devtool/sdk.py | |||
@@ -8,7 +8,7 @@ import shutil | |||
8 | import errno | 8 | import errno |
9 | import sys | 9 | import sys |
10 | import tempfile | 10 | import tempfile |
11 | from devtool import exec_build_env_command, setup_tinfoil, DevtoolError | 11 | from devtool import exec_build_env_command, setup_tinfoil, parse_recipe, DevtoolError |
12 | 12 | ||
13 | logger = logging.getLogger('devtool') | 13 | logger = logging.getLogger('devtool') |
14 | 14 | ||
@@ -235,6 +235,64 @@ def sdk_update(args, config, basepath, workspace): | |||
235 | return -1 | 235 | return -1 |
236 | return 0 | 236 | return 0 |
237 | 237 | ||
238 | def sdk_install(args, config, basepath, workspace): | ||
239 | """Entry point for the devtool sdk-install command""" | ||
240 | |||
241 | import oe.recipeutils | ||
242 | import bb.process | ||
243 | |||
244 | for recipe in args.recipename: | ||
245 | if recipe in workspace: | ||
246 | raise DevtoolError('recipe %s is a recipe in your workspace' % recipe) | ||
247 | |||
248 | tasks = ['do_populate_sysroot', 'do_packagedata'] | ||
249 | stampprefixes = {} | ||
250 | def checkstamp(recipe): | ||
251 | stampprefix = stampprefixes[recipe] | ||
252 | stamps = glob.glob(stampprefix + '*') | ||
253 | for stamp in stamps: | ||
254 | if '.sigdata.' not in stamp and stamp.startswith((stampprefix + '.', stampprefix + '_setscene.')): | ||
255 | return True | ||
256 | else: | ||
257 | return False | ||
258 | |||
259 | install_recipes = [] | ||
260 | tinfoil = setup_tinfoil(config_only=False, basepath=basepath) | ||
261 | try: | ||
262 | for recipe in args.recipename: | ||
263 | rd = parse_recipe(config, tinfoil, recipe, True) | ||
264 | if not rd: | ||
265 | return 1 | ||
266 | stampprefixes[recipe] = '%s.%s' % (rd.getVar('STAMP', True), tasks[0]) | ||
267 | if checkstamp(recipe): | ||
268 | logger.info('%s is already installed' % recipe) | ||
269 | else: | ||
270 | install_recipes.append(recipe) | ||
271 | finally: | ||
272 | tinfoil.shutdown() | ||
273 | |||
274 | if install_recipes: | ||
275 | logger.info('Installing %s...' % ', '.join(install_recipes)) | ||
276 | install_tasks = [] | ||
277 | for recipe in install_recipes: | ||
278 | for task in tasks: | ||
279 | if recipe.endswith('-native') and 'package' in task: | ||
280 | continue | ||
281 | install_tasks.append('%s:%s' % (recipe, task)) | ||
282 | try: | ||
283 | exec_build_env_command(config.init_path, basepath, 'bitbake --setscene-only %s' % ' '.join(install_tasks)) | ||
284 | except bb.process.ExecutionError as e: | ||
285 | raise DevtoolError('Failed to install %s:\n%s' % (recipe, str(e))) | ||
286 | failed = False | ||
287 | for recipe in install_recipes: | ||
288 | if checkstamp(recipe): | ||
289 | logger.info('Successfully installed %s' % recipe) | ||
290 | else: | ||
291 | raise DevtoolError('Failed to install %s - unavailable' % recipe) | ||
292 | failed = True | ||
293 | if failed: | ||
294 | return 2 | ||
295 | |||
238 | def register_commands(subparsers, context): | 296 | def register_commands(subparsers, context): |
239 | """Register devtool subcommands from the sdk plugin""" | 297 | """Register devtool subcommands from the sdk plugin""" |
240 | if context.fixed_setup: | 298 | if context.fixed_setup: |
@@ -242,3 +300,6 @@ def register_commands(subparsers, context): | |||
242 | parser_sdk.add_argument('updateserver', help='The update server to fetch latest SDK components from', nargs='?') | 300 | parser_sdk.add_argument('updateserver', help='The update server to fetch latest SDK components from', nargs='?') |
243 | parser_sdk.add_argument('--skip-prepare', action="store_true", help='Skip re-preparing the build system after updating (for debugging only)') | 301 | parser_sdk.add_argument('--skip-prepare', action="store_true", help='Skip re-preparing the build system after updating (for debugging only)') |
244 | parser_sdk.set_defaults(func=sdk_update) | 302 | parser_sdk.set_defaults(func=sdk_update) |
303 | parser_sdk_install = subparsers.add_parser('sdk-install', help='Install additional SDK components', description='Installs additional recipe development files into the SDK. (You can use "devtool search" to find available recipes.)') | ||
304 | parser_sdk_install.add_argument('recipename', help='Name of the recipe to install the development artifacts for', nargs='+') | ||
305 | parser_sdk_install.set_defaults(func=sdk_install) | ||