summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryuhuan.yang <yuhuan.yang@123.com>2017-08-07 19:07:17 +0800
committeryuhuan.yang <yuhuan.yang@123.com>2017-08-08 17:45:08 +0800
commita5cca2b08349c596407a156379b6bf1c36b62205 (patch)
tree0f58fb03fec74d20e351bdfa23a7898cc6bdd377
parentc8c46eef23bf9327f95cfa83400d1986e372202e (diff)
downloadmic-a5cca2b08349c596407a156379b6bf1c36b62205.tar.gz
mic-a5cca2b08349c596407a156379b6bf1c36b62205.tar.bz2
mic-a5cca2b08349c596407a156379b6bf1c36b62205.zip
Add new option of tpk_install
Change-Id: Id67c37b143f723e98491aad1d6730446149f01a5
-rwxr-xr-xmic/cmd_create.py4
-rwxr-xr-xmic/conf.py1
-rwxr-xr-xmic/imager/baseimager.py19
-rwxr-xr-xtools/mic4
4 files changed, 26 insertions, 2 deletions
diff --git a/mic/cmd_create.py b/mic/cmd_create.py
index 8dfaf8f..3189af2 100755
--- a/mic/cmd_create.py
+++ b/mic/cmd_create.py
@@ -191,7 +191,9 @@ def main(parser, args, argv):
configmgr.create['ignore_ksrepo'] = args.ignore_ksrepo
if args.run_script:
configmgr.create['run_script'] = args.run_script
-
+ if args.tpk_install:
+ configmgr.create['tpk_install'] = args.tpk_install
+
creater = createrClass()
creater.do_create(args)
diff --git a/mic/conf.py b/mic/conf.py
index a45b05e..d56d3cb 100755
--- a/mic/conf.py
+++ b/mic/conf.py
@@ -76,6 +76,7 @@ class ConfigMgr(object):
"ignore_ksrepo": False,
"strict_mode": False,
"run_script": None,
+ "tpk_install": None,
},
'chroot': {
"saveto": None,
diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py
index e0340a1..dd758b4 100755
--- a/mic/imager/baseimager.py
+++ b/mic/imager/baseimager.py
@@ -37,6 +37,7 @@ from mic.utils.errors import CreatorError, Abort
from mic.utils import misc, grabber, runner, fs_related as fs
from mic.chroot import kill_proc_inchroot
from mic.archive import get_archive_suffixes
+from mic.conf import configmgr
#post script max run time
MAX_RUN_TIME = 120
@@ -767,6 +768,23 @@ class BaseImageCreator(object):
runner.show('umount -l %s' % self.workdir)
+ def cp_tpk(self):
+ #Add tpk-install option
+ createopts = configmgr.create
+ if createopts['tpk_install']:
+ path = createopts['tpk_install']
+ file_list = os.listdir(path)
+ for f in file_list:
+ sub = os.path.splitext(f)[1]
+ if sub != ".tpk":
+ raise CreatorError("Not all files in the path: "+path +" is tpk")
+
+ tpk_dir = "/usr/apps/.preload-tpk"
+ fs.makedirs(self._instroot + "/usr/apps")
+ fs.makedirs(self._instroot + tpk_dir)
+ for f in file_list:
+ shutil.copy(path+"/"+f,self._instroot + tpk_dir)
+
def mount(self, base_on = None, cachedir = None):
"""Setup the target filesystem in preparation for an install.
@@ -833,6 +851,7 @@ class BaseImageCreator(object):
# get size of available space in 'instroot' fs
self._root_fs_avail = misc.get_filesystem_avail(self._instroot)
+ self.cp_tpk()
def unmount(self):
"""Unmounts the target filesystem.
diff --git a/tools/mic b/tools/mic
index 59138fc..e807a77 100755
--- a/tools/mic
+++ b/tools/mic
@@ -124,7 +124,7 @@ def create_parser(parser):
dest='strict_mode', default=False,
help='Abort creation of image, if there are some errors'
' during rpm installation. ')
-
+
parent_parser.add_argument('-d', '--debug', action='store_true',
help='debug output')
parent_parser.add_argument('-v', '--verbose', action='store_true',
@@ -134,6 +134,8 @@ def create_parser(parser):
help='interactive output')
parent_parser.add_argument('--run_script', action='store', dest='run_script',
default=None, help='Run script on local PC after image created')
+ parent_parser.add_argument('--tpk_install', action='store', dest='tpk_install',
+ default=None, help='Copy tpk file to /usr/apps/.preload-tpk')
parser.set_defaults(alias="cr")