Image files will typically contain lots of null blocks and should compress well.
This will help with distribution of images over slow network links.

Signed-off-by: Paul Barker <p...@paulbarker.me.uk>
---
 classes/sdcard_image-rpi.bbclass | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/classes/sdcard_image-rpi.bbclass b/classes/sdcard_image-rpi.bbclass
index a2fcd52..8d2a5f2 100644
--- a/classes/sdcard_image-rpi.bbclass
+++ b/classes/sdcard_image-rpi.bbclass
@@ -50,6 +50,11 @@ IMAGE_DEPENDS_rpi-sdimg = " \
 # SD card image name
 SDIMG = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.rpi-sdimg"
 
+# Compression method to apply to SDIMG after it has been created. May be 
"none",
+# "gzip", "bzip2" or "xz". Setting this to something other than "none" will
+# cause SDIMG to be renamed.
+SDIMG_COMPRESSION ?= "none"
+
 # Additional files and/or directories to be copied into the vfat partition 
from the IMAGE_ROOTFS.
 FATPAYLOAD ?= ""
 
@@ -107,6 +112,19 @@ IMAGE_CMD_rpi-sdimg () {
        else
                dd if=${SDIMG_ROOTFS} of=${SDIMG} conv=notrunc seek=1 bs=$(expr 
1024 \* ${BOOT_SPACE_ALIGNED} + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) && sync && 
sync
        fi
+
+       # Optionally apply compression
+       case "${SDIMG_COMPRESSION}" in
+       "gzip")
+               gzip -9 "${SDIMG}"
+               ;;
+       "bzip2")
+               bzip2 -9 "${SDIMG}"
+               ;;
+       "xz")
+               xz "${SDIMG}"
+               ;;
+       esac
 }
 
 ROOTFS_POSTPROCESS_COMMAND += " rpi_generate_sysctl_config ; "
-- 
1.8.3.4

_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to