[OE-core] [PATCH 1/1] kernel: Add KERNEL_IMAGETYPES to build multi types kernel at one time

2016-02-17 Thread zhe.he
From: He Zhe 

Add KERNEL_IMAGETYPES to support building packaging and installing
multi types of kernel images, such as zImage uImage, at one time.
KERNEL_IMAGETYPE works as before.

Fixes [YOCTO #6945].

Signed-off-by: He Zhe 
---
 meta/classes/kernel-fitimage.bbclass|  20 ++--
 meta/classes/kernel-grub.bbclass|  44 ++---
 meta/classes/kernel-uimage.bbclass  |  22 +++--
 meta/classes/kernel.bbclass | 169 ++--
 meta/conf/documentation.conf|   1 +
 meta/recipes-kernel/linux/linux-dtb.inc |  49 +
 6 files changed, 202 insertions(+), 103 deletions(-)

diff --git a/meta/classes/kernel-fitimage.bbclass 
b/meta/classes/kernel-fitimage.bbclass
index f1b409c..51df19d 100644
--- a/meta/classes/kernel-fitimage.bbclass
+++ b/meta/classes/kernel-fitimage.bbclass
@@ -1,8 +1,8 @@
 inherit kernel-uboot
 
 python __anonymous () {
-kerneltype = d.getVar('KERNEL_IMAGETYPE', True)
-if kerneltype == 'fitImage':
+kerneltypes = d.getVar('KERNEL_IMAGETYPES', True) or ""
+if 'fitImage' in kerneltypes.split():
 depends = d.getVar("DEPENDS", True)
 depends = "%s u-boot-mkimage-native dtc-native" % depends
 d.setVar("DEPENDS", depends)
@@ -10,7 +10,9 @@ python __anonymous () {
# Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal
# to kernel.bbclass . We have to override it, since we pack zImage
# (at least for now) into the fitImage .
-d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", "zImage")
+typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE", True) or ""
+if 'fitImage' in typeformake.split():
+d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', 
typeformake.replace('fitImage', 'zImage'))
 
 image = d.getVar('INITRAMFS_IMAGE', True)
 if image:
@@ -154,7 +156,7 @@ EOF
 }
 
 do_assemble_fitimage() {
-   if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then
+   if echo ${KERNEL_IMAGETYPES} | grep -Pq "\bfitImage\b"; then
kernelcount=1
dtbcount=""
rm -f fit-image.its
@@ -217,14 +219,14 @@ addtask assemble_fitimage before do_install after 
do_compile
 
 kernel_do_deploy_append() {
# Update deploy directory
-   if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then
+   if echo ${KERNEL_IMAGETYPES} | grep -Pq "\bfitImage\b"; then
cd ${B}
echo "Copying fit-image.its source file..."
-   
its_base_name="${KERNEL_IMAGETYPE}-its-${PV}-${PR}-${MACHINE}-${DATETIME}"
-   its_symlink_name=${KERNEL_IMAGETYPE}-its-${MACHINE}
+   its_base_name="fitImage-its-${PV}-${PR}-${MACHINE}-${DATETIME}"
+   its_symlink_name=fitImage-its-${MACHINE}
install -m 0644 fit-image.its ${DEPLOYDIR}/${its_base_name}.its
-   
linux_bin_base_name="${KERNEL_IMAGETYPE}-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}"
-   linux_bin_symlink_name=${KERNEL_IMAGETYPE}-linux.bin-${MACHINE}
+   
linux_bin_base_name="fitImage-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}"
+   linux_bin_symlink_name=fitImage-linux.bin-${MACHINE}
install -m 0644 linux.bin 
${DEPLOYDIR}/${linux_bin_base_name}.bin
 
cd ${DEPLOYDIR}
diff --git a/meta/classes/kernel-grub.bbclass b/meta/classes/kernel-grub.bbclass
index a63f482..f7dcc07 100644
--- a/meta/classes/kernel-grub.bbclass
+++ b/meta/classes/kernel-grub.bbclass
@@ -10,41 +10,44 @@
 #   updates the new kernel as the boot priority.
 #
 
-pkg_preinst_kernel-image_append () {
+python __anonymous () {
+import re
+
+preinst = '''
# Parsing confliction
[ -f "$D/boot/grub/menu.list" ] && grubcfg="$D/boot/grub/menu.list"
[ -f "$D/boot/grub/grub.cfg" ] && grubcfg="$D/boot/grub/grub.cfg"
if [ -n "$grubcfg" ]; then
# Dereference symlink to avoid confliction with new kernel name.
-   if grep -q "/${KERNEL_IMAGETYPE} \+root=" $grubcfg; then
-   if [ -L "$D/boot/${KERNEL_IMAGETYPE}" ]; then
-   kimage=`realpath $D/boot/${KERNEL_IMAGETYPE} 
2>/dev/null`
+   if grep -q "/KERNEL_IMAGETYPE \+root=" $grubcfg; then
+   if [ -L "$D/boot/KERNEL_IMAGETYPE" ]; then
+   kimage=`realpath $D/boot/KERNEL_IMAGETYPE 
2>/dev/null`
if [ -f "$D$kimage" ]; then
-   sed -i "s:${KERNEL_IMAGETYPE} 
\+root=:${kimage##*/} root=:" $grubcfg
+   sed -i "s:KERNEL_IMAGETYPE 
\+root=:${kimage##*/} root=:" $grubcfg
fi
fi
fi
 
# Rename old kernel if it conflicts with new kernel name.
-   if grep -q "/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} \+root=" 
$grubcfg; then
-   if [ -f "$D/boot/${KE

Re: [OE-core] [PATCH 1/1] kernel: Add KERNEL_IMAGETYPES to build multi types kernel at one time

2016-02-17 Thread Andre McCurdy
On Wed, Feb 17, 2016 at 2:01 AM,   wrote:
> From: He Zhe 
>
> Add KERNEL_IMAGETYPES to support building packaging and installing
> multi types of kernel images, such as zImage uImage, at one time.
> KERNEL_IMAGETYPE works as before.
>
> Fixes [YOCTO #6945].
>
> Signed-off-by: He Zhe 
> ---
>  meta/classes/kernel-fitimage.bbclass|  20 ++--
>  meta/classes/kernel-grub.bbclass|  44 ++---
>  meta/classes/kernel-uimage.bbclass  |  22 +++--
>  meta/classes/kernel.bbclass | 169 
> ++--
>  meta/conf/documentation.conf|   1 +
>  meta/recipes-kernel/linux/linux-dtb.inc |  49 +
>  6 files changed, 202 insertions(+), 103 deletions(-)
>
> diff --git a/meta/classes/kernel-fitimage.bbclass 
> b/meta/classes/kernel-fitimage.bbclass
> index f1b409c..51df19d 100644
> --- a/meta/classes/kernel-fitimage.bbclass
> +++ b/meta/classes/kernel-fitimage.bbclass
> @@ -1,8 +1,8 @@
>  inherit kernel-uboot
>
>  python __anonymous () {
> -kerneltype = d.getVar('KERNEL_IMAGETYPE', True)
> -if kerneltype == 'fitImage':
> +kerneltypes = d.getVar('KERNEL_IMAGETYPES', True) or ""
> +if 'fitImage' in kerneltypes.split():
>  depends = d.getVar("DEPENDS", True)
>  depends = "%s u-boot-mkimage-native dtc-native" % depends
>  d.setVar("DEPENDS", depends)
> @@ -10,7 +10,9 @@ python __anonymous () {
> # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal
> # to kernel.bbclass . We have to override it, since we pack zImage
> # (at least for now) into the fitImage .
> -d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", "zImage")
> +typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE", True) or ""
> +if 'fitImage' in typeformake.split():
> +d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', 
> typeformake.replace('fitImage', 'zImage'))
>
>  image = d.getVar('INITRAMFS_IMAGE', True)
>  if image:
> @@ -154,7 +156,7 @@ EOF
>  }
>
>  do_assemble_fitimage() {
> -   if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then
> +   if echo ${KERNEL_IMAGETYPES} | grep -Pq "\bfitImage\b"; then
> kernelcount=1
> dtbcount=""
> rm -f fit-image.its
> @@ -217,14 +219,14 @@ addtask assemble_fitimage before do_install after 
> do_compile
>
>  kernel_do_deploy_append() {
> # Update deploy directory
> -   if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then
> +   if echo ${KERNEL_IMAGETYPES} | grep -Pq "\bfitImage\b"; then
> cd ${B}
> echo "Copying fit-image.its source file..."
> -   
> its_base_name="${KERNEL_IMAGETYPE}-its-${PV}-${PR}-${MACHINE}-${DATETIME}"
> -   its_symlink_name=${KERNEL_IMAGETYPE}-its-${MACHINE}
> +   
> its_base_name="fitImage-its-${PV}-${PR}-${MACHINE}-${DATETIME}"
> +   its_symlink_name=fitImage-its-${MACHINE}
> install -m 0644 fit-image.its 
> ${DEPLOYDIR}/${its_base_name}.its
> -   
> linux_bin_base_name="${KERNEL_IMAGETYPE}-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}"
> -   
> linux_bin_symlink_name=${KERNEL_IMAGETYPE}-linux.bin-${MACHINE}
> +   
> linux_bin_base_name="fitImage-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}"
> +   linux_bin_symlink_name=fitImage-linux.bin-${MACHINE}
> install -m 0644 linux.bin 
> ${DEPLOYDIR}/${linux_bin_base_name}.bin
>
> cd ${DEPLOYDIR}
> diff --git a/meta/classes/kernel-grub.bbclass 
> b/meta/classes/kernel-grub.bbclass
> index a63f482..f7dcc07 100644
> --- a/meta/classes/kernel-grub.bbclass
> +++ b/meta/classes/kernel-grub.bbclass
> @@ -10,41 +10,44 @@
>  #   updates the new kernel as the boot priority.
>  #
>
> -pkg_preinst_kernel-image_append () {
> +python __anonymous () {
> +import re
> +
> +preinst = '''
> # Parsing confliction
> [ -f "$D/boot/grub/menu.list" ] && grubcfg="$D/boot/grub/menu.list"
> [ -f "$D/boot/grub/grub.cfg" ] && grubcfg="$D/boot/grub/grub.cfg"
> if [ -n "$grubcfg" ]; then
> # Dereference symlink to avoid confliction with new kernel 
> name.
> -   if grep -q "/${KERNEL_IMAGETYPE} \+root=" $grubcfg; then
> -   if [ -L "$D/boot/${KERNEL_IMAGETYPE}" ]; then
> -   kimage=`realpath $D/boot/${KERNEL_IMAGETYPE} 
> 2>/dev/null`
> +   if grep -q "/KERNEL_IMAGETYPE \+root=" $grubcfg; then
> +   if [ -L "$D/boot/KERNEL_IMAGETYPE" ]; then
> +   kimage=`realpath $D/boot/KERNEL_IMAGETYPE 
> 2>/dev/null`
> if [ -f "$D$kimage" ]; then
> -   sed -i "s:${KERNEL_IMAGETYPE} 
> \+root=:${kimage##*/} root=:" $grubcfg
> +   sed -i "s:KERNEL_IMAGETYPE 
> \+root=:${kimage##*/} root=:" $grubcfg
>   

Re: [OE-core] [PATCH 1/1] kernel: Add KERNEL_IMAGETYPES to build multi types kernel at one time

2016-02-18 Thread Andrea Adami
On Thu, Feb 18, 2016 at 4:37 AM, Andre McCurdy  wrote:
> On Wed, Feb 17, 2016 at 2:01 AM,   wrote:
>> From: He Zhe 
>>
>> Add KERNEL_IMAGETYPES to support building packaging and installing
>> multi types of kernel images, such as zImage uImage, at one time.
>> KERNEL_IMAGETYPE works as before.
>>
>> Fixes [YOCTO #6945].
>>
>> Signed-off-by: He Zhe 
>> ---
>>  meta/classes/kernel-fitimage.bbclass|  20 ++--
>>  meta/classes/kernel-grub.bbclass|  44 ++---
>>  meta/classes/kernel-uimage.bbclass  |  22 +++--
>>  meta/classes/kernel.bbclass | 169 
>> ++--
>>  meta/conf/documentation.conf|   1 +
>>  meta/recipes-kernel/linux/linux-dtb.inc |  49 +
>>  6 files changed, 202 insertions(+), 103 deletions(-)
>>
>> diff --git a/meta/classes/kernel-fitimage.bbclass 
>> b/meta/classes/kernel-fitimage.bbclass
>> index f1b409c..51df19d 100644
>> --- a/meta/classes/kernel-fitimage.bbclass
>> +++ b/meta/classes/kernel-fitimage.bbclass
>> @@ -1,8 +1,8 @@
>>  inherit kernel-uboot
>>
>>  python __anonymous () {
>> -kerneltype = d.getVar('KERNEL_IMAGETYPE', True)
>> -if kerneltype == 'fitImage':
>> +kerneltypes = d.getVar('KERNEL_IMAGETYPES', True) or ""
>> +if 'fitImage' in kerneltypes.split():
>>  depends = d.getVar("DEPENDS", True)
>>  depends = "%s u-boot-mkimage-native dtc-native" % depends
>>  d.setVar("DEPENDS", depends)
>> @@ -10,7 +10,9 @@ python __anonymous () {
>> # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal
>> # to kernel.bbclass . We have to override it, since we pack zImage
>> # (at least for now) into the fitImage .
>> -d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", "zImage")
>> +typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE", True) or ""
>> +if 'fitImage' in typeformake.split():
>> +d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', 
>> typeformake.replace('fitImage', 'zImage'))
>>
>>  image = d.getVar('INITRAMFS_IMAGE', True)
>>  if image:
>> @@ -154,7 +156,7 @@ EOF
>>  }
>>
>>  do_assemble_fitimage() {
>> -   if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then
>> +   if echo ${KERNEL_IMAGETYPES} | grep -Pq "\bfitImage\b"; then
>> kernelcount=1
>> dtbcount=""
>> rm -f fit-image.its
>> @@ -217,14 +219,14 @@ addtask assemble_fitimage before do_install after 
>> do_compile
>>
>>  kernel_do_deploy_append() {
>> # Update deploy directory
>> -   if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then
>> +   if echo ${KERNEL_IMAGETYPES} | grep -Pq "\bfitImage\b"; then
>> cd ${B}
>> echo "Copying fit-image.its source file..."
>> -   
>> its_base_name="${KERNEL_IMAGETYPE}-its-${PV}-${PR}-${MACHINE}-${DATETIME}"
>> -   its_symlink_name=${KERNEL_IMAGETYPE}-its-${MACHINE}
>> +   
>> its_base_name="fitImage-its-${PV}-${PR}-${MACHINE}-${DATETIME}"
>> +   its_symlink_name=fitImage-its-${MACHINE}
>> install -m 0644 fit-image.its 
>> ${DEPLOYDIR}/${its_base_name}.its
>> -   
>> linux_bin_base_name="${KERNEL_IMAGETYPE}-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}"
>> -   
>> linux_bin_symlink_name=${KERNEL_IMAGETYPE}-linux.bin-${MACHINE}
>> +   
>> linux_bin_base_name="fitImage-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}"
>> +   linux_bin_symlink_name=fitImage-linux.bin-${MACHINE}
>> install -m 0644 linux.bin 
>> ${DEPLOYDIR}/${linux_bin_base_name}.bin
>>
>> cd ${DEPLOYDIR}
>> diff --git a/meta/classes/kernel-grub.bbclass 
>> b/meta/classes/kernel-grub.bbclass
>> index a63f482..f7dcc07 100644
>> --- a/meta/classes/kernel-grub.bbclass
>> +++ b/meta/classes/kernel-grub.bbclass
>> @@ -10,41 +10,44 @@
>>  #   updates the new kernel as the boot priority.
>>  #
>>
>> -pkg_preinst_kernel-image_append () {
>> +python __anonymous () {
>> +import re
>> +
>> +preinst = '''
>> # Parsing confliction
>> [ -f "$D/boot/grub/menu.list" ] && grubcfg="$D/boot/grub/menu.list"
>> [ -f "$D/boot/grub/grub.cfg" ] && grubcfg="$D/boot/grub/grub.cfg"
>> if [ -n "$grubcfg" ]; then
>> # Dereference symlink to avoid confliction with new kernel 
>> name.
>> -   if grep -q "/${KERNEL_IMAGETYPE} \+root=" $grubcfg; then
>> -   if [ -L "$D/boot/${KERNEL_IMAGETYPE}" ]; then
>> -   kimage=`realpath $D/boot/${KERNEL_IMAGETYPE} 
>> 2>/dev/null`
>> +   if grep -q "/KERNEL_IMAGETYPE \+root=" $grubcfg; then
>> +   if [ -L "$D/boot/KERNEL_IMAGETYPE" ]; then
>> +   kimage=`realpath $D/boot/KERNEL_IMAGETYPE 
>> 2>/dev/null`
>> if [ -f "$D$kimage" ]; then
>> -   sed -i "s:${KERNEL_IMAGETYPE} 
>> \+root

Re: [OE-core] [PATCH 1/1] kernel: Add KERNEL_IMAGETYPES to build multi types kernel at one time

2016-02-18 Thread He Zhe


On 02/18/2016 11:37 AM, Andre McCurdy wrote:
> On Wed, Feb 17, 2016 at 2:01 AM,   wrote:
>> From: He Zhe 
>>
>> Add KERNEL_IMAGETYPES to support building packaging and installing
>> multi types of kernel images, such as zImage uImage, at one time.
>> KERNEL_IMAGETYPE works as before.
>>
>> Fixes [YOCTO #6945].
>>
>> Signed-off-by: He Zhe 
>> ---
>>  meta/classes/kernel-fitimage.bbclass|  20 ++--
>>  meta/classes/kernel-grub.bbclass|  44 ++---
>>  meta/classes/kernel-uimage.bbclass  |  22 +++--
>>  meta/classes/kernel.bbclass | 169 
>> ++--
>>  meta/conf/documentation.conf|   1 +
>>  meta/recipes-kernel/linux/linux-dtb.inc |  49 +
>>  6 files changed, 202 insertions(+), 103 deletions(-)
>>
>> diff --git a/meta/classes/kernel-fitimage.bbclass 
>> b/meta/classes/kernel-fitimage.bbclass
>> index f1b409c..51df19d 100644
>> --- a/meta/classes/kernel-fitimage.bbclass
>> +++ b/meta/classes/kernel-fitimage.bbclass
>> @@ -1,8 +1,8 @@
>>  inherit kernel-uboot
>>
>>  python __anonymous () {
>> -kerneltype = d.getVar('KERNEL_IMAGETYPE', True)
>> -if kerneltype == 'fitImage':
>> +kerneltypes = d.getVar('KERNEL_IMAGETYPES', True) or ""
>> +if 'fitImage' in kerneltypes.split():
>>  depends = d.getVar("DEPENDS", True)
>>  depends = "%s u-boot-mkimage-native dtc-native" % depends
>>  d.setVar("DEPENDS", depends)
>> @@ -10,7 +10,9 @@ python __anonymous () {
>> # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal
>> # to kernel.bbclass . We have to override it, since we pack zImage
>> # (at least for now) into the fitImage .
>> -d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", "zImage")
>> +typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE", True) or ""
>> +if 'fitImage' in typeformake.split():
>> +d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', 
>> typeformake.replace('fitImage', 'zImage'))
>>
>>  image = d.getVar('INITRAMFS_IMAGE', True)
>>  if image:
>> @@ -154,7 +156,7 @@ EOF
>>  }
>>
>>  do_assemble_fitimage() {
>> -   if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then
>> +   if echo ${KERNEL_IMAGETYPES} | grep -Pq "\bfitImage\b"; then
>> kernelcount=1
>> dtbcount=""
>> rm -f fit-image.its
>> @@ -217,14 +219,14 @@ addtask assemble_fitimage before do_install after 
>> do_compile
>>
>>  kernel_do_deploy_append() {
>> # Update deploy directory
>> -   if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then
>> +   if echo ${KERNEL_IMAGETYPES} | grep -Pq "\bfitImage\b"; then
>> cd ${B}
>> echo "Copying fit-image.its source file..."
>> -   
>> its_base_name="${KERNEL_IMAGETYPE}-its-${PV}-${PR}-${MACHINE}-${DATETIME}"
>> -   its_symlink_name=${KERNEL_IMAGETYPE}-its-${MACHINE}
>> +   
>> its_base_name="fitImage-its-${PV}-${PR}-${MACHINE}-${DATETIME}"
>> +   its_symlink_name=fitImage-its-${MACHINE}
>> install -m 0644 fit-image.its 
>> ${DEPLOYDIR}/${its_base_name}.its
>> -   
>> linux_bin_base_name="${KERNEL_IMAGETYPE}-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}"
>> -   
>> linux_bin_symlink_name=${KERNEL_IMAGETYPE}-linux.bin-${MACHINE}
>> +   
>> linux_bin_base_name="fitImage-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}"
>> +   linux_bin_symlink_name=fitImage-linux.bin-${MACHINE}
>> install -m 0644 linux.bin 
>> ${DEPLOYDIR}/${linux_bin_base_name}.bin
>>
>> cd ${DEPLOYDIR}
>> diff --git a/meta/classes/kernel-grub.bbclass 
>> b/meta/classes/kernel-grub.bbclass
>> index a63f482..f7dcc07 100644
>> --- a/meta/classes/kernel-grub.bbclass
>> +++ b/meta/classes/kernel-grub.bbclass
>> @@ -10,41 +10,44 @@
>>  #   updates the new kernel as the boot priority.
>>  #
>>
>> -pkg_preinst_kernel-image_append () {
>> +python __anonymous () {
>> +import re
>> +
>> +preinst = '''
>> # Parsing confliction
>> [ -f "$D/boot/grub/menu.list" ] && grubcfg="$D/boot/grub/menu.list"
>> [ -f "$D/boot/grub/grub.cfg" ] && grubcfg="$D/boot/grub/grub.cfg"
>> if [ -n "$grubcfg" ]; then
>> # Dereference symlink to avoid confliction with new kernel 
>> name.
>> -   if grep -q "/${KERNEL_IMAGETYPE} \+root=" $grubcfg; then
>> -   if [ -L "$D/boot/${KERNEL_IMAGETYPE}" ]; then
>> -   kimage=`realpath $D/boot/${KERNEL_IMAGETYPE} 
>> 2>/dev/null`
>> +   if grep -q "/KERNEL_IMAGETYPE \+root=" $grubcfg; then
>> +   if [ -L "$D/boot/KERNEL_IMAGETYPE" ]; then
>> +   kimage=`realpath $D/boot/KERNEL_IMAGETYPE 
>> 2>/dev/null`
>> if [ -f "$D$kimage" ]; then
>> -   sed -i "s:${KERNEL_IMAGETYPE} 
>> \+root=:${kima

Re: [OE-core] [PATCH 1/1] kernel: Add KERNEL_IMAGETYPES to build multi types kernel at one time

2016-02-18 Thread He Zhe


On 02/18/2016 04:15 PM, Andrea Adami wrote:
> On Thu, Feb 18, 2016 at 4:37 AM, Andre McCurdy  wrote:
>> On Wed, Feb 17, 2016 at 2:01 AM,   wrote:
>>> From: He Zhe 
>>>
>>> Add KERNEL_IMAGETYPES to support building packaging and installing
>>> multi types of kernel images, such as zImage uImage, at one time.
>>> KERNEL_IMAGETYPE works as before.
>>>
>>> Fixes [YOCTO #6945].
>>>
>>> Signed-off-by: He Zhe 
>>> ---
>>>  meta/classes/kernel-fitimage.bbclass|  20 ++--
>>>  meta/classes/kernel-grub.bbclass|  44 ++---
>>>  meta/classes/kernel-uimage.bbclass  |  22 +++--
>>>  meta/classes/kernel.bbclass | 169 
>>> ++--
>>>  meta/conf/documentation.conf|   1 +
>>>  meta/recipes-kernel/linux/linux-dtb.inc |  49 +
>>>  6 files changed, 202 insertions(+), 103 deletions(-)
>>>
>>> diff --git a/meta/classes/kernel-fitimage.bbclass 
>>> b/meta/classes/kernel-fitimage.bbclass
>>> index f1b409c..51df19d 100644
>>> --- a/meta/classes/kernel-fitimage.bbclass
>>> +++ b/meta/classes/kernel-fitimage.bbclass
>>> @@ -1,8 +1,8 @@
>>>  inherit kernel-uboot
>>>
>>>  python __anonymous () {
>>> -kerneltype = d.getVar('KERNEL_IMAGETYPE', True)
>>> -if kerneltype == 'fitImage':
>>> +kerneltypes = d.getVar('KERNEL_IMAGETYPES', True) or ""
>>> +if 'fitImage' in kerneltypes.split():
>>>  depends = d.getVar("DEPENDS", True)
>>>  depends = "%s u-boot-mkimage-native dtc-native" % depends
>>>  d.setVar("DEPENDS", depends)
>>> @@ -10,7 +10,9 @@ python __anonymous () {
>>> # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal
>>> # to kernel.bbclass . We have to override it, since we pack zImage
>>> # (at least for now) into the fitImage .
>>> -d.setVar("KERNEL_IMAGETYPE_FOR_MAKE", "zImage")
>>> +typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE", True) or ""
>>> +if 'fitImage' in typeformake.split():
>>> +d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', 
>>> typeformake.replace('fitImage', 'zImage'))
>>>
>>>  image = d.getVar('INITRAMFS_IMAGE', True)
>>>  if image:
>>> @@ -154,7 +156,7 @@ EOF
>>>  }
>>>
>>>  do_assemble_fitimage() {
>>> -   if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then
>>> +   if echo ${KERNEL_IMAGETYPES} | grep -Pq "\bfitImage\b"; then
>>> kernelcount=1
>>> dtbcount=""
>>> rm -f fit-image.its
>>> @@ -217,14 +219,14 @@ addtask assemble_fitimage before do_install after 
>>> do_compile
>>>
>>>  kernel_do_deploy_append() {
>>> # Update deploy directory
>>> -   if test "x${KERNEL_IMAGETYPE}" = "xfitImage" ; then
>>> +   if echo ${KERNEL_IMAGETYPES} | grep -Pq "\bfitImage\b"; then
>>> cd ${B}
>>> echo "Copying fit-image.its source file..."
>>> -   
>>> its_base_name="${KERNEL_IMAGETYPE}-its-${PV}-${PR}-${MACHINE}-${DATETIME}"
>>> -   its_symlink_name=${KERNEL_IMAGETYPE}-its-${MACHINE}
>>> +   
>>> its_base_name="fitImage-its-${PV}-${PR}-${MACHINE}-${DATETIME}"
>>> +   its_symlink_name=fitImage-its-${MACHINE}
>>> install -m 0644 fit-image.its 
>>> ${DEPLOYDIR}/${its_base_name}.its
>>> -   
>>> linux_bin_base_name="${KERNEL_IMAGETYPE}-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}"
>>> -   
>>> linux_bin_symlink_name=${KERNEL_IMAGETYPE}-linux.bin-${MACHINE}
>>> +   
>>> linux_bin_base_name="fitImage-linux.bin-${PV}-${PR}-${MACHINE}-${DATETIME}"
>>> +   linux_bin_symlink_name=fitImage-linux.bin-${MACHINE}
>>> install -m 0644 linux.bin 
>>> ${DEPLOYDIR}/${linux_bin_base_name}.bin
>>>
>>> cd ${DEPLOYDIR}
>>> diff --git a/meta/classes/kernel-grub.bbclass 
>>> b/meta/classes/kernel-grub.bbclass
>>> index a63f482..f7dcc07 100644
>>> --- a/meta/classes/kernel-grub.bbclass
>>> +++ b/meta/classes/kernel-grub.bbclass
>>> @@ -10,41 +10,44 @@
>>>  #   updates the new kernel as the boot priority.
>>>  #
>>>
>>> -pkg_preinst_kernel-image_append () {
>>> +python __anonymous () {
>>> +import re
>>> +
>>> +preinst = '''
>>> # Parsing confliction
>>> [ -f "$D/boot/grub/menu.list" ] && grubcfg="$D/boot/grub/menu.list"
>>> [ -f "$D/boot/grub/grub.cfg" ] && grubcfg="$D/boot/grub/grub.cfg"
>>> if [ -n "$grubcfg" ]; then
>>> # Dereference symlink to avoid confliction with new kernel 
>>> name.
>>> -   if grep -q "/${KERNEL_IMAGETYPE} \+root=" $grubcfg; then
>>> -   if [ -L "$D/boot/${KERNEL_IMAGETYPE}" ]; then
>>> -   kimage=`realpath 
>>> $D/boot/${KERNEL_IMAGETYPE} 2>/dev/null`
>>> +   if grep -q "/KERNEL_IMAGETYPE \+root=" $grubcfg; then
>>> +   if [ -L "$D/boot/KERNEL_IMAGETYPE" ]; then
>>> +   kimage=`realpath $D/boot/KERNEL_IMAGETYPE 
>>