Patchwork [1/3] lib/oe/image.py: check the rootfs size against IMAGE_ROOTFS_MAXSIZE

login
register
mail settings
Submitter Robert Yang
Date July 7, 2014, 9:33 a.m.
Message ID <97d978ed0f49da7c881046486badffdf6a44f139.1404725000.git.liezhi.yang@windriver.com>
Download mbox | patch
Permalink /patch/75071/
State Accepted
Commit 1cb9f7b00b5ede62a9546c39d798c876775b08c0
Headers show

Comments

Robert Yang - July 7, 2014, 9:33 a.m.
* Check the rootfs size against IMAGE_ROOTFS_MAXSIZE (if set)
* Add comments for IMAGE_ROOTFS_SIZE to not confuse with IMAGE_ROOTFS_MAXSIZE

[YOCTO #2610]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta/conf/bitbake.conf |    4 ++++
 meta/lib/oe/image.py   |    8 ++++++++
 2 files changed, 12 insertions(+)

Patch

diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 311e9a0..f4870d5 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -688,6 +688,10 @@  IMAGE_FSTYPES ?= "tar.gz"
 INITRAMFS_FSTYPES ?= "cpio.gz"
 DEFAULT_TASK_PROVIDER ?= "packagegroup-base"
 MACHINE_TASK_PROVIDER ?= "${DEFAULT_TASK_PROVIDER}"
+
+# The size in Kbytes for the generated image if it is larger than
+# the required size (du -ks IMAGE_ROOTFS * IMAGE_OVERHEAD_FACTOR),
+# and no effect if less than it.
 IMAGE_ROOTFS_SIZE ?= "65536"
 
 # Forcefully set CACHE now so future changes to things like 
diff --git a/meta/lib/oe/image.py b/meta/lib/oe/image.py
index c9b9033..354a676 100644
--- a/meta/lib/oe/image.py
+++ b/meta/lib/oe/image.py
@@ -144,6 +144,7 @@  class Image(ImageDepGraph):
         overhead_factor = float(self.d.getVar('IMAGE_OVERHEAD_FACTOR', True))
         rootfs_req_size = int(self.d.getVar('IMAGE_ROOTFS_SIZE', True))
         rootfs_extra_space = eval(self.d.getVar('IMAGE_ROOTFS_EXTRA_SPACE', True))
+        rootfs_maxsize = self.d.getVar('IMAGE_ROOTFS_MAXSIZE', True)
 
         output = subprocess.check_output(['du', '-ks',
                                           self.d.getVar('IMAGE_ROOTFS', True)])
@@ -158,6 +159,13 @@  class Image(ImageDepGraph):
         base_size += rootfs_alignment - 1
         base_size -= base_size % rootfs_alignment
 
+        # Check the rootfs size against IMAGE_ROOTFS_MAXSIZE (if set)
+        if rootfs_maxsize:
+            rootfs_maxsize_int = int(rootfs_maxsize)
+            if base_size > rootfs_maxsize_int:
+                bb.fatal("The rootfs size %d(K) overrides the max size %d(K)" % \
+                    (base_size, rootfs_maxsize_int))
+
         return base_size
 
     def _create_symlinks(self, subimages):