aboutsummaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/classes
diff options
context:
space:
mode:
authorAnton Gerasimov <anton@advancedtelematic.com>2016-11-30 15:07:18 +0100
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2016-12-02 09:58:08 +0000
commit11fb6fee5045401466763b5fd2985f708333f2ac (patch)
tree8f42705e9cf4535427c7ff28780557a862f3671a /meta-agl-bsp/classes
parentfa6ff083c4b0b35bd750ad5fd6ce4121f03ef559 (diff)
Set rootfs size based on real size of rootfs image
ROOTFS_SIZE is recomputed for each image type based on total size of rootfs directory. If rootfs directory gets smaller between creation of rootfs image and SD image, it fill result in corrupted SD image. It should not happen in theory, but it happens occasionally for a reason I could not identify. Change-Id: I1c888c179fdcec32c3cacbbce7b2d34ec70bbb17 Signed-off-by: Anton Gerasimov <anton@advancedtelematic.com>
Diffstat (limited to 'meta-agl-bsp/classes')
-rw-r--r--meta-agl-bsp/classes/sdcard_image-rpi-gdp.bbclass20
1 files changed, 18 insertions, 2 deletions
diff --git a/meta-agl-bsp/classes/sdcard_image-rpi-gdp.bbclass b/meta-agl-bsp/classes/sdcard_image-rpi-gdp.bbclass
index 2956dd075..b26323950 100644
--- a/meta-agl-bsp/classes/sdcard_image-rpi-gdp.bbclass
+++ b/meta-agl-bsp/classes/sdcard_image-rpi-gdp.bbclass
@@ -2,12 +2,28 @@ inherit sdcard_image-rpi
IMAGE_CMD_rpi-sdimg () {
+ # Get rootfs size
+ if echo "${SDIMG_ROOTFS_TYPE}" | egrep -q "*\.xz"
+ then
+ ROOTPART_SIZE=`xz -l --robot ${SDIMG_ROOTFS} | grep "^file" | cut -f`
+ else
+ ROOTPART_SIZE=`du -Lb ${SDIMG_ROOTFS} | cut -f1`
+ fi
+
+ ROOTPART_SIZE=$(expr ${ROOTPART_SIZE} / 1024)
+
+ # just in case our file system block size is not a multiple of 1KiB
+ if [ $(expr ${ROOTPART_SIZE} % 1024) != 0 ];
+ then
+ ROOTPART_SIZE=$(expr ${ROOTPART_SIZE} + 1)
+ fi
+
# Align partitions
BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1)
BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT})
- SDIMG_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE)
+ SDIMG_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTPART_SIZE)
- echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $ROOTFS_SIZE KiB"
+ echo "Creating filesystem with Boot partition ${BOOT_SPACE_ALIGNED} KiB and RootFS $ROOTPART_SIZE KiB"
# Check if we are building with device tree support
DTS="${@get_dts(d, None)}"