Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Mike Looijmans <mike.looijmans@topic.nl>
To: <openembedded-core@lists.openembedded.org>
Cc: cxu@windriver.com
Subject: Re: [PATCH 1/1] kernel.bbclass: Need a method to install/update for bzImage
Date: Thu, 12 Sep 2013 11:47:23 +0200	[thread overview]
Message-ID: <52318DAB.9090108@topic.nl> (raw)
In-Reply-To: <732e1a82d56c4355c0bae26ed5aec0151b5adb1a.1378977276.git.hongxu.jia@windriver.com>

This change just assumes that all boot systems are alike. Just applying 
this patch "as is" will probably break a lot of embedded systems that 
have totally different ways of upgrading the kernel. Best scenario is 
that they'll waste time and space running scripts that will have no effect.

It should be possible - and more important: default - to NOT include 
these scripts, and use them only on targets they apply to. 
kernel.bbclass is in my opinion not the correct location.

Otherwise, should I add my kernel postinstall script that writes the 
kernel into an MTD block on an embedded target to this class as well? 
And a NAND version? And SD?

Mike.


On 09/12/2013 11:25 AM, Hongxu Jia wrote:
> While installing a rpm to update kernel on a deployed target, it will update
> the boot area and the boot menu with the kernel as the priority but allow
> you to fall back to the original kernel as well.
>
> - In pre-install script, it backs up original kernel to avoid confliction with
>    new one.
> - In post-install script, it updates the new kernel as the boot priority.
>
> [YOCTO #4104]
>
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
>   meta/classes/kernel.bbclass | 65 +++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 65 insertions(+)
>
> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> index e039dfc..f0dd679 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -263,7 +263,72 @@ ALLOW_EMPTY_kernel-image = "1"
>   ALLOW_EMPTY_kernel-modules = "1"
>   DESCRIPTION_kernel-modules = "Kernel modules meta package"
>
> +pkg_preinst_kernel-image () {
> +	if [ -z "$D" ]; then
> +		# Parsing confliction
> +		[ -f /boot/grub/menu.list ] && grubcfg="/boot/grub/menu.list"
> +		[ -f /boot/grub/grub.cfg ] && grubcfg="/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
> +				kimage=`realpath /boot/${KERNEL_IMAGETYPE}`;
> +				sed -i "s#${KERNEL_IMAGETYPE} root=#${kimage##*/} root=#" $grubcfg
> +			fi
> +
> +			# Rename old kernel if it conflicts with new kernel name.
> +			if grep -q "/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} root=" $grubcfg; then
> +				timestamp=`date +%s`
> +				kimage="/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}-$timestamp-back"
> +				sed -i "s#${KERNEL_IMAGETYPE}-${KERNEL_VERSION} root=#${kimage##*/} root=#" $grubcfg
> +				mv /boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} $kimage
> +			fi
> +		fi
> +	fi
> +}
> +
>   pkg_postinst_kernel-image () {
> +	get_new_grub_cfg() {
> +		title="Update ${KERNEL_IMAGETYPE}-${KERNEL_VERSION}-${PV}"
> +		if [ -f /boot/grub/grub.cfg ]; then
> +			rootfs=`grep " *linux [^ ].* root=" /boot/grub/grub.cfg -m 1 | \
> +				 sed "s# *linux [^ ].* root=#    linux /${KERNEL_IMAGETYPE}-${KERNEL_VERSION} root=#"`
> +
> +			echo "menuentry \"$title\" {"
> +			echo "    set root=(hd0,1)"
> +			echo "$rootfs"
> +			echo "}"
> +		elif [ -f /boot/grub/menu.list ] ; then
> +			rootfs=`grep "kernel [^ ].* root=" /boot/grub/menu.list -m 1 | \
> +				 sed "s#kernel [^ ].* root=#kernel /${KERNEL_IMAGETYPE}-${KERNEL_VERSION} root=#"`
> +
> +			echo "default 0"
> +			echo "timeout 30"
> +			echo "title $title"
> +			echo "root  (hd0,0)"
> +			echo "$rootfs"
> +		fi
> +	}
> +
> +	get_old_grub_cfg() {
> +		if [ -f /boot/grub/grub.cfg ]; then
> +			cat /boot/grub/grub.cfg
> +		elif [ -f /boot/grub/menu.list ] ; then
> +			cat /boot/grub/menu.list | sed -e '/^default/d' -e '/^timeout/d'
> +		fi
> +	}
> +
> +	if [ -z "$D" ]; then
> +		[ -f /boot/grub/menu.list ] && grubcfg="/boot/grub/menu.list"
> +		[ -f /boot/grub/grub.cfg ] && grubcfg="/boot/grub/grub.cfg"
> +		if [ -n "$grubcfg" ]; then
> +			grubcfgtmp="$grubcfg.tmp"
> +			get_new_grub_cfg  > $grubcfgtmp
> +			get_old_grub_cfg >> $grubcfgtmp
> +			mv $grubcfgtmp $grubcfg
> +			echo "Caution! Update kernel may affect kernel-module!"
> +		fi
> +	fi
> +
>   	update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
>   	if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>   		mkdir -p $D/lib/modules/${KERNEL_VERSION}
>



Met vriendelijke groet / kind regards,

Mike Looijmans

TOPIC Embedded Systems
Eindhovenseweg 32-C, NL-5683 KH Best
Postbus 440, NL-5680 AK Best
Telefoon: (+31) – (0)499 - 33.69.79
Telefax: (+31) - (0)499 - 33.69.70
E-mail: mike.looijmans@topic.nl
Website: www.topic.nl

Dit e-mail bericht en de eventueel daarbij behorende bijlagen zijn uitsluitend bestemd voor de geadresseerde, zoals die blijkt uit het e-mail bericht en/of de bijlagen. Er kunnen gegevens met betrekking tot een derde instaan. Indien u als niet-geadresseerde dit bericht en de bijlagen ontvangt, terwijl u niet bevoegd of gemachtigd bent om dit bericht namens de geadresseerde te ontvangen, wordt u verzocht de afzender hierover direct te informeren en het e-mail bericht met de bijlagen te vernietigen. Ieder gebruik van de inhoud van het e-mail bericht, waaronder de daarbij behorende bijlagen, door een ander dan de geadresseerde is onrechtmatig jegens ons dan wel de eventueel in het e-mail bericht of de bijlagen voorkomende andere personen. TOPIC Embedded Systems is niet aansprakelijk voor enigerlei schade voortvloeiend uit het gebruik en/of acceptatie van dit e-mail bericht of de daarbij behorende bijlagen.

The contents of this message, as well as any enclosures, are addressed personally to, and thus solely intended for the addressee. They may contain information regarding a third party. A recipient who is neither the addressee, nor empowered to receive this message on behalf of the addressee, is kindly requested to immediately inform the sender of receipt, and to destroy the message and the enclosures. Any use of the contents of this message and/or the enclosures by any other person than the addressee or person who is empowered to receive this message, is illegal towards the sender and/or the aforementioned third party. TOPIC Embedded Systems is not  liable for any damage as a result of the use and/or acceptance of this message and as well as any enclosures.


  reply	other threads:[~2013-09-12  9:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-12  9:25 [PATCH 0/1] kernel.bbclass: Need a method to install/update for bzImage Hongxu Jia
2013-09-12  9:25 ` [PATCH 1/1] " Hongxu Jia
2013-09-12  9:47   ` Mike Looijmans [this message]
2013-09-12 12:03     ` Hongxu Jia
2013-09-13  8:51       ` Mike Looijmans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52318DAB.9090108@topic.nl \
    --to=mike.looijmans@topic.nl \
    --cc=cxu@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox