diff options
author | jianzhong.fang <jz.fang@samsung.com> | 2016-08-19 08:27:03 +0800 |
---|---|---|
committer | SoonKyu Park <sk7.park@samsung.com> | 2016-09-23 16:50:30 +0900 |
commit | ac1526642ae23e02ce6bed44386902fb666e6dad (patch) | |
tree | eab3e2b82248f76ee4f5e1e3d3d785adb496499f | |
parent | 4161678b3bf9d2eb36fdcb82c820bce02f6ba5bc (diff) | |
download | mic-ac1526642ae23e02ce6bed44386902fb666e6dad.tar.gz mic-ac1526642ae23e02ce6bed44386902fb666e6dad.tar.bz2 mic-ac1526642ae23e02ce6bed44386902fb666e6dad.zip |
Add exclude-from-image option to exclude specific images
Change-Id: I5651efc10e3b250af0f31f5224f9dca40a5d7124
-rw-r--r-- | mic/imager/baseimager.py | 14 | ||||
-rw-r--r-- | mic/imager/loop.py | 4 | ||||
-rwxr-xr-x | mic/imager/raw.py | 3 | ||||
-rw-r--r-- | mic/kickstart/custom_commands/partition.py | 5 |
4 files changed, 25 insertions, 1 deletions
diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index 01936a1..7b201d2 100644 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -1209,6 +1209,18 @@ class BaseImageCreator(object): f.write("%s %s" % (md5sum, os.path.basename(image_name))) self.outimage.append(image_name+".md5sum") + def remove_exclude_image(self): + for item in self._instloops[:]: + if item['exclude_image']: + msger.info("Removing %s in image." % item['name']) + imgfile = os.path.join(self._imgdir, item['name']) + try: + os.remove(imgfile) + except OSError as err: + if err.errno == errno.ENOENT: + pass + self._instloops.remove(item) + def package(self, destdir = "."): """Prepares the created image for final delivery. @@ -1221,6 +1233,8 @@ class BaseImageCreator(object): this defaults to the current directory. """ + self.remove_exclude_image() + self._stage_final_image() if not os.path.exists(destdir): diff --git a/mic/imager/loop.py b/mic/imager/loop.py index 51d8181..0943ec7 100644 --- a/mic/imager/loop.py +++ b/mic/imager/loop.py @@ -157,6 +157,7 @@ class LoopImageCreator(BaseImageCreator): 'loop': None, # to be created in _mount_instroot 'uuid': part.uuid or None, 'kspart' : part, + 'exclude_image' : part.exclude_image or None, }) self._instloops = allloops @@ -329,7 +330,8 @@ class LoopImageCreator(BaseImageCreator): "extopts": None, "loop": None, "uuid": None, - "kspart": None + "kspart": None, + "exclude_image" : None }) self._check_imgdir() diff --git a/mic/imager/raw.py b/mic/imager/raw.py index 08f9683..82e9a16 100755 --- a/mic/imager/raw.py +++ b/mic/imager/raw.py @@ -597,3 +597,6 @@ class RawImageCreator(BaseImageCreator): if self.compress_image: self.image_files.update({'compress': self.compress_image}) super(RawImageCreator, self).create_manifest() + + def remove_exclude_image(self): + pass diff --git a/mic/kickstart/custom_commands/partition.py b/mic/kickstart/custom_commands/partition.py index d4c39bf..89dad58 100644 --- a/mic/kickstart/custom_commands/partition.py +++ b/mic/kickstart/custom_commands/partition.py @@ -28,6 +28,7 @@ class Mic_PartData(FC4_PartData): self.extopts = kwargs.get("extopts", None) self.part_type = kwargs.get("part_type", None) self.uuid = kwargs.get("uuid", None) + self.exclude_image = kwargs.get("exclude_from_image", False) def _getArgsAsStr(self): retval = FC4_PartData._getArgsAsStr(self) @@ -40,6 +41,8 @@ class Mic_PartData(FC4_PartData): retval += " --part-type=%s" % self.part_type if self.uuid: retval += " --uuid=%s" % self.uuid + if self.exclude_image: + retval += " --exclude-from-image" return retval @@ -58,4 +61,6 @@ class Mic_Partition(FC4_Partition): op.add_option("--part-type", type="string", action="store", dest="part_type", default=None) op.add_option("--uuid", dest="uuid", action="store", type="string") + op.add_option("--exclude-from-image", action="store_true", dest="exclude_image", + default=False) return op |