Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # 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 | |
| 19 | import os |
| 20 | import subprocess |
| 21 | import logging |
| 22 | from bb.process import ExecutionError |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 23 | from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, DevtoolError |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | |
| 25 | logger = logging.getLogger('devtool') |
| 26 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | def package(args, config, basepath, workspace): |
| 28 | """Entry point for the devtool 'package' subcommand""" |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 29 | check_workspace_recipe(workspace, args.recipename) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 31 | tinfoil = setup_tinfoil(basepath=basepath, config_only=True) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 32 | try: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 33 | image_pkgtype = config.get('Package', 'image_pkgtype', '') |
| 34 | if not image_pkgtype: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 35 | image_pkgtype = tinfoil.config_data.getVar('IMAGE_PKGTYPE') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 36 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 37 | deploy_dir_pkg = tinfoil.config_data.getVar('DEPLOY_DIR_%s' % image_pkgtype.upper()) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 38 | finally: |
| 39 | tinfoil.shutdown() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | |
| 41 | package_task = config.get('Package', 'package_task', 'package_write_%s' % image_pkgtype) |
| 42 | try: |
| 43 | exec_build_env_command(config.init_path, basepath, 'bitbake -c %s %s' % (package_task, args.recipename), watch=True) |
| 44 | except bb.process.ExecutionError as e: |
| 45 | # We've already seen the output since watch=True, so just ensure we return something to the user |
| 46 | return e.exitcode |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 47 | |
| 48 | logger.info('Your packages are in %s' % deploy_dir_pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 49 | |
| 50 | return 0 |
| 51 | |
| 52 | def register_commands(subparsers, context): |
| 53 | """Register devtool subcommands from the package plugin""" |
| 54 | if context.fixed_setup: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 55 | parser_package = subparsers.add_parser('package', |
| 56 | help='Build packages for a recipe', |
| 57 | description='Builds packages for a recipe\'s output files', |
| 58 | group='testbuild', order=-5) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | parser_package.add_argument('recipename', help='Recipe to package') |
| 60 | parser_package.set_defaults(func=package) |