add no_shrink option to partition, fix parameter of disk.expand()
authorDohyung Kim <dohyung2.kim@samsung.com>
Thu, 2 Jul 2015 02:39:09 +0000 (11:39 +0900)
committeryuhuan.yang <yuhuan.yang@samsung.com>
Fri, 26 Jan 2018 05:53:27 +0000 (13:53 +0800)
* add no_shrink option to partition
  - if no_shrink is enable in specific partition, this partition do not shrink.
  - if not, following pack_to or shrink option in loop command
* fix parameter of disk.expand()
  - expand(size) -> expand(size=size)

Change-Id: Ic9486621795c0e1a867fd551d61f152c693b6c52
Signed-off-by: Dohyung Kim <dohyung2.kim@samsung.com>
mic/imager/loop.py
mic/kickstart/custom_commands/partition.py
mic/utils/fs_related.py

index eab83b2134c630a0642fb9ce29823a85225046be..7fb502469407d31cb200cce47953c594bc4a0f8d 100755 (executable)
@@ -169,6 +169,7 @@ class LoopImageCreator(BaseImageCreator):
                     'uuid': part.uuid or None,
                     'kspart' : part,
                     'exclude_image' : part.exclude_image or None,
+                    'no_shrink': part.no_shrink or False,
                     })
             self._instloops = allloops
 
@@ -310,6 +311,9 @@ class LoopImageCreator(BaseImageCreator):
         minsize = 0
         for item in self._instloops:
             if not item['cpioopts']:
+                if item['no_shrink']:
+                    item['loop'].resparse()
+                    continue
                 if item['name'] == self._img_name:
                     minsize = item['loop'].resparse(size)
                 else:
index d692a91381de070d0f3fa5d337df70451c295e35..d0385b7ea26a0ca439ba4e8721f28ef28c457f16 100755 (executable)
@@ -32,6 +32,7 @@ class Mic_PartData(FC4_PartData):
         self.vdfsopts = kwargs.get("vdfsopts", None)
         self.squashfsopts = kwargs.get("squashfsopts", None)
         self.cpioopts = kwargs.get("cpioopts", None)
+        self.no_shrink = kwargs.get("no_shrink", False)
 
     def _getArgsAsStr(self):
         retval = FC4_PartData._getArgsAsStr(self)
@@ -52,6 +53,8 @@ class Mic_PartData(FC4_PartData):
             retval += " --squashfsoptions=%s" % self.squashfsopts
         if self.cpioopts:
             retval += " --cpiooptions=%s" % self.cpioopts
+        if self.no_shrink:
+            retval += " --no-shrink"
         return retval
 
 class Mic_Partition(FC4_Partition):
@@ -77,4 +80,5 @@ class Mic_Partition(FC4_Partition):
                       default=None)
         op.add_option("--cpiooptions", type="string", action="store", dest="cpioopts",
                       default=None)
+        op.add_option("--no-shrink", action="store_true", dest="no_shrink", default=False)
         return op
index 54f68da75457e849c96b9082abfb28e992c523ea..2abbeadff97811d3472fa056e87a1ceb8ca179af 100644 (file)
@@ -483,7 +483,7 @@ class ExtDiskMount(DiskMount):
             return
 
         if size > current_size:
-            self.disk.expand(size)
+            self.disk.expand(size=size)
 
         self.__fsck()
 
@@ -580,7 +580,7 @@ class VfatDiskMount(DiskMount):
             return
 
         if size > current_size:
-            self.disk.expand(size)
+            self.disk.expand(size=size)
 
         self.__fsck()
 
@@ -685,7 +685,7 @@ class BtrfsDiskMount(DiskMount):
             return
 
         if size > current_size:
-            self.disk.expand(size)
+            self.disk.expand(size=size)
 
         self.__fsck()
         return size