summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDohyung Kim <dohyung2.kim@samsung.com>2017-07-20 16:39:49 +0900
committeryuhuan.yang <yuhuan.yang@samsung.com>2018-01-30 13:27:25 +0800
commit9ab2f64216560503211f5e5bd9313e82c1986252 (patch)
tree251080a88316d9f0b9727b1cd88a6414588702f0
parenta525045ae230064e5461cd3395e2e8d6c531bf9b (diff)
downloadmic-9ab2f64216560503211f5e5bd9313e82c1986252.tar.gz
mic-9ab2f64216560503211f5e5bd9313e82c1986252.tar.bz2
mic-9ab2f64216560503211f5e5bd9313e82c1986252.zip
use the value of --pack-to option as filename to match all outputs
AS-IS: $ sudo mic cr loop PLATFORM.ks --release SNAPSHOT --pack-to IMAGENAME.tar.gz IMAGENAME.tar.gz IMAGENAME.xml SNAPSHOT-PLATFORM.packages SNAPSHOT-PLATFORM.files SNAPSHOT-PLATFORM.license SNAPSHOT-PLATFORM.ks ... TO-BE: $ sudo mic cr loop PLATFORM.ks --release SNAPSHOT --pack-to IMAGENAME.tar.gz IMAGENAME.tar.gz IMAGENAME.xml IMAGENAME.packages IMAGENAME.files IMAGENAME.license IMAGENAME.ks ... Change-Id: I5cc148a09b3e4cc4ed863100f0fde4df362038cd Signed-off-by: Dohyung Kim <dohyung2.kim@samsung.com>
-rwxr-xr-xmic/conf.py13
-rwxr-xr-xmic/imager/baseimager.py2
-rwxr-xr-xmic/utils/misc.py9
3 files changed, 22 insertions, 2 deletions
diff --git a/mic/conf.py b/mic/conf.py
index 33e534f..9299cfe 100755
--- a/mic/conf.py
+++ b/mic/conf.py
@@ -227,6 +227,12 @@ class ConfigMgr(object):
self.create['release'],
self.create['name'])
self.create['name'] = self.create['release'] + '_' + self.create['name']
+ if self.create['pack_to'] is not None:
+ if '@NAME@' in self.create['pack_to']:
+ self.create['pack_to'] = self.create['pack_to'].replace('@NAME@', self.create['name'])
+ self.create['name'] = misc.strip_archive_suffix(self.create['pack_to'])
+ if self.create['name'] is None:
+ raise errors.CreatorError("Not supported archive file format: %s" % self.create['pack_to'])
if not self.create['logfile']:
self.create['logfile'] = os.path.join(self.create['destdir'],
@@ -234,6 +240,13 @@ class ConfigMgr(object):
self.create['releaselog'] = True
self.set_logfile()
+ elif self.create['pack_to'] is not None:
+ if '@NAME@' in self.create['pack_to']:
+ self.create['pack_to'] = self.create['pack_to'].replace('@NAME@', self.create['name'])
+ self.create['name'] = misc.strip_archive_suffix(self.create['pack_to'])
+ if self.create['name'] is None:
+ raise errors.CreatorError("Not supported archive file format: %s" % self.create['pack_to'])
+
msger.info("Retrieving repo metadata:")
ksrepos = kickstart.get_repos(ks,
self.create['extrarepos'],
diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py
index a1ddb6a..ef86f0f 100755
--- a/mic/imager/baseimager.py
+++ b/mic/imager/baseimager.py
@@ -116,8 +116,6 @@ class BaseImageCreator(object):
self.destdir = os.path.abspath(os.path.expanduser(self.destdir))
if self.pack_to:
- if '@NAME@' in self.pack_to:
- self.pack_to = self.pack_to.replace('@NAME@', self.name)
(tar, ext) = os.path.splitext(self.pack_to)
if ext in (".gz", ".bz2", ".lzo", ".bz") and tar.endswith(".tar"):
ext = ".tar" + ext
diff --git a/mic/utils/misc.py b/mic/utils/misc.py
index 5aa5b16..be14d01 100755
--- a/mic/utils/misc.py
+++ b/mic/utils/misc.py
@@ -41,6 +41,7 @@ except ImportError:
xmlparse = cElementTree.parse
from mic import msger
+from mic.archive import get_archive_suffixes
from mic.utils.errors import CreatorError, SquashfsError
from mic.utils.fs_related import find_binary_path, makedirs
from mic.utils.grabber import myurlgrab
@@ -1044,3 +1045,11 @@ def strip_end(text, suffix):
if not text.endswith(suffix):
return text
return text[:-len(suffix)]
+
+def strip_archive_suffix(filename):
+ for suffix in get_archive_suffixes():
+ if filename.endswith(suffix):
+ return filename[:-len(suffix)]
+ else:
+ msger.warning("Not supported archive file format: %s" % filename)
+ return None