Patchwork [2/4] cpio-image: added lzma support

login
register
mail settings
Submitter christian.braunersorensen@prevas.dk
Date Feb. 27, 2013, 8:43 a.m.
Message ID <661ceb69fa3e2b050d7afc2917298b13294eafd2.1361954556.git.christian.braunersorensen@prevas.dk>
Download mbox | patch
Permalink /patch/223554/
State Superseded
Delegated to: Esben Haabendal
Headers show

Comments

christian.braunersorensen@prevas.dk - Feb. 27, 2013, 8:43 a.m.
From: Christian Sørensen <christian.braunersorensen@prevas.dk>

---
 classes/cpio-image.oeclass | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)
Esben Haabendal - Feb. 27, 2013, 3:18 p.m.
<christian.braunersorensen@prevas.dk> writes:

> From: Christian Sørensen <christian.braunersorensen@prevas.dk>
>
> ---
>  classes/cpio-image.oeclass | 34 +++++++++++++++++++++++++---------
>  1 file changed, 25 insertions(+), 9 deletions(-)

Hi Christian

Could you please resubmit with a commit message describing how to use
the two new USE flags?


>
> diff --git a/classes/cpio-image.oeclass b/classes/cpio-image.oeclass
> index 0b28940..13356dd 100644
> --- a/classes/cpio-image.oeclass
> +++ b/classes/cpio-image.oeclass
> @@ -3,17 +3,24 @@ IMAGE_BASENAME ?= "${PN}-${TARGET_MACHINE_ID}"
>  inherit image image_mdev image_inetd image_crontab image_makedevs image_inittab image_fstab
>  
>  RECIPE_FLAGS += "ramdisk_image \
> -    ramdisk_image_name ramdisk_image_compression"
> +    ramdisk_image_name ramdisk_image_compression \
> +    cpio_compress_image cpio_image_compression"
> +
>  DEFAULT_USE_ramdisk_image = "0"
>  DEFAULT_USE_ramdisk_image_name = "${IMAGE_BASENAME}"
>  DEFAULT_USE_ramdisk_image_compression = "none"
>  
> +DEFAULT_USE_cpio_compress_image = "00"
> +DEFAULT_USE_cpio_image_compression = "none"

Why do we need two USE flags?  Shouldn't it be enough to specify the
compression method to use (or flag off for no compression?)

> +
>  IMAGE_CREATE_FUNCS += "cpio_image"
>  
>  inherit kernel-arch
>  IMAGE_CREATE_FUNCS:>USE_ramdisk_image = " cpio_mkimage"
>  CLASS_DEPENDS:>USE_ramdisk_image = " native:u-boot-tools-mkimage"
>  
> +IMAGE_CREATE_FUNCS:>USE_cpio_compress_image = " cpio_compress_image"
> +
>  cpio_image () {
>  	(
>          cd ${IMAGE_DIR}
> @@ -22,23 +29,31 @@ cpio_image () {
>  	)
>  }
>  
> -cpio_mkimage () {
> -	(
> -	case "${USE_ramdisk_image_compression}" in
> +cpio_compress() {
> +	case "$1" in
>  		none) cp ${B}/${IMAGE_BASENAME}.cpio ${B}/image.bin
>  			;;
> -		bzip2) echo "TODO: ${USE_ramdisk_image_compression}"
> +		bzip2) echo "TODO: $1"
>  			;;
>  		gzip) gzip ${B}/${IMAGE_BASENAME}.cpio -c > ${B}/image.bin
>  			;;
> -		lzma) echo "TODO: ${USE_ramdisk_image_compression}"
> +		lzma) lzma ${B}/${IMAGE_BASENAME}.cpio -c  > ${B}/image.bin
>  			;;
> -		lzo) echo "TODO: ${USE_ramdisk_image_compression}"
> +		lzo) echo "TODO: $1"
>  			;;
> -		*) echo "ERROR: mkimage compression ${USE_ramdisk_image_compression} not supported"
> +		*) echo "ERROR: mkimage compression $1 not supported"
>  			;;
>  	esac
> +}
> +
> +cpio_compress_image(){
> +       cpio_compress ${USE_cpio_image_compression}
> +       cp ${B}/image.bin ${B}/${IMAGE_BASENAME}.${USE_cpio_image_compression}

Will we end up with files ending with .none?

> +}
>  
> +cpio_mkimage () {
> +	(
> +        cpio_compress ${USE_ramdisk_image_compression}
>  	mkimage -A ${UBOOT_ARCH} -O linux -T ramdisk \
>  		-C none \
>  		-a 0x0 -e 0x0 \
> @@ -49,6 +64,7 @@ cpio_mkimage () {
>  
>  EXT = ".cpio"
>  EXT:>USE_ramdisk_image = " .img"
> +EXT:>USE_cpio_compress_image = " .${USE_cpio_image_compression}"
>  
>  do_install[postfuncs] += "do_install_cpio_image"
>  do_install_cpio_image () {
> @@ -57,7 +73,7 @@ do_install_cpio_image () {
>  	done
>  }
>  
> -FILES_${PN} += "/*.cpio /*.img"
> +FILES_${PN} += "/*.cpio /*.img /*.${USE_cpio_image_compression}"
>  
>  do_deploy[postfuncs] += "do_deploy_cpio_image"
>  do_deploy_cpio_image () {

Patch

diff --git a/classes/cpio-image.oeclass b/classes/cpio-image.oeclass
index 0b28940..13356dd 100644
--- a/classes/cpio-image.oeclass
+++ b/classes/cpio-image.oeclass
@@ -3,17 +3,24 @@  IMAGE_BASENAME ?= "${PN}-${TARGET_MACHINE_ID}"
 inherit image image_mdev image_inetd image_crontab image_makedevs image_inittab image_fstab
 
 RECIPE_FLAGS += "ramdisk_image \
-    ramdisk_image_name ramdisk_image_compression"
+    ramdisk_image_name ramdisk_image_compression \
+    cpio_compress_image cpio_image_compression"
+
 DEFAULT_USE_ramdisk_image = "0"
 DEFAULT_USE_ramdisk_image_name = "${IMAGE_BASENAME}"
 DEFAULT_USE_ramdisk_image_compression = "none"
 
+DEFAULT_USE_cpio_compress_image = "00"
+DEFAULT_USE_cpio_image_compression = "none"
+
 IMAGE_CREATE_FUNCS += "cpio_image"
 
 inherit kernel-arch
 IMAGE_CREATE_FUNCS:>USE_ramdisk_image = " cpio_mkimage"
 CLASS_DEPENDS:>USE_ramdisk_image = " native:u-boot-tools-mkimage"
 
+IMAGE_CREATE_FUNCS:>USE_cpio_compress_image = " cpio_compress_image"
+
 cpio_image () {
 	(
         cd ${IMAGE_DIR}
@@ -22,23 +29,31 @@  cpio_image () {
 	)
 }
 
-cpio_mkimage () {
-	(
-	case "${USE_ramdisk_image_compression}" in
+cpio_compress() {
+	case "$1" in
 		none) cp ${B}/${IMAGE_BASENAME}.cpio ${B}/image.bin
 			;;
-		bzip2) echo "TODO: ${USE_ramdisk_image_compression}"
+		bzip2) echo "TODO: $1"
 			;;
 		gzip) gzip ${B}/${IMAGE_BASENAME}.cpio -c > ${B}/image.bin
 			;;
-		lzma) echo "TODO: ${USE_ramdisk_image_compression}"
+		lzma) lzma ${B}/${IMAGE_BASENAME}.cpio -c  > ${B}/image.bin
 			;;
-		lzo) echo "TODO: ${USE_ramdisk_image_compression}"
+		lzo) echo "TODO: $1"
 			;;
-		*) echo "ERROR: mkimage compression ${USE_ramdisk_image_compression} not supported"
+		*) echo "ERROR: mkimage compression $1 not supported"
 			;;
 	esac
+}
+
+cpio_compress_image(){
+       cpio_compress ${USE_cpio_image_compression}
+       cp ${B}/image.bin ${B}/${IMAGE_BASENAME}.${USE_cpio_image_compression}
+}
 
+cpio_mkimage () {
+	(
+        cpio_compress ${USE_ramdisk_image_compression}
 	mkimage -A ${UBOOT_ARCH} -O linux -T ramdisk \
 		-C none \
 		-a 0x0 -e 0x0 \
@@ -49,6 +64,7 @@  cpio_mkimage () {
 
 EXT = ".cpio"
 EXT:>USE_ramdisk_image = " .img"
+EXT:>USE_cpio_compress_image = " .${USE_cpio_image_compression}"
 
 do_install[postfuncs] += "do_install_cpio_image"
 do_install_cpio_image () {
@@ -57,7 +73,7 @@  do_install_cpio_image () {
 	done
 }
 
-FILES_${PN} += "/*.cpio /*.img"
+FILES_${PN} += "/*.cpio /*.img /*.${USE_cpio_image_compression}"
 
 do_deploy[postfuncs] += "do_deploy_cpio_image"
 do_deploy_cpio_image () {