Skip to contentSkip to conversation

wic usability fixes

PATCH New Tom Zanussi 1 participant 3 messages Oct 18, 2013

lore
Share & tools
lore
#0 lore raw

cover wic usability fixes

These fixes point out problems or avoid ugly backtraces when users supply invalid input values.

The following changes since commit fd09f894b40dadb8bc8b267a26dbf52e22a53d66:

wic: add pseudo to the populate-extfs step (2013-10-16 14:11:53 -0500)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib.git tzanussi/wic-fixes-2
http://git.yoctoproject.org/cgit.cgi//log/?h=tzanussi/wic-fixes-2

Tom Zanussi (2):
wic: Check for the existence/correctness of build artifacts
wic: Initialize return values in find_artifacts()

 scripts/lib/image/engine.py |  2 ++
 scripts/wic                 | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)
Signature · 1 line
1.7.11.4
#1 lore raw

PATCH 1/2 wic: Check for the existence/correctness of build artifacts

If a user uses the -e option and specifies a machine that hasn't been built or uses the wrong .wks script for the build artifacts pointed to by the current machine, we should point that out for obvious cases.

---
 scripts/wic | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
scripts/wic +20 -0
index a7221c3..08473d3 100755
@@ -143,6 +143,26 @@ def wic_create_subcommand(args, usage_str):
         if not os.path.isdir(native_sysroot):
             print "--native-sysroot (-n) not found, exiting\n"
             sys.exit(1)
+    else:
+        not_found = not_found_dir = ""
+        if not os.path.isdir(rootfs_dir):
+            (not_found, not_found_dir) = ("rootfs-dir", rootfs_dir)
+        elif not os.path.isdir(hdddir) and not os.path.isdir(staging_data_dir):
+            (not_found, not_found_dir) = ("bootimg-dir", bootimg_dir)
+        elif not os.path.isdir(kernel_dir):
+            (not_found, not_found_dir) = ("kernel-dir", kernel_dir)
+        elif not os.path.isdir(native_sysroot):
+            (not_found, not_found_dir) = ("native-sysroot", native_sysroot)
+        if not_found:
+            if not not_found_dir:
+                not_found_dir = "Completely missing artifact - wrong image (.wks) used?"
+            print "Build artifacts not found, exiting."
+            print "  (Please check that the build artifacts for the machine"
+            print "   selected in local.conf actually exist and that they"
+            print "   are the correct artifacts for the image (.wks file)).\n"
+            print "The artifact that couldn't be found was %s:\n  %s" % \
+                (not_found, not_found_dir)
+            sys.exit(1)
 
     wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
                native_sysroot, hdddir, staging_data_dir, scripts_path,
Signature · 1 line
1.7.11.4
#2 lore raw

PATCH 2/2 wic: Initialize return values in find_artifacts()

If one of these isn't found, it won't be initialized and will throw an UnboundLocalError.

---
 scripts/lib/image/engine.py | 2 ++
 1 file changed, 2 insertions(+)
scripts/lib/image/engine.py +2 -0
index be29222..b3a9c74 100644
@@ -82,6 +82,8 @@ def find_artifacts(image_name):
         print "Couldn't get '%s' output, exiting." % bitbake_env_cmd
         sys.exit(1)
 
+    rootfs_dir = kernel_dir = hdddir = staging_data_dir = native_sysroot = ""
+
     for line in bitbake_env_lines.split('\n'):
         if (get_line_val(line, "IMAGE_ROOTFS")):
             rootfs_dir = get_line_val(line, "IMAGE_ROOTFS")
Signature · 1 line
1.7.11.4