kernel.bbclass: handles symbolic KERNEL_OUTPUT in bundle_initramfs task
PATCH 1/1 kernel.bbclass: handles symbolic KERNEL_OUTPUT in bundle_initramfs task
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.
--- meta/classes/kernel.bbclass | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
meta/classes/kernel.bbclass +20 -4
@@ -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
Signature · 1 line
1.8.4.1
Quoted 29 lines · Ming Liu
In many cases,
KERNEL_OUTPUTis a symbolic link to the real bootable image, but inbundle_initramfstask, it's not considered so that theKERNEL_OUTPUTis being renamed/restored as a regular file, this leads it finally point to a incorrect target, or even worse, break thebundle_initramfstask forKERNEL_OUTPUTis not going to be regenerated in case it is a symbolic link to vmlinux.Also, we need move
bundle_initramfsafterkernel_link_vmlinux.Signed-off-by Ming Liu <[email protected]>--- meta/classes/kernel.bbclass | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)meta/classes/kernel.bbclass +6
-1@@ -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}`
meta/classes/kernel.bbclass do_bundle_initramfs () { · line 139
Quoted 10 lines
meta/classes/kernel.bbclass +4
-2+ 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.
meta/classes/kernel.bbclass do_bundle_initramfs () { · line 144
Quoted 5 lines
meta/classes/kernel.bbclass +5
-0+ 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 ?
meta/classes/kernel.bbclass python do_devshell_prepend () { · line 171
Quoted 13 lines
meta/classes/kernel.bbclass +5
-1+ 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
Quoted 10 lines
meta/classes/kernel.bbclass +0
-1kernel_do_compile() { unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE --1.8.4.1
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"
Quoted 33 lines · Bruce Ashfield
Quoted 32 lines · Ming Liu
In many cases,
KERNEL_OUTPUTis a symbolic link to the real bootable image, but inbundle_initramfstask, it's not considered so that theKERNEL_OUTPUTis being renamed/restored as a regular file, this leads it finally point to a incorrect target, or even worse, break thebundle_initramfstask forKERNEL_OUTPUTis not going to be regenerated in case it is a symbolic link to vmlinux.Also, we need move
bundle_initramfsafterkernel_link_vmlinux.Signed-off-by Ming Liu <[email protected]>--- meta/classes/kernel.bbclass | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)meta/classes/kernel.bbclass +8
-1@@ -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
Quoted 8 lines
meta/classes/kernel.bbclass do_bundle_initramfs () { · line 139
Quoted 7 lines
meta/classes/kernel.bbclass +2
-2fi 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 ]; thenWhy not if [ -n "$realpath" ] ? I always find that reads easier.
OK, that would be better.
Quoted 8 lines
meta/classes/kernel.bbclass do_bundle_initramfs () { · line 144
Quoted 6 lines
meta/classes/kernel.bbclass +5
-0+ mv -f $realpath $realpath.initramfs + mv -f $realpath.bak $realpath + cd ${B}/$(dirname ${KERNEL_OUTPUT}) + ln -sf $linkpath + ln -sf $linkpath.initramfsWon'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.
Quoted 12 lines
Quoted 12 lines
meta/classes/kernel.bbclass +4
-0+ 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"] = '' }
Quoted 3 lines
meta/classes/kernel.bbclass python do_devshell_prepend () { · line 171
Quoted 2 lines
meta/classes/kernel.bbclass +1
-1-addtask bundle_initramfs after do_compile before do_build +addtask bundle_initramfs after do_kernel_link_vmlinux before do_buildThis 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
Quoted 14 lines
Bruce
Quoted 9 lines
meta/classes/kernel.bbclass +0
-1kernel_do_compile() { unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE --1.8.4.1
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
On Wed, Nov 13, 2013 at 12:03 AM, Ming Liu <[email protected]> wrote:
...
Quoted 2 lines
So, I will put it into another commit, I will send the V1 soon including all the changes discussed above.
v2 ;-)
Signature · 3 lines
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
Quoted 5 lines · Otavio Salvador
On Wed, Nov 13, 2013 at 12:03 AM, Ming Liu <[email protected]> wrote:
...Quoted 2 lines
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