From 9d138c4d18dd05e9e650a4527df80a61e155b5bf Mon Sep 17 00:00:00 2001 From: Dohyung Kim Date: Thu, 2 Jul 2015 11:39:09 +0900 Subject: [PATCH] add no_shrink option to partition, fix parameter of disk.expand() * 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 --- mic/imager/loop.py | 4 ++++ mic/kickstart/custom_commands/partition.py | 4 ++++ mic/utils/fs_related.py | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mic/imager/loop.py b/mic/imager/loop.py index eab83b2..7fb5024 100755 --- a/mic/imager/loop.py +++ b/mic/imager/loop.py @@ -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: diff --git a/mic/kickstart/custom_commands/partition.py b/mic/kickstart/custom_commands/partition.py index d692a91..d0385b7 100755 --- a/mic/kickstart/custom_commands/partition.py +++ b/mic/kickstart/custom_commands/partition.py @@ -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 diff --git a/mic/utils/fs_related.py b/mic/utils/fs_related.py index 54f68da..2abbead 100644 --- a/mic/utils/fs_related.py +++ b/mic/utils/fs_related.py @@ -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 -- 2.7.4