* [PATCH] kernel.bbclass: handles symbolic KERNEL_OUTPUT in bundle_initramfs task
@ 2013-11-12 8:17 Ming Liu
2013-11-12 15:07 ` Bruce Ashfield
0 siblings, 1 reply; 5+ messages in thread
From: Ming Liu @ 2013-11-12 8:17 UTC (permalink / raw)
To: openembedded-core
In many cases, KERNEL_OUTPUT is a symbolic link to the real bootable image,
but in bundle_initramfs task, it's not considered so that the KERNEL_OUTPUT
is being renamed/restored as a regular file, this leads it finally point to
a incorrect target, or even worse, break the bundle_initramfs task for
KERNEL_OUTPUT is not going to be regenerated in case it is a symbolic link
to vmlinux.
Also, we need move bundle_initramfs after kernel_link_vmlinux.
Signed-off-by: Ming Liu <ming.liu@windriver.com>
---
meta/classes/kernel.bbclass | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index a4db9f5..2ec09ae 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -123,13 +123,29 @@ do_bundle_initramfs () {
if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
echo "Creating a kernel image with a bundled initramfs..."
copy_initramfs
- if [ -e ${KERNEL_OUTPUT} ] ; then
+ # Backuping kernel image relies on its type(regular file or symbolic link)
+ linkpath=""
+ realpath=""
+ if [ -h ${KERNEL_OUTPUT} ] ; then
+ linkpath=`readlink -n ${KERNEL_OUTPUT}`
+ realpath=`readlink -fn ${KERNEL_OUTPUT}`
+ mv -f $realpath $realpath.bak
+ elif [ -f ${KERNEL_OUTPUT} ]; then
mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.bak
fi
use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio
kernel_do_compile
- mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs
- mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT}
+ # Restoring kernel image
+ if [ ! -z $realpath ]; then
+ mv -f $realpath $realpath.initramfs
+ mv -f $realpath.bak $realpath
+ cd ${B}/$(dirname ${KERNEL_OUTPUT})
+ ln -sf $linkpath
+ ln -sf $linkpath.initramfs
+ else
+ mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs
+ mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT}
+ fi
# Update install area
echo "There is kernel image bundled with initramfs: ${B}/${KERNEL_OUTPUT}.initramfs"
install -m 0644 ${B}/${KERNEL_OUTPUT}.initramfs ${D}/boot/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin
@@ -152,7 +168,7 @@ python do_devshell_prepend () {
os.environ["LDFLAGS"] = ''
}
-addtask bundle_initramfs after do_compile before do_build
+addtask bundle_initramfs after do_kernel_link_vmlinux before do_build
kernel_do_compile() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
--
1.8.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] kernel.bbclass: handles symbolic KERNEL_OUTPUT in bundle_initramfs task
2013-11-12 8:17 [PATCH] kernel.bbclass: handles symbolic KERNEL_OUTPUT in bundle_initramfs task Ming Liu
@ 2013-11-12 15:07 ` Bruce Ashfield
2013-11-13 2:03 ` Ming Liu
0 siblings, 1 reply; 5+ messages in thread
From: Bruce Ashfield @ 2013-11-12 15:07 UTC (permalink / raw)
To: Ming Liu; +Cc: Patches and discussions about the oe-core layer
On Tue, Nov 12, 2013 at 3:17 AM, Ming Liu <ming.liu@windriver.com> wrote:
> In many cases, KERNEL_OUTPUT is a symbolic link to the real bootable image,
> but in bundle_initramfs task, it's not considered so that the KERNEL_OUTPUT
> is being renamed/restored as a regular file, this leads it finally point to
> a incorrect target, or even worse, break the bundle_initramfs task for
> KERNEL_OUTPUT is not going to be regenerated in case it is a symbolic link
> to vmlinux.
>
> Also, we need move bundle_initramfs after kernel_link_vmlinux.
>
> Signed-off-by: Ming Liu <ming.liu@windriver.com>
> ---
> meta/classes/kernel.bbclass | 24 ++++++++++++++++++++----
> 1 file changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> index a4db9f5..2ec09ae 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -123,13 +123,29 @@ do_bundle_initramfs () {
> if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
> echo "Creating a kernel image with a bundled initramfs..."
> copy_initramfs
> - if [ -e ${KERNEL_OUTPUT} ] ; then
> + # Backuping kernel image relies on its type(regular file or symbolic link)
> + linkpath=""
> + realpath=""
> + if [ -h ${KERNEL_OUTPUT} ] ; then
> + linkpath=`readlink -n ${KERNEL_OUTPUT}`
> + realpath=`readlink -fn ${KERNEL_OUTPUT}`
> + mv -f $realpath $realpath.bak
> + elif [ -f ${KERNEL_OUTPUT} ]; then
> mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.bak
> fi
> use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio
> kernel_do_compile
> - mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs
> - mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT}
> + # Restoring kernel image
> + if [ ! -z $realpath ]; then
Why not if [ -n "$realpath" ] ? I always find that reads easier.
> + mv -f $realpath $realpath.initramfs
> + mv -f $realpath.bak $realpath
> + cd ${B}/$(dirname ${KERNEL_OUTPUT})
> + ln -sf $linkpath
> + ln -sf $linkpath.initramfs
Won't the links just follow .. they are symbolic after all. Since things are
being put back in place. Or are the names changing underneath ?
> + else
> + mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs
> + mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT}
> + fi
> # Update install area
> echo "There is kernel image bundled with initramfs: ${B}/${KERNEL_OUTPUT}.initramfs"
> install -m 0644 ${B}/${KERNEL_OUTPUT}.initramfs ${D}/boot/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin
> @@ -152,7 +168,7 @@ python do_devshell_prepend () {
> os.environ["LDFLAGS"] = ''
> }
>
> -addtask bundle_initramfs after do_compile before do_build
> +addtask bundle_initramfs after do_kernel_link_vmlinux before do_build
This isn't explained in the commit log.
Bruce
>
> kernel_do_compile() {
> unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
> --
> 1.8.4.1
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
--
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kernel.bbclass: handles symbolic KERNEL_OUTPUT in bundle_initramfs task
2013-11-12 15:07 ` Bruce Ashfield
@ 2013-11-13 2:03 ` Ming Liu
2013-11-13 2:18 ` Otavio Salvador
0 siblings, 1 reply; 5+ messages in thread
From: Ming Liu @ 2013-11-13 2:03 UTC (permalink / raw)
To: Bruce Ashfield; +Cc: Patches and discussions about the oe-core layer
On 11/12/2013 11:07 PM, Bruce Ashfield wrote:
> On Tue, Nov 12, 2013 at 3:17 AM, Ming Liu <ming.liu@windriver.com> wrote:
>> In many cases, KERNEL_OUTPUT is a symbolic link to the real bootable image,
>> but in bundle_initramfs task, it's not considered so that the KERNEL_OUTPUT
>> is being renamed/restored as a regular file, this leads it finally point to
>> a incorrect target, or even worse, break the bundle_initramfs task for
>> KERNEL_OUTPUT is not going to be regenerated in case it is a symbolic link
>> to vmlinux.
>>
>> Also, we need move bundle_initramfs after kernel_link_vmlinux.
>>
>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
>> ---
>> meta/classes/kernel.bbclass | 24 ++++++++++++++++++++----
>> 1 file changed, 20 insertions(+), 4 deletions(-)
>>
>> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
>> index a4db9f5..2ec09ae 100644
>> --- a/meta/classes/kernel.bbclass
>> +++ b/meta/classes/kernel.bbclass
>> @@ -123,13 +123,29 @@ do_bundle_initramfs () {
>> if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
>> echo "Creating a kernel image with a bundled initramfs..."
>> copy_initramfs
>> - if [ -e ${KERNEL_OUTPUT} ] ; then
>> + # Backuping kernel image relies on its type(regular file or symbolic link)
>> + linkpath=""
>> + realpath=""
>> + if [ -h ${KERNEL_OUTPUT} ] ; then
>> + linkpath=`readlink -n ${KERNEL_OUTPUT}`
>> + realpath=`readlink -fn ${KERNEL_OUTPUT}`
>> + mv -f $realpath $realpath.bak
>> + elif [ -f ${KERNEL_OUTPUT} ]; then
>> mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.bak
>> fi
>> use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE}-${MACHINE}.cpio
>> kernel_do_compile
>> - mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs
>> - mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT}
>> + # Restoring kernel image
>> + if [ ! -z $realpath ]; then
> Why not if [ -n "$realpath" ] ? I always find that reads easier.
OK, that would be better.
>
>> + mv -f $realpath $realpath.initramfs
>> + mv -f $realpath.bak $realpath
>> + cd ${B}/$(dirname ${KERNEL_OUTPUT})
>> + ln -sf $linkpath
>> + ln -sf $linkpath.initramfs
> Won't the links just follow .. they are symbolic after all. Since things are
> being put back in place. Or are the names changing underneath ?
Indeed, 'ln -sf $linkpath' is unnecessary, I can remove it, but for the
initramfs link, we must create it here for it doesn't exist before this.
>
>> + else
>> + mv -f ${KERNEL_OUTPUT} ${KERNEL_OUTPUT}.initramfs
>> + mv -f ${KERNEL_OUTPUT}.bak ${KERNEL_OUTPUT}
>> + fi
>> # Update install area
>> echo "There is kernel image bundled with initramfs: ${B}/${KERNEL_OUTPUT}.initramfs"
>> install -m 0644 ${B}/${KERNEL_OUTPUT}.initramfs ${D}/boot/${KERNEL_IMAGETYPE}-initramfs-${MACHINE}.bin
>> @@ -152,7 +168,7 @@ python do_devshell_prepend () {
>> os.environ["LDFLAGS"] = ''
>> }
>>
>> -addtask bundle_initramfs after do_compile before do_build
>> +addtask bundle_initramfs after do_kernel_link_vmlinux before do_build
> This isn't explained in the commit log.
So, I will put it into another commit, I will send the V1 soon including
all the changes discussed above.
//Ming Liu
>
> Bruce
>
>> kernel_do_compile() {
>> unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
>> --
>> 1.8.4.1
>>
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kernel.bbclass: handles symbolic KERNEL_OUTPUT in bundle_initramfs task
2013-11-13 2:03 ` Ming Liu
@ 2013-11-13 2:18 ` Otavio Salvador
2013-11-13 2:21 ` Ming Liu
0 siblings, 1 reply; 5+ messages in thread
From: Otavio Salvador @ 2013-11-13 2:18 UTC (permalink / raw)
To: Ming Liu; +Cc: Patches and discussions about the oe-core layer
On Wed, Nov 13, 2013 at 12:03 AM, Ming Liu <ming.liu@windriver.com> wrote:
...
> So, I will put it into another commit, I will send the V1 soon including all
> the changes discussed above.
v2 ;-)
--
Otavio Salvador O.S. Systems
http://www.ossystems.com.br http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] kernel.bbclass: handles symbolic KERNEL_OUTPUT in bundle_initramfs task
2013-11-13 2:18 ` Otavio Salvador
@ 2013-11-13 2:21 ` Ming Liu
0 siblings, 0 replies; 5+ messages in thread
From: Ming Liu @ 2013-11-13 2:21 UTC (permalink / raw)
To: Otavio Salvador; +Cc: Patches and discussions about the oe-core layer
On 11/13/2013 10:18 AM, Otavio Salvador wrote:
> On Wed, Nov 13, 2013 at 12:03 AM, Ming Liu <ming.liu@windriver.com> wrote:
> ...
>> So, I will put it into another commit, I will send the V1 soon including all
>> the changes discussed above.
> v2 ;-)
Got it. Thanks! :)
//Ming Liu
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-11-13 2:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-12 8:17 [PATCH] kernel.bbclass: handles symbolic KERNEL_OUTPUT in bundle_initramfs task Ming Liu
2013-11-12 15:07 ` Bruce Ashfield
2013-11-13 2:03 ` Ming Liu
2013-11-13 2:18 ` Otavio Salvador
2013-11-13 2:21 ` Ming Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox