[yocto] [meta-raspberrypi][PATCH v2 1/2] sdcard_image-rpi.bbclass: Allow optional compression
Paul Barker
paul at paulbarker.me.uk
Mon Sep 2 13:11:49 PDT 2013
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 <paul at paulbarker.me.uk>
---
README | 2 ++
classes/sdcard_image-rpi.bbclass | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/README b/README
index db88066..6f947c7 100644
--- a/README
+++ b/README
@@ -112,6 +112,8 @@ How to use it:
IMAGE_FSTYPES = "tar.bz2 ext3.xz rpi-sdimg.xz
2. Overwrite SDIMG_ROOTFS_TYPE in local.conf
SDIMG_ROOTFS_TYPE = "ext3.xz"
+3. Overwrite SDIMG_COMPRESSION in local.conf
+ SDIMG_COMPRESSION = "xz"
*Accommodate the values above to your own needs (ex: ext3 / ext4).
2.B. Optional - GPU memory:
diff --git a/classes/sdcard_image-rpi.bbclass b/classes/sdcard_image-rpi.bbclass
index a2fcd52..3ee4e94 100644
--- a/classes/sdcard_image-rpi.bbclass
+++ b/classes/sdcard_image-rpi.bbclass
@@ -50,6 +50,13 @@ 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. Supported
+# compression formats are "gzip", "bzip2" or "xz". The original .rpi-sdimg file
+# is kept and a new compressed file is created if one of these compression
+# formats is chosen. If SDIMG_COMPRESSION is set to any other value it is
+# silently ignored.
+#SDIMG_COMPRESSION ?= ""
+
# Additional files and/or directories to be copied into the vfat partition from the IMAGE_ROOTFS.
FATPAYLOAD ?= ""
@@ -107,6 +114,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 -k9 "${SDIMG}"
+ ;;
+ "bzip2")
+ bzip2 -k9 "${SDIMG}"
+ ;;
+ "xz")
+ xz -k "${SDIMG}"
+ ;;
+ esac
}
ROOTFS_POSTPROCESS_COMMAND += " rpi_generate_sysctl_config ; "
--
1.8.4
More information about the yocto
mailing list