summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-04-07 12:57:41 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-04-09 07:43:53 +0100
commit2dc30249babbeb2ac3d2bfdbb49cc5963dfff432 (patch)
tree93ba1bbf6d125e067b4e543e8c43b13de5637d9c /scripts
parent939fca9de24e6750baa9ba066daafdda85b4a216 (diff)
downloadpoky-2dc30249babbeb2ac3d2bfdbb49cc5963dfff432.tar.gz
wic: Implement --build-rootfs command line option
-f/--build-rootfs option makes wic to run bitbake <image> to produce rootfs. This option requires image name to be specified with -e/--image-name. (From OE-Core rev: 75ae0b7cf3863eb2857a2b6a7073beea626f751d) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/image/help.py10
-rwxr-xr-xscripts/wic25
2 files changed, 28 insertions, 7 deletions
diff --git a/scripts/lib/image/help.py b/scripts/lib/image/help.py
index e1eb265979..e365a07803 100644
--- a/scripts/lib/image/help.py
+++ b/scripts/lib/image/help.py
@@ -111,7 +111,7 @@ wic_create_usage = """
111 [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>] 111 [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]
112 [-e | --image-name] [-s, --skip-build-check] [-D, --debug] 112 [-e | --image-name] [-s, --skip-build-check] [-D, --debug]
113 [-r, --rootfs-dir] [-b, --bootimg-dir] 113 [-r, --rootfs-dir] [-b, --bootimg-dir]
114 [-k, --kernel-dir] [-n, --native-sysroot] 114 [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs]
115 115
116 This command creates an OpenEmbedded image based on the 'OE kickstart 116 This command creates an OpenEmbedded image based on the 'OE kickstart
117 commands' found in the <wks file>. 117 commands' found in the <wks file>.
@@ -132,7 +132,7 @@ SYNOPSIS
132 [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>] 132 [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]
133 [-e | --image-name] [-s, --skip-build-check] [-D, --debug] 133 [-e | --image-name] [-s, --skip-build-check] [-D, --debug]
134 [-r, --rootfs-dir] [-b, --bootimg-dir] 134 [-r, --rootfs-dir] [-b, --bootimg-dir]
135 [-k, --kernel-dir] [-n, --native-sysroot] 135 [-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs]
136 136
137DESCRIPTION 137DESCRIPTION
138 This command creates an OpenEmbedded image based on the 'OE 138 This command creates an OpenEmbedded image based on the 'OE
@@ -167,6 +167,8 @@ DESCRIPTION
167 The -n option is used to specify the path to the native sysroot 167 The -n option is used to specify the path to the native sysroot
168 containing the tools to use to build the image. 168 containing the tools to use to build the image.
169 169
170 The -f option is used to build rootfs by running "bitbake <image>"
171
170 The -s option is used to skip the build check. The build check is 172 The -s option is used to skip the build check. The build check is
171 a simple sanity check used to determine whether the user has 173 a simple sanity check used to determine whether the user has
172 sourced the build environment so that the -e option can operate 174 sourced the build environment so that the -e option can operate
@@ -528,8 +530,8 @@ DESCRIPTION
528 usage: wic create <wks file or image name> [-o <DIRNAME> | ...] 530 usage: wic create <wks file or image name> [-o <DIRNAME> | ...]
529 [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>] 531 [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]
530 [-e | --image-name] [-s, --skip-build-check] [-D, --debug] 532 [-e | --image-name] [-s, --skip-build-check] [-D, --debug]
531 [-r, --rootfs-dir] [-b, --bootimg-dir] 533 [-r, --rootfs-dir] [-b, --bootimg-dir] [-k, --kernel-dir]
532 [-k, --kernel-dir] [-n, --native-sysroot] 534 [-n, --native-sysroot] [-f, --build-rootfs]
533 535
534 This command creates an OpenEmbedded image based on the 'OE 536 This command creates an OpenEmbedded image based on the 'OE
535 kickstart commands' found in the <wks file>. 537 kickstart commands' found in the <wks file>.
diff --git a/scripts/wic b/scripts/wic
index ce78254d67..524156ddc5 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -40,11 +40,15 @@ import logging
40# External modules 40# External modules
41scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0]))) 41scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])))
42lib_path = scripts_path + '/lib' 42lib_path = scripts_path + '/lib'
43sys.path = sys.path + [lib_path] 43bitbake_path = os.path.join(scripts_path, '../bitbake/lib')
44sys.path = sys.path + [lib_path, bitbake_path]
44 45
45from image.help import * 46from image.help import *
46from image.engine import * 47from image.engine import *
47 48
49from bb import cookerdata
50from bb.main import bitbake_main, BitBakeConfigParameters
51
48def rootfs_dir_to_args(krootfs_dir): 52def rootfs_dir_to_args(krootfs_dir):
49 """ 53 """
50 Get a rootfs_dir dict and serialize to string 54 Get a rootfs_dir dict and serialize to string
@@ -94,6 +98,7 @@ def wic_create_subcommand(args, usage_str):
94 action = "store", help = "path to the native sysroot containing the tools to use to build the image") 98 action = "store", help = "path to the native sysroot containing the tools to use to build the image")
95 parser.add_option("-p", "--skip-build-check", dest = "build_check", 99 parser.add_option("-p", "--skip-build-check", dest = "build_check",
96 action = "store_false", default = True, help = "skip the build check") 100 action = "store_false", default = True, help = "skip the build check")
101 parser.add_option("-f", "--build-rootfs", action="store_true", help = "build rootfs")
97 parser.add_option("-D", "--debug", dest = "debug", action = "store_true", 102 parser.add_option("-D", "--debug", dest = "debug", action = "store_true",
98 default = False, help = "output debug information") 103 default = False, help = "output debug information")
99 104
@@ -123,8 +128,6 @@ def wic_create_subcommand(args, usage_str):
123 else: 128 else:
124 print "Done.\n" 129 print "Done.\n"
125 130
126 print "Creating image(s)...\n"
127
128 bitbake_env_lines = find_bitbake_env_lines(options.image_name) 131 bitbake_env_lines = find_bitbake_env_lines(options.image_name)
129 if not bitbake_env_lines: 132 if not bitbake_env_lines:
130 print "Couldn't get bitbake environment, exiting." 133 print "Couldn't get bitbake environment, exiting."
@@ -134,9 +137,24 @@ def wic_create_subcommand(args, usage_str):
134 bootimg_dir = "" 137 bootimg_dir = ""
135 138
136 if options.image_name: 139 if options.image_name:
140 if options.build_rootfs:
141 argv = ["bitbake", options.image_name]
142 if options.debug:
143 argv.append("--debug")
144
145 print "Building rootfs...\n"
146 if bitbake_main(BitBakeConfigParameters(argv),
147 cookerdata.CookerConfiguration()):
148 sys.exit(1)
149
137 (rootfs_dir, kernel_dir, bootimg_dir, native_sysroot) \ 150 (rootfs_dir, kernel_dir, bootimg_dir, native_sysroot) \
138 = find_artifacts(options.image_name) 151 = find_artifacts(options.image_name)
139 152
153 else:
154 if options.build_rootfs:
155 print "Image name is not specified, exiting. (Use -e/--image-name to specify it)\n"
156 sys.exit(1)
157
140 wks_file = args[0] 158 wks_file = args[0]
141 159
142 if not wks_file.endswith(".wks"): 160 if not wks_file.endswith(".wks"):
@@ -194,6 +212,7 @@ def wic_create_subcommand(args, usage_str):
194 212
195 rootfs_dir = rootfs_dir_to_args(krootfs_dir) 213 rootfs_dir = rootfs_dir_to_args(krootfs_dir)
196 214
215 print "Creating image(s)...\n"
197 wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir, 216 wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
198 native_sysroot, scripts_path, image_output_dir, 217 native_sysroot, scripts_path, image_output_dir,
199 options.debug, options.properties_file) 218 options.debug, options.properties_file)