summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/build-image.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/devtool/build-image.py')
-rw-r--r--scripts/lib/devtool/build-image.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/lib/devtool/build-image.py b/scripts/lib/devtool/build-image.py
new file mode 100644
index 0000000000..d8e7b12832
--- /dev/null
+++ b/scripts/lib/devtool/build-image.py
@@ -0,0 +1,56 @@
1# Development tool - build-image plugin
2#
3# Copyright (C) 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
18"""Devtool plugin containing the build-image subcommand."""
19
20import os
21import logging
22
23from bb.process import ExecutionError
24from devtool import exec_build_env_command, add_md5
25
26LOG = logging.getLogger('devtool')
27
28def plugin_init(pluginlist):
29 """Plugin initialization"""
30 pass
31
32def build_image(args, config, basepath, workspace):
33 """Entry point for the devtool 'build-image' subcommand."""
34 image = args.recipe
35 appendfile = os.path.join(config.workspace_path, 'appends',
36 '%s.bbappend' % image)
37 with open(appendfile, 'w') as afile:
38 afile.write('IMAGE_INSTALL_append = " %s"\n' % \
39 ' '.join(workspace.keys()))
40
41 add_md5(config, image, appendfile)
42
43 try:
44 exec_build_env_command(config.init_path, basepath,
45 'bitbake %s' % image, watch=True)
46 except ExecutionError as err:
47 return err.exitcode
48
49 LOG.info('Successfully built %s', image)
50
51def register_commands(subparsers, context):
52 """Register devtool subcommands from the build-image plugin"""
53 parser_package = subparsers.add_parser('build-image', help='Build image')
54 parser_package.add_argument('recipe', help='Image recipe to build')
55 parser_package.set_defaults(func=build_image)
56