All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] kernel.bbclass: fix KERNEL_IMAGETYPE(S) for Image.gz
@ 2017-06-02  7:05 Nicolas Dechesne
  2017-06-04 17:07 ` Kunihiko Hayashi
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Dechesne @ 2017-06-02  7:05 UTC (permalink / raw)
  To: openembedded-core; +Cc: Nicolas Dechesne

KERNEL_IMAGETYPES lists all the kernel images that we want to build. in
cb17b6c2a7 (kernel.bbclass: support kernel image type of vmlinux.gz), some logic
was added to support vmlinux.gz which is not a target built by kernel
makefiles (only vmlinux). It is clear that the goal of this logic is only to
support vmlinux.gz and not others compressed format (such as Image.gz) which are
valid target for kernel makefiles.

For Image.gz we should rely on the kernel makefiles and not do the compression
in kernel class.

This patch updates the logic used to filter out non supported kernel target from
KERNEL_IMAGETYPES, and make vmlinux.gz a 'special case', instead of *.gz. If
more special cases are needed in the future, we could add them in a similar way.

This patch should be a no-op for anyone using vmlinux or vmlinux.gz, and on top
of that it is fixing the build for Image.gz which was not working until now.

Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
---
 meta/classes/kernel.bbclass | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 7a134d5c29..7670c7107a 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -32,7 +32,6 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION')
 KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
 
 python __anonymous () {
-    import re
 
     # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
     type = d.getVar('KERNEL_IMAGETYPE') or ""
@@ -44,7 +43,10 @@ python __anonymous () {
         types = (alttype + ' ' + types).strip()
     d.setVar('KERNEL_IMAGETYPES', types)
 
-    typeformake = re.sub(r'\.gz', '', types)
+    # some commonly used kernel images aren't generated by the kernel build system, such as vmlinux.gz
+    # typeformake lists only valid kernel make targets, and post processing can be done after the kernel
+    # is built (such as using gzip to compress vmlinux)
+    typeformake = types.replace('vmlinux.gz', 'vmlinux')
     d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake)
 
     for type in types.split():
@@ -268,14 +270,12 @@ kernel_do_compile() {
 	fi
 	for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
 		oe_runmake ${typeformake} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
-		for type in ${KERNEL_IMAGETYPES} ; do
-			if test "${typeformake}.gz" = "${type}"; then
-				mkdir -p "${KERNEL_OUTPUT_DIR}"
-				gzip -9c < "${typeformake}" > "${KERNEL_OUTPUT_DIR}/${type}"
-				break;
-			fi
-		done
 	done
+	# vmlinux.gz is not built by kernel
+	if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then
+		mkdir -p "${KERNEL_OUTPUT_DIR}"
+		gzip -9c < ${B}/vmlinux > "${KERNEL_OUTPUT_DIR}/vmlinux.gz"
+	fi
 }
 
 do_compile_kernelmodules() {
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] kernel.bbclass: fix KERNEL_IMAGETYPE(S) for Image.gz
  2017-06-02  7:05 [PATCH v3] kernel.bbclass: fix KERNEL_IMAGETYPE(S) for Image.gz Nicolas Dechesne
@ 2017-06-04 17:07 ` Kunihiko Hayashi
  0 siblings, 0 replies; 2+ messages in thread
From: Kunihiko Hayashi @ 2017-06-04 17:07 UTC (permalink / raw)
  To: Nicolas Dechesne; +Cc: openembedded-core

On 2017/06/02 16:05, nicolas.dechesne@linaro.org (Nicolas Dechesne) wrote:
> KERNEL_IMAGETYPES lists all the kernel images that we want to build. in
> cb17b6c2a7 (kernel.bbclass: support kernel image type of vmlinux.gz), some logic
> was added to support vmlinux.gz which is not a target built by kernel
> makefiles (only vmlinux). It is clear that the goal of this logic is only to
> support vmlinux.gz and not others compressed format (such as Image.gz) which are
> valid target for kernel makefiles.
>
> For Image.gz we should rely on the kernel makefiles and not do the compression
> in kernel class.
>
> This patch updates the logic used to filter out non supported kernel target from
> KERNEL_IMAGETYPES, and make vmlinux.gz a 'special case', instead of *.gz. If
> more special cases are needed in the future, we could add them in a similar way.
>
> This patch should be a no-op for anyone using vmlinux or vmlinux.gz, and on top
> of that it is fixing the build for Image.gz which was not working until now.
>
> Signed-off-by: Nicolas Dechesne <nicolas.dechesne at linaro.org>
> ---
>  meta/classes/kernel.bbclass | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> index 7a134d5c29..7670c7107a 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -32,7 +32,6 @@ KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION')
>  KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
>
>  python __anonymous () {
> -    import re
>
>      # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
>      type = d.getVar('KERNEL_IMAGETYPE') or ""
> @@ -44,7 +43,10 @@ python __anonymous () {
>          types = (alttype + ' ' + types).strip()
>      d.setVar('KERNEL_IMAGETYPES', types)
>
> -    typeformake = re.sub(r'\.gz', '', types)
> +    # some commonly used kernel images aren't generated by the kernel build system, such as vmlinux.gz
> +    # typeformake lists only valid kernel make targets, and post processing can be done after the kernel
> +    # is built (such as using gzip to compress vmlinux)
> +    typeformake = types.replace('vmlinux.gz', 'vmlinux')
>      d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake)
>
>      for type in types.split():
> @@ -268,14 +270,12 @@ kernel_do_compile() {
>  	fi
>  	for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
>  		oe_runmake ${typeformake} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
> -		for type in ${KERNEL_IMAGETYPES} ; do
> -			if test "${typeformake}.gz" = "${type}"; then
> -				mkdir -p "${KERNEL_OUTPUT_DIR}"
> -				gzip -9c < "${typeformake}" > "${KERNEL_OUTPUT_DIR}/${type}"
> -				break;
> -			fi
> -		done
>  	done
> +	# vmlinux.gz is not built by kernel
> +	if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then
> +		mkdir -p "${KERNEL_OUTPUT_DIR}"
> +		gzip -9c < ${B}/vmlinux > "${KERNEL_OUTPUT_DIR}/vmlinux.gz"
> +	fi
>  }
>
>  do_compile_kernelmodules() {
>

This patch treats 'vmlinux.gz' only as special case, then it looks no problem.  
Although it might become redundant to add another image type such as  
'vmlinux.gz', it's out of scope.

I tried this patch in case of arm, arm64 and x86. I specified the name of  
compress image for each architecture to KERNEL_IMAGETYPES and I got same images  
as that compressed by the kernel build system, in particular got Image.gz for  
arm64 without any errors.

And I added 'vmlinux.gz' to KERNEL_IMAGETYPES and got compressed vmlinux  
correctly. I think the patch works fine.

Tested-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>

Best Regards,
Kunihiko Hayashi


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-04 17:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02  7:05 [PATCH v3] kernel.bbclass: fix KERNEL_IMAGETYPE(S) for Image.gz Nicolas Dechesne
2017-06-04 17:07 ` Kunihiko Hayashi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.