prefer to use 'pbzip2'/'pgzip' than 'bzip2'/'gzip'
authorGui Chen <gui.chen@intel.com>
Mon, 16 Sep 2013 06:29:13 +0000 (02:29 -0400)
committerGui Chen <gui.chen@intel.com>
Mon, 16 Sep 2013 06:37:06 +0000 (02:37 -0400)
Fixes: #1281

Change-Id: I72c996fde9689c7c684848dade4add8b76b00b07
Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/utils/misc.py

index 6810248..d9260f3 100644 (file)
@@ -182,13 +182,21 @@ def extract_rpm(rpmfile, targetdir):
 
 def compressing(fpath, method):
     comp_map = {
-        "gz": "gzip",
-        "bz2": "bzip2"
+        "gz": ["pgzip", "pigz", "gzip"],
+        "bz2": ["pbzip2", "bzip2"],
     }
     if method not in comp_map:
         raise CreatorError("Unsupport compress format: %s, valid values: %s"
                            % (method, ','.join(comp_map.keys())))
-    cmd = find_binary_path(comp_map[method])
+    cmd = None
+    for cmdname in comp_map[method]:
+        try:
+            cmd = find_binary_path(cmdname)
+            break
+        except CreatorError as err:
+            pass
+    if not cmd:
+        raise CreatorError("Command %s not available" % cmdname)
     rc = runner.show([cmd, "-f", fpath])
     if rc:
         raise CreatorError("Failed to %s file: %s" % (comp_map[method], fpath))