diff mbox series

[morty] kernel.bbclass: fix KERNEL_IMAGETYPE(S) for Image.gz

Message ID 20170913193820.11923-1-nicolas.dechesne@linaro.org
State New
Headers show
Series [morty] kernel.bbclass: fix KERNEL_IMAGETYPE(S) for Image.gz | expand

Commit Message

Nicolas Dechesne Sept. 13, 2017, 7:38 p.m. UTC
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>

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

(cherry picked from commit cfc0c897656fe67e81a6a5dcd936dff785529f41)
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>

---
 meta/classes/kernel.bbclass | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

-- 
2.11.0

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Comments

Nicolas Dechesne Sept. 27, 2017, 7:20 p.m. UTC | #1
On Wed, Sep 13, 2017 at 12:38 PM, Nicolas Dechesne
<nicolas.dechesne@linaro.org> 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@linaro.org>

> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

> (cherry picked from commit cfc0c897656fe67e81a6a5dcd936dff785529f41)

> Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>

> ---


I noticed that morty was updated very recently, and this patch wasn't
merged. Is there any issue with this patch? We would really need this
fix in morty.


>  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 eefe574a60..f8318b83a1 100644

> --- a/meta/classes/kernel.bbclass

> +++ b/meta/classes/kernel.bbclass

> @@ -28,7 +28,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', True) or ""

> @@ -40,7 +39,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():

> @@ -262,14 +264,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

>

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Armin Kuster Sept. 28, 2017, 2:29 p.m. UTC | #2
Nicolas,


On 09/27/2017 12:20 PM, Nicolas Dechesne wrote:
> On Wed, Sep 13, 2017 at 12:38 PM, Nicolas Dechesne

> <nicolas.dechesne@linaro.org> 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@linaro.org>

>> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

>> (cherry picked from commit cfc0c897656fe67e81a6a5dcd936dff785529f41)

>> Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>

>> ---

> I noticed that morty was updated very recently, and this patch wasn't

> merged. Is there any issue with this patch? We would really need this

> fix in morty.

Its in my akuster/morty-next. I am working in some kernel boot issues.
Once that gets working I will submit a pull request which will include
this change.

- armin
>

>

>>  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 eefe574a60..f8318b83a1 100644

>> --- a/meta/classes/kernel.bbclass

>> +++ b/meta/classes/kernel.bbclass

>> @@ -28,7 +28,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', True) or ""

>> @@ -40,7 +39,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():

>> @@ -262,14 +264,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

>>


-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
diff mbox series

Patch

diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index eefe574a60..f8318b83a1 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -28,7 +28,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', True) or ""
@@ -40,7 +39,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():
@@ -262,14 +264,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() {