diff options
author | xiaojuan.mao <xiaojuan.mao@samsung.com> | 2017-04-26 16:16:49 +0800 |
---|---|---|
committer | xiaojuan.mao <xiaojuan.mao@samsung.com> | 2017-07-13 11:22:11 +0800 |
commit | 074909a7f3379d608efa48072a8c87f500168984 (patch) | |
tree | 491c09ec3aa85e52aae86bc0bcb97880d0a7eb0a | |
parent | 36f04fe55a20f305423a69ce400ce09c8badd724 (diff) | |
download | mic-074909a7f3379d608efa48072a8c87f500168984.tar.gz mic-074909a7f3379d608efa48072a8c87f500168984.tar.bz2 mic-074909a7f3379d608efa48072a8c87f500168984.zip |
Use cpio gzip in mic.
Change-Id: Ic7b3512b153ec5c92cd47a281bab8341f01acaf0
-rwxr-xr-x[-rw-r--r--] | README.rst | 0 | ||||
-rwxr-xr-x | mic/cmd_create.py | 2 | ||||
-rwxr-xr-x | mic/conf.py | 1 | ||||
-rwxr-xr-x | mic/imager/baseimager.py | 15 | ||||
-rwxr-xr-x[-rw-r--r--] | mic/imager/loop.py | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | mic/kickstart/custom_commands/partition.py | 6 | ||||
-rwxr-xr-x | plugins/imager/fs_plugin.py | 3 | ||||
-rwxr-xr-x | plugins/imager/loop_plugin.py | 3 | ||||
-rwxr-xr-x | plugins/imager/qcow_plugin.py | 3 | ||||
-rwxr-xr-x | plugins/imager/raw_plugin.py | 2 | ||||
-rwxr-xr-x | tools/mic | 3 |
11 files changed, 20 insertions, 28 deletions
diff --git a/README.rst b/README.rst index 99b2778..99b2778 100644..100755 --- a/README.rst +++ b/README.rst diff --git a/mic/cmd_create.py b/mic/cmd_create.py index 729100b..54fdbde 100755 --- a/mic/cmd_create.py +++ b/mic/cmd_create.py @@ -146,8 +146,6 @@ def main(parser, args, argv): if args.pack_to is not None:
configmgr.create['pack_to'] = args.pack_to
- if args.cpio:
- configmgr.create['cpio'] = args.cpio
if args.copy_kernel:
configmgr.create['copy_kernel'] = args.copy_kernel
diff --git a/mic/conf.py b/mic/conf.py index 45ea0c3..d844c65 100755 --- a/mic/conf.py +++ b/mic/conf.py @@ -75,7 +75,6 @@ class ConfigMgr(object): "extrarepos": {}, "ignore_ksrepo": False, "strict_mode": False, - "cpio":False, }, 'chroot': { "saveto": None, diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index d09d00e..3cd11de 100755 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -87,7 +87,6 @@ class BaseImageCreator(object): self.pack_to = None self.repourl = {} self.multiple_partitions = False - self.cpio = False # If the kernel is save to the destdir when copy_kernel cmd is called. self._need_copy_kernel = False @@ -153,6 +152,8 @@ class BaseImageCreator(object): if part.fstype and part.fstype == "btrfs": self._dep_checks.append("mkfs.btrfs") break + if part.fstype == "cpio": + part.fstype = "ext4" if len(self.ks.handler.partition.partitions) > 1: self.multiple_partitions = True @@ -1251,27 +1252,25 @@ class BaseImageCreator(object): self._instloops.remove(item) def create_cpio_image(self): - if self.cpio: - cpiomountdir = self._instroot + '/mnt/initrd' - if os.path.exists(cpiomountdir): + for item in self._instloops: + if item['cpioopts']: msger.info("Create image by cpio.") - imgfile = os.path.join(self._imgdir, 'ramdisk.img') + imgfile = os.path.join(self._imgdir, item['name']) if imgfile: os.remove(imgfile) try: cpiocmd = fs.find_binary_path('cpio') if cpiocmd: oldoutdir = os.getcwd() + cpiomountdir = os.path.join(self._instroot, item['mountpoint'].lstrip('/')) os.chdir(cpiomountdir) # find . | cpio --create --'format=newc' | gzip > ../ramdisk.img - runner.show('find . | cpio -o -H newc | gzip > %s' % imgfile) + runner.show('find . | cpio --create --format=%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) - else: - msger.warning("Do not create image by cpio. There is no directory '/mnt/initrd'.") def package(self, destdir = "."): """Prepares the created image for final delivery. diff --git a/mic/imager/loop.py b/mic/imager/loop.py index 5dd1e13..d976b88 100644..100755 --- a/mic/imager/loop.py +++ b/mic/imager/loop.py @@ -164,6 +164,7 @@ class LoopImageCreator(BaseImageCreator): 'extopts': part.extopts or None, 'vdfsopts': part.vdfsopts or None, 'squashfsopts': part.squashfsopts or None, + 'cpioopts': part.cpioopts or None, 'loop': None, # to be created in _mount_instroot 'uuid': part.uuid or None, 'kspart' : part, @@ -308,10 +309,11 @@ class LoopImageCreator(BaseImageCreator): """ minsize = 0 for item in self._instloops: - if item['name'] == self._img_name: - minsize = item['loop'].resparse(size) - else: - item['loop'].resparse(size) + if not item['cpioopts']: + if item['name'] == self._img_name: + minsize = item['loop'].resparse(size) + else: + item['loop'].resparse(size) return minsize diff --git a/mic/kickstart/custom_commands/partition.py b/mic/kickstart/custom_commands/partition.py index 1d31c11..d692a91 100644..100755 --- a/mic/kickstart/custom_commands/partition.py +++ b/mic/kickstart/custom_commands/partition.py @@ -31,6 +31,7 @@ class Mic_PartData(FC4_PartData): self.exclude_image = kwargs.get("exclude_from_image", False) self.vdfsopts = kwargs.get("vdfsopts", None) self.squashfsopts = kwargs.get("squashfsopts", None) + self.cpioopts = kwargs.get("cpioopts", None) def _getArgsAsStr(self): retval = FC4_PartData._getArgsAsStr(self) @@ -49,7 +50,8 @@ class Mic_PartData(FC4_PartData): retval += " --vdfsoptions=%s" % self.vdfsopts if self.squashfsopts: retval += " --squashfsoptions=%s" % self.squashfsopts - + if self.cpioopts: + retval += " --cpiooptions=%s" % self.cpioopts return retval class Mic_Partition(FC4_Partition): @@ -73,4 +75,6 @@ class Mic_Partition(FC4_Partition): default=None) op.add_option("--squashfsoptions", type="string", action="store", dest="squashfsopts", default=None) + op.add_option("--cpiooptions", type="string", action="store", dest="cpioopts", + default=None) return op diff --git a/plugins/imager/fs_plugin.py b/plugins/imager/fs_plugin.py index b573127..86b1849 100755 --- a/plugins/imager/fs_plugin.py +++ b/plugins/imager/fs_plugin.py @@ -95,7 +95,6 @@ class FsPlugin(ImagerPlugin): #Download the source packages ###private options if args.include_src: installed_pkgs = creator.get_installed_packages() - msger.info('--------------------------------------------------') msger.info('Generating the image with source rpms included ...') if not misc.SrcpkgsDownload(installed_pkgs, creatoropts["repomd"], creator._instroot, creatoropts["cachedir"]): @@ -103,8 +102,6 @@ class FsPlugin(ImagerPlugin): creator.configure(creatoropts["repomd"]) creator.copy_kernel() - if creatoropts['cpio']: - creator.create_cpio_image() creator.unmount() creator.package(creatoropts["destdir"]) creator.create_manifest() diff --git a/plugins/imager/loop_plugin.py b/plugins/imager/loop_plugin.py index 50aab52..6005f46 100755 --- a/plugins/imager/loop_plugin.py +++ b/plugins/imager/loop_plugin.py @@ -102,8 +102,7 @@ class LoopPlugin(ImagerPlugin): creator.install() creator.configure(creatoropts["repomd"]) creator.copy_kernel() - if creatoropts['cpio']: - creator.create_cpio_image() + creator.create_cpio_image() creator.unmount() creator.package(creatoropts["destdir"]) creator.create_manifest() diff --git a/plugins/imager/qcow_plugin.py b/plugins/imager/qcow_plugin.py index cfbbd66..76339a5 100755 --- a/plugins/imager/qcow_plugin.py +++ b/plugins/imager/qcow_plugin.py @@ -133,8 +133,7 @@ class QcowPlugin(ImagerPlugin): creator.install() creator.configure(creatoropts["repomd"]) creator.copy_kernel() - if creatoropts['cpio']: - creator.create_cpio_image() + creator.create_cpio_image() creator.unmount() creator.package(creatoropts["destdir"]) creator.create_manifest() diff --git a/plugins/imager/raw_plugin.py b/plugins/imager/raw_plugin.py index 0df535c..09a9714 100755 --- a/plugins/imager/raw_plugin.py +++ b/plugins/imager/raw_plugin.py @@ -100,8 +100,6 @@ class RawPlugin(ImagerPlugin): creator.install() creator.configure(creatoropts["repomd"]) creator.copy_kernel() - if creatoropts['cpio']: - creator.create_cpio_image() creator.unmount() creator.generate_bmap() creator.package(creatoropts["destdir"]) @@ -65,9 +65,6 @@ def create_parser(parser): """ parent_parser = ArgumentParser(add_help=False) - parent_parser.add_argument('--cpio', action='store_true', - dest='cpio', default=False, - help='Use cpio to generate image') parent_parser.add_argument('ksfile', help='Path of ksfile') parent_parser.add_argument('--logfile', dest='logfile', default=None, help='Path of logfile') |