[OE-core] KERNEL_IMAGETYPES and Image.gz
Andre McCurdy
armccurdy at gmail.com
Wed May 31 22:56:02 UTC 2017
On Wed, May 31, 2017 at 3:04 PM, Andre McCurdy <armccurdy at gmail.com> wrote:
> On Wed, May 31, 2017 at 3:26 AM, Nicolas Dechesne
> <nicolas.dechesne at linaro.org> wrote:
>> On Tue, May 30, 2017 at 11:56 PM, Andre McCurdy <armccurdy at gmail.com> wrote:
>>> On Tue, May 30, 2017 at 1:26 PM, Nicolas Dechesne <nicolas.dechesne at linaro.org> wrote:
>>>> so, to backtrack a bit, i think it should be safe to only treat
>>>> vmlinux.gz as a 'special' case, and then it is there in
>>>> KERNEL_IMAGETYPE, then we do a "make vmlinux" and we manually compress
>>>> the file, otherwise we just trust that KERNEL_IMAGETYPE is a valid
>>>> type and give it to kernel make command line. that should be enough
>>>> to fix the Image.gz cases on all platforms where it's relevant (like
>>>> arm).
>>>
>>> That sounds reasonable.
>>
>> I've been playing with this today, and that *seems* to work fine. At
>> least I can still build vmlinux, vmlinux.gz and it fixes the build of
>> Image.gz as well..
>>
>> I would appreciate some feedback on this one. I can then send a proper
>> patch. Could that break badly for anyone?
>>
>> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
>> index 7a134d5c29..459b6d66a3 100644
>> --- a/meta/classes/kernel.bbclass
>> +++ b/meta/classes/kernel.bbclass
>> @@ -44,7 +44,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 = re.sub(r'vmlinux\.gz', 'vmlinux', types)
>> d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake)
>>
>> for type in types.split():
>>
>
> Looks good to me. Below is a version which takes the cleanup slightly
> further (it will no doubt get mangled since I'm copying and pasting
> into gmail, but maybe gives some more ideas for the final patch).
>
> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> index 8954b28..264d5b7 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -32,8 +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 ""
> alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
> @@ -44,7 +42,13 @@ python __anonymous () {
> types = (alttype + ' ' + types).strip()
> d.setVar('KERNEL_IMAGETYPES', types)
>
> - typeformake = re.sub(r'\.gz', '', types)
> + # Almost all commonly used kernel images are generated by the kernel build
> + # system directly. However some, such as vmlinux.gz, are created as special
> + # cases by post-processing steps in kernel_do_compile() and
> should therefore
> + # not be included in typeformake.
> +
> + typeformake = types.replace('vmlinux.gz', '').strip()
Unfortunately this doesn't work if "vmlinux" isn't already included in
KERNEL_IMAGETYPES etc, so we either need to search and replace as
before, or add something like:
typeformake = types
if 'vmlinux.gz' in types.split():
typeformake = typeformake.replace('vmlinux.gz', '').strip()
if 'vmlinux' not in typeformake.split():
typeformake = typeformake + ' vmlinux'
which is a little more complex, but has the advantage of not risking
duplicating "vmlinux" in typeformake, and therefore not calling "make
vmlinux" twice in kernel_do_compile(), which I guess we sometimes do
now...
> +
> d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake)
>
> for type in types.split():
> @@ -266,14 +270,11 @@ 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
> + 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() {
More information about the Openembedded-core
mailing list