Use cpio gzip in mic. 28/150628/3
authorxiaojuan.mao <xiaojuan.mao@samsung.com>
Wed, 26 Apr 2017 08:16:49 +0000 (16:16 +0800)
committeryangyuhuan <yuhuan.yang@samsung.com>
Mon, 18 Sep 2017 15:47:03 +0000 (23:47 +0800)
Change-Id: Ic7b3512b153ec5c92cd47a281bab8341f01acaf0

README.rst [changed mode: 0644->0755]
mic/cmd_create.py
mic/conf.py
mic/imager/baseimager.py
mic/imager/loop.py [changed mode: 0644->0755]
mic/kickstart/custom_commands/partition.py [changed mode: 0644->0755]
plugins/imager/fs_plugin.py
plugins/imager/loop_plugin.py
plugins/imager/qcow_plugin.py
plugins/imager/raw_plugin.py
tools/mic

old mode 100644 (file)
new mode 100755 (executable)
index 729100b2e0712f0358b8a0493c1d973bd9043117..54fdbde18f530a065025c561199fb8635e746f0d 100755 (executable)
@@ -146,8 +146,6 @@ def main(parser, args, argv):
 \r
     if args.pack_to is not None:\r
         configmgr.create['pack_to'] = args.pack_to\r
-    if args.cpio:\r
-       configmgr.create['cpio'] = args.cpio \r
 \r
     if args.copy_kernel:\r
         configmgr.create['copy_kernel'] = args.copy_kernel\r
index 45ea0c3e6edcab739c61f2a70a55137cf0f0541d..d844c6533a00e2faee239f386ec9539e6634a5c8 100755 (executable)
@@ -75,7 +75,6 @@ class ConfigMgr(object):
                     "extrarepos": {},
                     "ignore_ksrepo": False,
                     "strict_mode": False,
-                    "cpio":False,
                 },
                 'chroot': {
                     "saveto": None,
index d09d00ed63933d2e74b90be6e4606f54e2b5dde1..3cd11ded4546a88d34a55e27b94f5883a7792ec4 100755 (executable)
@@ -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.
old mode 100644 (file)
new mode 100755 (executable)
index 5dd1e13..d976b88
@@ -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
 
old mode 100644 (file)
new mode 100755 (executable)
index 1d31c11..d692a91
@@ -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
index b5731270a6948b003a4d5ec5efb0e9fbd1ca3dfc..86b1849b80037245360d4d40d6790a2c1f5030ae 100755 (executable)
@@ -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()
index 50aab5208c6c61ba2eddbf5159a9c93e5494471e..6005f463607094ccaf4e0c455c2f339be07a09f5 100755 (executable)
@@ -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()
index cfbbd667473cfa942b952a37dc1d106742584338..76339a555e079d0e4501bdcd75e119c24a441c82 100755 (executable)
@@ -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()
index 0df535c9e0c940940e58f4ecb87a410597237921..09a9714c369ed5b9ef1f629090902c3cd928b3d4 100755 (executable)
@@ -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"])
index 393dd594b3f85e83a128ac33bfb72333d302d1a5..7aa8b35e9a71784055bee5360db51e4ee400f586 100755 (executable)
--- a/tools/mic
+++ b/tools/mic
@@ -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')