diff options
author | xiaojuan.mao <xiaojuan.mao@samsung.com> | 2017-06-12 20:18:06 +0800 |
---|---|---|
committer | xiaojuan.mao <xiaojuan.mao@samsung.com> | 2017-07-13 11:24:02 +0800 |
commit | 2a2242f4ca49f8f9e5c5fd97d8391f7832dac4da (patch) | |
tree | 7a81b5ebf95522a41d6d1e596afe2ad6ca268c45 | |
parent | 141b4c20bd515f5c1a32ccd4e2c054939f6a9168 (diff) | |
download | mic-2a2242f4ca49f8f9e5c5fd97d8391f7832dac4da.tar.gz mic-2a2242f4ca49f8f9e5c5fd97d8391f7832dac4da.tar.bz2 mic-2a2242f4ca49f8f9e5c5fd97d8391f7832dac4da.zip |
Change the order of generating image by cpio.
Change-Id: Ia1d2cc22b9a6e695a6f905574f8081c5910f0e8b
-rwxr-xr-x | mic/imager/baseimager.py | 17 | ||||
-rwxr-xr-x | plugins/imager/loop_plugin.py | 3 | ||||
-rwxr-xr-x | plugins/imager/qcow_plugin.py | 3 |
3 files changed, 18 insertions, 5 deletions
diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index 26104c8..a5c53b4 100755 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -706,7 +706,7 @@ class BaseImageCreator(object): return self.cachedir def __sanity_check(self): - """Ensure that the config we've been given is sane.""" + """Ensure that the config we've been given is same.""" if not (kickstart.get_packages(self.ks) or kickstart.get_groups(self.ks)): raise CreatorError("No packages or groups specified") @@ -1268,15 +1268,26 @@ class BaseImageCreator(object): cpiocmd = fs.find_binary_path('cpio') if cpiocmd: oldoutdir = os.getcwd() - cpiomountdir = os.path.join(self._instroot, item['mountpoint'].lstrip('/')) + cpiomountdir = os.path.join(self._imgdir, item['mountpoint'].lstrip('/')) os.chdir(cpiomountdir) # find . | cpio --create --'format=newc' | gzip > ../ramdisk.img runner.show('find . | cpio --create %s | gzip > %s' % (item['cpioopts'], imgfile)) shutil.rmtree(cpiomountdir, ignore_errors=True) - fs.makedirs(cpiomountdir) os.chdir(oldoutdir) except OSError, (errno, msg): raise errors.KsError("Create image by cpio error: %s" % msg) + def copy_cpio_resource(self): + for item in self._instloops: + if item['cpioopts']: + msger.info("Copy resouces to be used for creating image by cpio.") + try: + cpcmd = fs.find_binary_path('cp') + if cpcmd: + cpiomountdir = os.path.join(self._instroot, item['mountpoint'].lstrip('/')) + runner.show('cp -r %s %s' % (cpiomountdir, self._imgdir)) + shutil.rmtree(cpiomountdir, ignore_errors=True) + except OSError, (errno, msg): + raise errors.KsError("Copy resouces error: %s" % msg) def package(self, destdir = "."): """Prepares the created image for final delivery. diff --git a/plugins/imager/loop_plugin.py b/plugins/imager/loop_plugin.py index 6005f46..70dafc0 100755 --- a/plugins/imager/loop_plugin.py +++ b/plugins/imager/loop_plugin.py @@ -102,8 +102,9 @@ class LoopPlugin(ImagerPlugin): creator.install() creator.configure(creatoropts["repomd"]) creator.copy_kernel() - creator.create_cpio_image() + creator.copy_cpio_resource() creator.unmount() + creator.create_cpio_image() creator.package(creatoropts["destdir"]) creator.create_manifest() diff --git a/plugins/imager/qcow_plugin.py b/plugins/imager/qcow_plugin.py index 76339a5..33ed358 100755 --- a/plugins/imager/qcow_plugin.py +++ b/plugins/imager/qcow_plugin.py @@ -133,8 +133,9 @@ class QcowPlugin(ImagerPlugin): creator.install() creator.configure(creatoropts["repomd"]) creator.copy_kernel() - creator.create_cpio_image() + creator.copy_cpio_resource() creator.unmount() + creator.create_cpio_image() creator.package(creatoropts["destdir"]) creator.create_manifest() |