[OE-core] [wic patch 4/5] wic: Add option to keep partition images
Andreas J. Reichel
andreas.reichel at tngtech.com
Fri Apr 21 12:11:44 UTC 2017
Add new option -P, --keep-partition-images to prevent
deletion of .p* files created by wic's direct imager plugin.
Signed-off-by: Andreas Reichel <andreas.reichel.ext at siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka at siemens.com>
Signed-off-by: Daniel Wagner <daniel.wagner at siemens.com>
---
scripts/lib/wic/help.py | 5 +++++
scripts/lib/wic/plugins/imager/direct.py | 28 +++++++++++++++++++---------
scripts/wic | 2 ++
3 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index ba0c8e5eea..026a383155 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -134,6 +134,7 @@ wic_create_usage = """
[-e | --image-name] [-s, --skip-build-check] [-D, --debug]
[-r, --rootfs-dir] [-b, --bootimg-dir]
[-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs]
+ [-P, --keep-partition-images]
[-c, --compress-with] [-m, --bmap]
This command creates an OpenEmbedded image based on the 'OE kickstart
@@ -155,6 +156,7 @@ SYNOPSIS
[-e | --image-name] [-s, --skip-build-check] [-D, --debug]
[-r, --rootfs-dir] [-b, --bootimg-dir]
[-k, --kernel-dir] [-n, --native-sysroot] [-f, --build-rootfs]
+ [-P, --keep-partition-images]
[-c, --compress-with] [-m, --bmap]
DESCRIPTION
@@ -227,6 +229,9 @@ DESCRIPTION
The -m option is used to produce .bmap file for the image. This file
can be used to flash image using bmaptool utility.
+
+ The -p option is used to keep the individual partition image files .p*,
+ created by the direct imager plugin.
"""
wic_list_usage = """
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index d6b47ff0bb..b27584bdbe 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -84,8 +84,12 @@ class DirectPlugin(ImagerPlugin):
break
image_path = self._full_path(self.workdir, self.parts[0].disk, "direct")
+ self.keep_partimages = options.keep_partimages
+
self._image = PartitionedImage(image_path, self.ptable_format,
- self.parts, self.native_sysroot)
+ self.parts, self.native_sysroot,
+ keep_partimages=self.keep_partimages)
+
def do_create(self):
"""
@@ -287,7 +291,9 @@ class PartitionedImage():
Partitioned image in a file.
"""
- def __init__(self, path, ptable_format, partitions, native_sysroot=None):
+ def __init__(self, path, ptable_format, partitions, native_sysroot=None,
+ keep_partimages=False):
+
self.path = path # Path to the image file
self.numpart = 0 # Number of allocated partitions
self.realpart = 0 # Number of partitions in the partition table
@@ -325,6 +331,8 @@ class PartitionedImage():
else: # msdos partition table
part.uuid = '%08x-%02d' % (self.identifier, part.realnum)
+ self.keep_partimages = keep_partimages
+
def prepare(self, imager):
"""Prepare an image. Call prepare method of all image partitions."""
for part in self.partitions:
@@ -540,13 +548,15 @@ class PartitionedImage():
def cleanup(self):
# remove partition images
- for image in set(self.partimages):
- try:
- os.remove(image)
- except IOError as e:
- logger.warning(
- "Could not delete file. {0}: I/O error ({1}): {2}\n".format(
- image, e.errno, e.strerror))
+ if not self.keep_partimages:
+ # remove partition images
+ for image in set(self.partimages):
+ try:
+ os.remove(image)
+ except IOError as e:
+ logger.warning(
+ "Could not delete file. {0}: I/O error ({1}): {2}\n".format(
+ image, e.errno, e.strerror))
def assemble(self):
logger.debug("Installing partitions")
diff --git a/scripts/wic b/scripts/wic
index 49cad869e2..98f7405702 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -303,6 +303,8 @@ def wic_init_parser_create(subparser):
"bitbake variables")
subparser.add_argument("-D", "--debug", dest="debug", action="store_true",
default=False, help="output debug information")
+ subparser.add_argument("-P", "--keep-partition-images", dest="keep_partimages",
+ action="store_true", default=False)
return
--
2.11.0
More information about the Openembedded-core
mailing list