diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/wic | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/scripts/wic b/scripts/wic index d14671769d..97af72b104 100755 --- a/scripts/wic +++ b/scripts/wic | |||
@@ -142,13 +142,11 @@ def wic_create_subcommand(args, usage_str): | |||
142 | (options, args) = parser.parse_args(args) | 142 | (options, args) = parser.parse_args(args) |
143 | 143 | ||
144 | if len(args) != 1: | 144 | if len(args) != 1: |
145 | logger.error("Wrong number of arguments, exiting\n") | ||
146 | parser.print_help() | 145 | parser.print_help() |
147 | sys.exit(1) | 146 | raise WicError("Wrong number of arguments, exiting") |
148 | 147 | ||
149 | if options.build_rootfs and not bitbake_main: | 148 | if options.build_rootfs and not bitbake_main: |
150 | logger.error("Can't build roofs as bitbake is not in the $PATH") | 149 | raise WicError("Can't build roofs as bitbake is not in the $PATH") |
151 | sys.exit(1) | ||
152 | 150 | ||
153 | if not options.image_name: | 151 | if not options.image_name: |
154 | missed = [] | 152 | missed = [] |
@@ -159,9 +157,8 @@ def wic_create_subcommand(args, usage_str): | |||
159 | if not val: | 157 | if not val: |
160 | missed.append(opt) | 158 | missed.append(opt) |
161 | if missed: | 159 | if missed: |
162 | logger.error("The following build artifacts are not specified: %s", | 160 | raise WicError("The following build artifacts are not specified: %s" % |
163 | ", ".join(missed)) | 161 | ", ".join(missed)) |
164 | sys.exit(1) | ||
165 | 162 | ||
166 | if options.image_name: | 163 | if options.image_name: |
167 | BB_VARS.default_image = options.image_name | 164 | BB_VARS.default_image = options.image_name |
@@ -172,8 +169,7 @@ def wic_create_subcommand(args, usage_str): | |||
172 | BB_VARS.vars_dir = options.vars_dir | 169 | BB_VARS.vars_dir = options.vars_dir |
173 | 170 | ||
174 | if options.build_check and not engine.verify_build_env(): | 171 | if options.build_check and not engine.verify_build_env(): |
175 | logger.error("Couldn't verify build environment, exiting\n") | 172 | raise WicError("Couldn't verify build environment, exiting") |
176 | sys.exit(1) | ||
177 | 173 | ||
178 | bootimg_dir = "" | 174 | bootimg_dir = "" |
179 | 175 | ||
@@ -189,7 +185,7 @@ def wic_create_subcommand(args, usage_str): | |||
189 | logger.info("Building rootfs...\n") | 185 | logger.info("Building rootfs...\n") |
190 | if bitbake_main(BitBakeConfigParameters(argv), | 186 | if bitbake_main(BitBakeConfigParameters(argv), |
191 | cookerdata.CookerConfiguration()): | 187 | cookerdata.CookerConfiguration()): |
192 | sys.exit(1) | 188 | raise WicError("bitbake exited with error") |
193 | 189 | ||
194 | rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", options.image_name) | 190 | rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", options.image_name) |
195 | kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE", options.image_name) | 191 | kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE", options.image_name) |
@@ -197,29 +193,28 @@ def wic_create_subcommand(args, usage_str): | |||
197 | "wic-tools", cache=False) | 193 | "wic-tools", cache=False) |
198 | else: | 194 | else: |
199 | if options.build_rootfs: | 195 | if options.build_rootfs: |
200 | logger.error("Image name is not specified, exiting. (Use -e/--image-name to specify it)\n") | 196 | raise WicError("Image name is not specified, exiting. " |
201 | sys.exit(1) | 197 | "(Use -e/--image-name to specify it)") |
202 | native_sysroot = options.native_sysroot | 198 | native_sysroot = options.native_sysroot |
203 | 199 | ||
204 | if not native_sysroot or not os.path.isdir(native_sysroot): | 200 | if not native_sysroot or not os.path.isdir(native_sysroot): |
205 | logger.info("Building wic-tools...\n") | 201 | logger.info("Building wic-tools...\n") |
206 | if bitbake_main(BitBakeConfigParameters("bitbake wic-tools".split()), | 202 | if bitbake_main(BitBakeConfigParameters("bitbake wic-tools".split()), |
207 | cookerdata.CookerConfiguration()): | 203 | cookerdata.CookerConfiguration()): |
208 | sys.exit(1) | 204 | raise WicError("bitbake wic-tools failed") |
209 | native_sysroot = get_bitbake_var("RECIPE_SYSROOT_NATIVE", "wic-tools") | 205 | native_sysroot = get_bitbake_var("RECIPE_SYSROOT_NATIVE", "wic-tools") |
210 | if not native_sysroot: | 206 | if not native_sysroot: |
211 | logger.info("Unable to find the location of the native tools sysroot to use\n") | 207 | raise WicError("Unable to find the location of the native " |
212 | sys.exit(1) | 208 | "tools sysroot to use") |
213 | 209 | ||
214 | wks_file = args[0] | 210 | wks_file = args[0] |
215 | 211 | ||
216 | if not wks_file.endswith(".wks"): | 212 | if not wks_file.endswith(".wks"): |
217 | wks_file = engine.find_canned_image(scripts_path, wks_file) | 213 | wks_file = engine.find_canned_image(scripts_path, wks_file) |
218 | if not wks_file: | 214 | if not wks_file: |
219 | logger.error("No image named %s found, exiting. (Use 'wic list images' "\ | 215 | raise WicError("No image named %s found, exiting. (Use 'wic list images' " |
220 | "to list available images, or specify a fully-qualified OE "\ | 216 | "to list available images, or specify a fully-qualified OE " |
221 | "kickstart (.wks) filename)\n" % args[0]) | 217 | "kickstart (.wks) filename)" % args[0]) |
222 | sys.exit(1) | ||
223 | 218 | ||
224 | if not options.image_name: | 219 | if not options.image_name: |
225 | rootfs_dir = '' | 220 | rootfs_dir = '' |
@@ -229,17 +224,13 @@ def wic_create_subcommand(args, usage_str): | |||
229 | kernel_dir = options.kernel_dir | 224 | kernel_dir = options.kernel_dir |
230 | native_sysroot = options.native_sysroot | 225 | native_sysroot = options.native_sysroot |
231 | if rootfs_dir and not os.path.isdir(rootfs_dir): | 226 | if rootfs_dir and not os.path.isdir(rootfs_dir): |
232 | logger.error("--roofs-dir (-r) not found, exiting\n") | 227 | raise WicError("--roofs-dir (-r) not found, exiting") |
233 | sys.exit(1) | ||
234 | if not os.path.isdir(bootimg_dir): | 228 | if not os.path.isdir(bootimg_dir): |
235 | logger.error("--bootimg-dir (-b) not found, exiting\n") | 229 | raise WicError("--bootimg-dir (-b) not found, exiting") |
236 | sys.exit(1) | ||
237 | if not os.path.isdir(kernel_dir): | 230 | if not os.path.isdir(kernel_dir): |
238 | logger.error("--kernel-dir (-k) not found, exiting\n") | 231 | raise WicError("--kernel-dir (-k) not found, exiting") |
239 | sys.exit(1) | ||
240 | if not os.path.isdir(native_sysroot): | 232 | if not os.path.isdir(native_sysroot): |
241 | logger.error("--native-sysroot (-n) not found, exiting\n") | 233 | raise WicError("--native-sysroot (-n) not found, exiting") |
242 | sys.exit(1) | ||
243 | else: | 234 | else: |
244 | not_found = not_found_dir = "" | 235 | not_found = not_found_dir = "" |
245 | if not os.path.isdir(rootfs_dir): | 236 | if not os.path.isdir(rootfs_dir): |
@@ -251,12 +242,11 @@ def wic_create_subcommand(args, usage_str): | |||
251 | if not_found: | 242 | if not_found: |
252 | if not not_found_dir: | 243 | if not not_found_dir: |
253 | not_found_dir = "Completely missing artifact - wrong image (.wks) used?" | 244 | not_found_dir = "Completely missing artifact - wrong image (.wks) used?" |
254 | logger.error("Build artifacts not found, exiting.") | 245 | logger.info("Build artifacts not found, exiting.") |
255 | logger.info(" (Please check that the build artifacts for the machine") | 246 | logger.info(" (Please check that the build artifacts for the machine") |
256 | logger.info(" selected in local.conf actually exist and that they") | 247 | logger.info(" selected in local.conf actually exist and that they") |
257 | logger.info(" are the correct artifacts for the image (.wks file)).\n") | 248 | logger.info(" are the correct artifacts for the image (.wks file)).\n") |
258 | logger.info("The artifact that couldn't be found was %s:\n %s", not_found, not_found_dir) | 249 | raise WicError("The artifact that couldn't be found was %s:\n %s", not_found, not_found_dir) |
259 | sys.exit(1) | ||
260 | 250 | ||
261 | krootfs_dir = options.rootfs_dir | 251 | krootfs_dir = options.rootfs_dir |
262 | if krootfs_dir is None: | 252 | if krootfs_dir is None: |
@@ -279,9 +269,8 @@ def wic_list_subcommand(args, usage_str): | |||
279 | args = parser.parse_args(args)[1] | 269 | args = parser.parse_args(args)[1] |
280 | 270 | ||
281 | if not engine.wic_list(args, scripts_path): | 271 | if not engine.wic_list(args, scripts_path): |
282 | logger.error("Bad list arguments, exiting\n") | ||
283 | parser.print_help() | 272 | parser.print_help() |
284 | sys.exit(1) | 273 | raise WicError("Bad list arguments, exiting") |
285 | 274 | ||
286 | 275 | ||
287 | def wic_help_topic_subcommand(args, usage_str): | 276 | def wic_help_topic_subcommand(args, usage_str): |
@@ -328,7 +317,7 @@ def main(argv): | |||
328 | if args[0] == "help": | 317 | if args[0] == "help": |
329 | if len(args) == 1: | 318 | if len(args) == 1: |
330 | parser.print_help() | 319 | parser.print_help() |
331 | sys.exit(1) | 320 | raise WicError("help command requires parameter") |
332 | 321 | ||
333 | return hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands) | 322 | return hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands) |
334 | 323 | ||
@@ -337,5 +326,6 @@ if __name__ == "__main__": | |||
337 | try: | 326 | try: |
338 | sys.exit(main(sys.argv[1:])) | 327 | sys.exit(main(sys.argv[1:])) |
339 | except WicError as err: | 328 | except WicError as err: |
329 | print() | ||
340 | logger.error(err) | 330 | logger.error(err) |
341 | sys.exit(1) | 331 | sys.exit(1) |