* [PATCH 0/1] wic update - honor --source --size
@ 2014-02-07 22:19 Tom Zanussi
2014-02-07 22:19 ` [PATCH 1/1] wic: Honor --size for --source partititions Tom Zanussi
0 siblings, 1 reply; 2+ messages in thread
From: Tom Zanussi @ 2014-02-07 22:19 UTC (permalink / raw)
To: openembedded-core; +Cc: Tom Zanussi
This patch allows --size to work for --source partitions i.e. a
partition created from e.g. rootfs/ can now be any size you want, not
just the size of the rootfs.
The following changes since commit 3a590e85808c6fae32f8a40aa003d373d097de9d:
build-appliance-image: Update to poky commit b37dd451a52622d5b570183a81583cc34c2ff555 (2014-02-06 15:36:50 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib.git tzanussi/wic-source-size-update
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=tzanussi/wic-source-size-update
Tom Zanussi (1):
wic: Honor --size for --source partititions
.../lib/mic/kickstart/custom_commands/partition.py | 57 +++++++++++++++++++---
scripts/lib/mic/plugins/source/bootimg-efi.py | 10 +++-
scripts/lib/mic/plugins/source/bootimg-pcbios.py | 10 +++-
scripts/lib/mic/utils/oe/misc.py | 1 +
4 files changed, 68 insertions(+), 10 deletions(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/1] wic: Honor --size for --source partititions
2014-02-07 22:19 [PATCH 0/1] wic update - honor --source --size Tom Zanussi
@ 2014-02-07 22:19 ` Tom Zanussi
0 siblings, 0 replies; 2+ messages in thread
From: Tom Zanussi @ 2014-02-07 22:19 UTC (permalink / raw)
To: openembedded-core; +Cc: Tom Zanussi
Instead of simply creating partitions large enough to contain the
contents of a --source partition (and adding a pre-specified amount of
padding), use the --size used in the partition .wks statement.
If --size isn't used, or is smaller than the actual --source size,
retain the current behavior.
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
.../lib/mic/kickstart/custom_commands/partition.py | 57 +++++++++++++++++++---
scripts/lib/mic/plugins/source/bootimg-efi.py | 10 +++-
scripts/lib/mic/plugins/source/bootimg-pcbios.py | 10 +++-
scripts/lib/mic/utils/oe/misc.py | 1 +
4 files changed, 68 insertions(+), 10 deletions(-)
diff --git a/scripts/lib/mic/kickstart/custom_commands/partition.py b/scripts/lib/mic/kickstart/custom_commands/partition.py
index 4974a87..91d751e 100644
--- a/scripts/lib/mic/kickstart/custom_commands/partition.py
+++ b/scripts/lib/mic/kickstart/custom_commands/partition.py
@@ -56,6 +56,12 @@ class Wic_PartData(Mic_PartData):
return retval
+ def get_size(self):
+ """
+ Accessor for partition size, 0 or --size before set_size().
+ """
+ return self.size
+
def set_size(self, size):
"""
Accessor for actual partition size, which must be set by source
@@ -70,6 +76,29 @@ class Wic_PartData(Mic_PartData):
"""
self.source_file = source_file
+ def get_extra_block_count(self, current_blocks):
+ """
+ The --size param is reflected in self.size (in MB), and we already
+ have current_blocks (1k) blocks, calculate and return the
+ number of (1k) blocks we need to add to get to --size, 0 if
+ we're already there or beyond.
+ """
+ msger.debug("Requested partition size for %s: %d" % \
+ (self.mountpoint, self.size))
+
+ if not self.size:
+ return 0
+
+ requested_blocks = self.size * 1024
+
+ msger.debug("Requested blocks %d, current_blocks %d" % \
+ (requested_blocks, current_blocks))
+
+ if requested_blocks > current_blocks:
+ return requested_blocks - current_blocks
+ else:
+ return 0
+
def prepare(self, cr, cr_workdir, oe_builddir, rootfs_dir, bootimg_dir,
kernel_dir, native_sysroot):
"""
@@ -147,16 +176,22 @@ class Wic_PartData(Mic_PartData):
"""
populate_script = "%s/usr/bin/populate-extfs.sh" % native_sysroot
- image_extra_space = 10240
-
image_rootfs = rootfs_dir
rootfs = "%s/rootfs.%s" % (cr_workdir, self.fstype)
du_cmd = "du -ks %s" % image_rootfs
rc, out = exec_cmd(du_cmd)
- actual_rootfs_size = out.split()[0]
+ actual_rootfs_size = int(out.split()[0])
+
+ extra_blocks = self.get_extra_block_count(actual_rootfs_size)
+
+ if extra_blocks < IMAGE_EXTRA_SPACE:
+ extra_blocks = IMAGE_EXTRA_SPACE
+
+ rootfs_size = actual_rootfs_size + extra_blocks
- rootfs_size = int(actual_rootfs_size) + image_extra_space
+ msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
+ (extra_blocks, self.mountpoint, rootfs_size))
dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \
(rootfs, rootfs_size)
@@ -187,16 +222,22 @@ class Wic_PartData(Mic_PartData):
Currently handles ext2/3/4 and btrfs.
"""
- image_extra_space = 10240
-
image_rootfs = rootfs_dir
rootfs = "%s/rootfs.%s" % (cr_workdir, self.fstype)
du_cmd = "du -ks %s" % image_rootfs
rc, out = exec_cmd(du_cmd)
- actual_rootfs_size = out.split()[0]
+ actual_rootfs_size = int(out.split()[0])
+
+ extra_blocks = self.get_extra_block_count(actual_rootfs_size)
+
+ if extra_blocks < IMAGE_EXTRA_SPACE:
+ extra_blocks = IMAGE_EXTRA_SPACE
+
+ rootfs_size = actual_rootfs_size + extra_blocks
- rootfs_size = int(actual_rootfs_size) + image_extra_space
+ msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
+ (extra_blocks, self.mountpoint, rootfs_size))
dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \
(rootfs, rootfs_size)
diff --git a/scripts/lib/mic/plugins/source/bootimg-efi.py b/scripts/lib/mic/plugins/source/bootimg-efi.py
index 3e0997b..1974b06 100644
--- a/scripts/lib/mic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/mic/plugins/source/bootimg-efi.py
@@ -131,7 +131,15 @@ class BootimgEFIPlugin(SourcePlugin):
rc, out = exec_cmd(du_cmd)
blocks = int(out.split()[0])
- blocks += BOOTDD_EXTRA_SPACE
+ extra_blocks = part.get_extra_block_count(blocks)
+
+ if extra_blocks < BOOTDD_EXTRA_SPACE:
+ extra_blocks = BOOTDD_EXTRA_SPACE
+
+ blocks += extra_blocks
+
+ msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
+ (extra_blocks, part.mountpoint, blocks))
# Ensure total sectors is an integral number of sectors per
# track or mcopy will complain. Sectors are 512 bytes, and we
diff --git a/scripts/lib/mic/plugins/source/bootimg-pcbios.py b/scripts/lib/mic/plugins/source/bootimg-pcbios.py
index 3cd446f..fad150f 100644
--- a/scripts/lib/mic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/mic/plugins/source/bootimg-pcbios.py
@@ -154,7 +154,15 @@ class BootimgPcbiosPlugin(SourcePlugin):
rc, out = exec_cmd(du_cmd)
blocks = int(out.split()[0])
- blocks += BOOTDD_EXTRA_SPACE
+ extra_blocks = part.get_extra_block_count(blocks)
+
+ if extra_blocks < BOOTDD_EXTRA_SPACE:
+ extra_blocks = BOOTDD_EXTRA_SPACE
+
+ blocks += extra_blocks
+
+ msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
+ (extra_blocks, part.mountpoint, blocks))
# Ensure total sectors is an integral number of sectors per
# track or mcopy will complain. Sectors are 512 bytes, and we
diff --git a/scripts/lib/mic/utils/oe/misc.py b/scripts/lib/mic/utils/oe/misc.py
index 77dfe03..6b01955 100644
--- a/scripts/lib/mic/utils/oe/misc.py
+++ b/scripts/lib/mic/utils/oe/misc.py
@@ -108,6 +108,7 @@ def add_wks_var(key, val):
wks_vars[key] = val
BOOTDD_EXTRA_SPACE = 16384
+IMAGE_EXTRA_SPACE = 10240
__bitbake_env_lines = ""
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-07 22:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-07 22:19 [PATCH 0/1] wic update - honor --source --size Tom Zanussi
2014-02-07 22:19 ` [PATCH 1/1] wic: Honor --size for --source partititions Tom Zanussi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.