Update tar command option
authorLihong Sun <lihongx.sun@intel.com>
Thu, 11 Dec 2014 06:56:25 +0000 (01:56 -0500)
committeradmin <yuhuan.yang@samsung.com>
Thu, 4 Feb 2016 10:32:27 +0000 (18:32 +0800)
List whole files to the tar command instead of giving a dir

Change-Id: I1916924eaf63876c9d4fe0bcfa64f4f8e142a42e

mic/archive.py

index 35571ce..a612389 100644 (file)
@@ -248,16 +248,18 @@ def _do_tar(archive_name, target_name):
     @target_name: the name of the target to tar
     @retval: the path of the archived file
     """
+    file_list = []
     if os.path.isdir(target_name):
         target_dir = target_name
         target_name = "."
+        for target_file in os.listdir(target_dir):
+            file_list.append(target_file)
     else:
         target_dir = os.path.dirname(target_name)
         target_name = os.path.basename(target_name)
-
-    cmdln = ["tar", "-S", "-C", target_dir, "-cf", archive_name, target_name]
-
-
+        file_list.append(target_name)
+    cmdln = ["tar", "-S", "-C", target_dir, "-cf", archive_name]
+    cmdln.extend(file_list)
     _call_external(cmdln)
 
     return archive_name
@@ -271,9 +273,7 @@ def _do_untar(archive_name, target_dir=None):
     """
     if not target_dir:
         target_dir = os.getcwd()
-
     cmdln = ["tar", "-S", "-C", target_dir, "-xf", archive_name]
-
     (returncode, stdout, stderr) = _call_external(cmdln)
     if returncode != 0:
         raise OSError, os.linesep.join([stdout, stderr])