more accurate checking for tarball of loop images
authorGui Chen <gui.chen@intel.com>
Mon, 9 Jan 2012 09:38:37 +0000 (17:38 +0800)
committerJF Ding <jian-feng.ding@intel.com>
Mon, 9 Jan 2012 09:50:14 +0000 (17:50 +0800)
Signed-off-by: Gui Chen <gui.chen@intel.com>
plugins/imager/loop_plugin.py

index 649152c..c84efe6 100644 (file)
@@ -183,10 +183,13 @@ class LoopPlugin(ImagerPlugin):
 
     @classmethod
     def do_chroot(cls, target):
-        import tarfile
-        if tarfile.is_tarfile(target):
-            LoopPlugin._do_chroot_tar(target)
-            return
+        if target.endswith('.tar'):
+            import tarfile
+            if tarfile.is_tarfile(target):
+                LoopPlugin._do_chroot_tar(target)
+                return
+            else:
+                raise errors.CreatorError("damaged tarball for loop images")
 
         img = target
         imgsize = misc.get_file_size(img) * 1024L * 1024L