From: Henning Schild <henning.schild@siemens.com>
To: isar-users@googlegroups.com
Cc: Cedric Hombourger <Cedric_Hombourger@mentor.com>,
Andreas Reichel <andreas.reichel.ext@siemens.com>,
Henning Schild <henning.schild@siemens.com>
Subject: [PATCH v2 08/17] classes: image: introduce size measuring function, for before do_*_image
Date: Fri, 13 Apr 2018 16:18:57 +0200 [thread overview]
Message-ID: <08b425a4b904308ddb06bbcb69583a3ac4f88a8a.1523628814.git.henning.schild@siemens.com> (raw)
In-Reply-To: <cover.1523628814.git.henning.schild@siemens.com>
In-Reply-To: <cover.1523628814.git.henning.schild@siemens.com>
Measure the size and export it to the variable ROOTFS_SIZE just before
the imaging step. The concept is inspired by OE.
Issue:
The size of the rootfs is required for all sort of images, at the moment
Isar only supports one "real" image. Later patches will introduce
another image. And this patch prepares for that by moving the size
measurement into our image base class.
Impact:
- Issue is solved
- nothing changes for users
Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
meta/classes/ext4-img.bbclass | 7 ++-----
meta/classes/image.bbclass | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/meta/classes/ext4-img.bbclass b/meta/classes/ext4-img.bbclass
index 8a978e6..d19d036 100644
--- a/meta/classes/ext4-img.bbclass
+++ b/meta/classes/ext4-img.bbclass
@@ -1,9 +1,6 @@
# This software is a part of ISAR.
# Copyright (C) 2015-2017 ilbers GmbH
-# Extra space for rootfs in MB
-ROOTFS_EXTRA ?= "64"
-
ROOTFS_TYPE = "ext4"
EXT4_IMAGE_FILE = "${DEPLOY_DIR_IMAGE}/${PN}-${DISTRO}-${MACHINE}.ext4.img"
@@ -14,8 +11,7 @@ do_ext4_image[stamp-extra-info] = "${DISTRO}-${MACHINE}"
do_ext4_image() {
rm -f ${EXT4_IMAGE_FILE}
- ROOTFS_SIZE=`sudo du -sm ${IMAGE_ROOTFS} | awk '{print $1 + ${ROOTFS_EXTRA};}'`
- dd if=/dev/zero of=${EXT4_IMAGE_FILE} bs=1M count=${ROOTFS_SIZE}
+ dd if=/dev/zero of=${EXT4_IMAGE_FILE} bs=1k count=${ROOTFS_SIZE}
sudo mkfs.ext4 -F ${EXT4_IMAGE_FILE}
@@ -33,3 +29,4 @@ do_ext4_image() {
}
addtask ext4_image before do_build after do_copy_boot_files
+do_ext4_image[prefuncs] = 'set_image_size'
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index a6537f9..2243860 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -5,6 +5,9 @@ IMAGE_INSTALL ?= ""
IMAGE_TYPE ?= "ext4-img"
IMAGE_ROOTFS = "${WORKDIR}/rootfs"
+# Extra space for rootfs in MB
+ROOTFS_EXTRA ?= "64"
+
def get_image_name(d, name_link):
S = d.getVar("IMAGE_ROOTFS", True)
path_link = os.path.join(S, name_link)
@@ -15,6 +18,22 @@ def get_image_name(d, name_link):
'/'))
return ""
+def get_rootfs_size(d):
+ import subprocess
+ rootfs_extra = int(d.getVar("ROOTFS_EXTRA", True))
+
+ output = subprocess.check_output(['sudo', 'du', '-s', '--block-size=1k',
+ d.getVar("IMAGE_ROOTFS", True)])
+ base_size = int(output.split()[0])
+
+ return base_size + rootfs_extra * 1024
+
+python set_image_size () {
+ rootfs_size = get_rootfs_size(d)
+ d.setVar('ROOTFS_SIZE', str(rootfs_size))
+ d.setVarFlag('ROOTFS_SIZE', 'export', '1')
+}
+
# These variables are used by wic and start_vm
KERNEL_IMAGE ?= "${@get_image_name(d, 'vmlinuz')}"
INITRD_IMAGE ?= "${@get_image_name(d, 'initrd.img')}"
--
2.16.1
next prev parent reply other threads:[~2018-04-13 14:19 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-13 14:18 [PATCH v2 00/16] wic integration Henning Schild
2018-04-13 14:18 ` [PATCH v2 01/17] Revert "wic: Make the bootimg-efi plugin generate usable images" Henning Schild
2018-04-13 14:18 ` [PATCH v2 02/17] Revert "wic: Introduce the `WicExecError` exception class" Henning Schild
2018-04-13 14:18 ` [PATCH v2 03/17] Revert "wic: Work around mcopy error" Henning Schild
2018-04-13 14:18 ` [PATCH v2 04/17] Revert "wic: Use sudo instead of pseudo" Henning Schild
2018-04-16 10:44 ` Andreas Reichel
2018-04-16 10:53 ` Andreas Reichel
2018-04-16 10:57 ` Henning Schild
2018-04-13 14:18 ` [PATCH v2 05/17] Revert "wic: Remove sysroot support" Henning Schild
2018-04-13 14:18 ` [PATCH v2 06/17] wic: now truly go for the wic version we claim to have Henning Schild
2018-04-13 14:18 ` [PATCH v2 07/17] Revert "isar-init-build-env: Add /sbin to PATH" Henning Schild
2018-04-13 14:18 ` Henning Schild [this message]
2018-04-13 14:18 ` [PATCH v2 09/17] meta/image: Fix broken variables KERNEL_IMAGE and INITRD_IMAGE Henning Schild
2018-04-16 10:45 ` Andreas Reichel
2018-04-13 14:18 ` [PATCH v2 10/17] isar-init-build-env: make ISARROOT available in bitbake Henning Schild
2018-04-13 14:19 ` [PATCH v2 11/17] images: New class wic-img for wic intregration Henning Schild
2018-04-13 14:44 ` Henning Schild
2018-04-16 10:17 ` Claudius Heine
2018-04-16 10:25 ` Henning Schild
2018-04-16 10:31 ` Andreas Reichel
2018-04-13 14:19 ` [PATCH v2 12/17] wic: Add pcibios boot plugins and wks files Henning Schild
2018-04-16 10:52 ` Andreas Reichel
2018-04-16 11:48 ` Henning Schild
2018-04-13 14:19 ` [PATCH v2 13/17] scripts/start_vm: Enable booting of full disk images Henning Schild
2018-04-16 10:33 ` Andreas Reichel
2018-04-16 11:46 ` Henning Schild
2018-04-16 13:24 ` Andreas Reichel
2018-04-13 14:19 ` [PATCH v2 14/17] multiconfig: Switch qemuamd64-stretch to using wic by default Henning Schild
2018-04-16 10:25 ` Claudius Heine
2018-04-16 10:32 ` Henning Schild
2018-04-13 14:19 ` [PATCH v2 15/17] multiconfig: Switch qemui386-stretch " Henning Schild
2018-04-16 10:35 ` Andreas Reichel
2018-04-16 10:43 ` Henning Schild
2018-04-16 10:51 ` Henning Schild
2018-04-16 10:56 ` Claudius Heine
2018-04-13 14:19 ` [PATCH v2 16/17] docs: Change according to recent patches Henning Schild
2018-04-13 14:19 ` [PATCH v2 17/17] scripts/vm_smoke_test: double the timeout we wait for qemus Henning Schild
2018-04-16 10:47 ` Andreas Reichel
2018-04-16 11:45 ` Henning Schild
2018-04-25 15:53 ` [PATCH v2 00/16] wic integration Alexander Smirnov
2018-04-26 11:26 ` Henning Schild
2018-05-01 19:23 ` Alexander Smirnov
2018-05-03 16:32 ` Henning Schild
2018-05-03 16:39 ` Alexander Smirnov
2018-05-04 8:16 ` Henning Schild
2018-05-04 8:32 ` Alexander Smirnov
2018-05-04 9:30 ` Henning Schild
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08b425a4b904308ddb06bbcb69583a3ac4f88a8a.1523628814.git.henning.schild@siemens.com \
--to=henning.schild@siemens.com \
--cc=Cedric_Hombourger@mentor.com \
--cc=andreas.reichel.ext@siemens.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox