blob: afb5809a36b3acdf3e4ec4272ae17deeebc41882 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# Development tool - package command plugin
2#
3# Copyright (C) 2014-2015 Intel Corporation
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17"""Devtool plugin containing the package subcommands"""
18
19import os
20import subprocess
21import logging
22from bb.process import ExecutionError
Patrick Williamsf1e5d692016-03-30 15:21:19 -050023from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, DevtoolError
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024
25logger = logging.getLogger('devtool')
26
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027def package(args, config, basepath, workspace):
28 """Entry point for the devtool 'package' subcommand"""
Patrick Williamsf1e5d692016-03-30 15:21:19 -050029 check_workspace_recipe(workspace, args.recipename)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050031 tinfoil = setup_tinfoil(basepath=basepath)
32 try:
33 tinfoil.prepare(config_only=True)
34
35 image_pkgtype = config.get('Package', 'image_pkgtype', '')
36 if not image_pkgtype:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037 image_pkgtype = tinfoil.config_data.getVar('IMAGE_PKGTYPE', True)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050038
39 deploy_dir_pkg = tinfoil.config_data.getVar('DEPLOY_DIR_%s' % image_pkgtype.upper(), True)
40 finally:
41 tinfoil.shutdown()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050042
43 package_task = config.get('Package', 'package_task', 'package_write_%s' % image_pkgtype)
44 try:
45 exec_build_env_command(config.init_path, basepath, 'bitbake -c %s %s' % (package_task, args.recipename), watch=True)
46 except bb.process.ExecutionError as e:
47 # We've already seen the output since watch=True, so just ensure we return something to the user
48 return e.exitcode
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050049
50 logger.info('Your packages are in %s' % deploy_dir_pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051
52 return 0
53
54def register_commands(subparsers, context):
55 """Register devtool subcommands from the package plugin"""
56 if context.fixed_setup:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050057 parser_package = subparsers.add_parser('package',
58 help='Build packages for a recipe',
59 description='Builds packages for a recipe\'s output files',
60 group='testbuild', order=-5)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061 parser_package.add_argument('recipename', help='Recipe to package')
62 parser_package.set_defaults(func=package)