Skip to contentSkip to conversation

kernel.bbclass: Need a method to install/update for bzImage

PATCH Superseded Hongxu Jia 2 participants 5 messages Sep 12, 2013 – Sep 13, 2013

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Hongxu Jia

author
#0 lore raw

cover kernel.bbclass: Need a method to install/update for bzImage

Test Case:
1. Prepare a deployed target, and make sure your boot area has enough disk space.

2. Download the new kernel image rpm to the target

3. Before install/update, check boot area and menu

root@qemux86:~# ls /boot/
grub        vmlinuz
root@qemux86:~# cat /boot/grub/grub.cfg
menuentry "Linux" {
    set root=(hd0,1)
    linux /vmlinuz root=/dev/hdb2  rw  console=tty0  quiet
}

4. Install/update bzImage

root@qemux86:~# rpm -i kernel-image-3.10.9-yocto-standard-3.10.9+git0+cd502a8814_7144bcc4b8-r0.qemux86.rpm 
Caution! Update kernel may affect kernel-module!
update-alternatives: Linking //boot/bzImage to bzImage-3.10.9-yocto-standard

5. After install/update, check boot area and menu

root@qemux86:~# ls /boot/ -al
drwxr-xr-x    4 root     root          1024 Sep 12 08:48 .
drwxr-xr-x   17 root     root          4096 Sep 12 07:08 ..
lrwxrwxrwx    1 root     root            29 Sep 12 08:48 bzImage -> bzImage-3.10.9-yocto-standard
-rw-r--r--    1 root     root       6172096 Sep 12 07:39 bzImage-3.10.9-yocto-standard
drwxr-xr-x    4 root     root          1024 Sep 12 08:48 grub
-rwxr-x---    1 root     root       6172096 Sep 12 08:45 vmlinuz
root@qemux86:~# cat /boot/grub/grub.cfg 
menuentry "Update bzImage-3.10.9-yocto-standard-3.10.9+gitAUTOINC+cd502a8814_7144bcc4b8" {
    set root=(hd0,1)
    linux /bzImage-3.10.9-yocto-standard root=/dev/hdb2  rw  console=tty0  quiet
}
menuentry "Linux" {
    set root=(hd0,1)
    linux /vmlinuz root=/dev/hdb2  rw  console=tty0  quiet
}

6. Reboot target, 'Update bzImage-3.10.9-yocto-standard-3.10.9+gitAUTOINC+cd502a8814_7144bcc4b8' will be in the boot menu.

7. It supports GRUB 0.97 in which the grub.cfg doesn't exist and menu.lst is used.

8. If you install the same rpm more than one time with '--force', there will be multiple kernel images in boot area and menu.

//Hongxu

The following changes since commit 1b814498b60d5f354d8cc5bdf568b91baf0745dc:

bitbake: bitbake/cooker: fix some calls of cookerdata.findConfigFile method (2013-09-02 12:26:20 +0100)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib hongxu/update-bzimage
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/update-bzimage

Hongxu Jia (1):
kernel.bbclass: Need a method to install/update for bzImage

 meta/classes/kernel.bbclass | 65 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
Signature · 1 line
1.8.1.2
author
#1 lore raw

PATCH 1/1 kernel.bbclass: Need a method to install/update for bzImage

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]

---
 meta/classes/kernel.bbclass | 65 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
meta/classes/kernel.bbclass +65 -0
index e039dfc..f0dd679 100644
@@ -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}
Signature · 1 line
1.8.1.2
#2 lore raw

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.

Quoted 83 lines · Hongxu Jia

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]

---
  meta/classes/kernel.bbclass | 65 +++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 65 insertions(+)
meta/classes/kernel.bbclass +58 -0
index e039dfc..f0dd679 100644
@@ -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"

meta/classes/kernel.bbclass ALLOW_EMPTY_kernel-image = "1" · line 334

Quoted 10 lines
meta/classes/kernel.bbclass +7 -0
+			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: [email protected]
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.

author
#3 lore raw
Quoted 4 lines · Mike Looijmans

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.

Yes, we should add a on-off to decide whether the method should be used or not, and set off by default.

But I could not find a better location to do this, almost all of targets in oe-core may need this, do you have any suggestions?

Thanks,
Hongxu

Quoted 130 lines

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.

Quoted 103 lines · Hongxu Jia

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]

---
  meta/classes/kernel.bbclass | 65 
+++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 65 insertions(+)
meta/classes/kernel.bbclass +7 -0
index e039dfc..f0dd679 100644
@@ -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.

meta/classes/kernel.bbclass +3 -0
+            if grep -q "/${KERNEL_IMAGETYPE} root=" $grubcfg; then
+                kimage=`realpath /boot/${KERNEL_IMAGETYPE}`;
+                sed -i "s#${KERNEL_IMAGETYPE} root=#${kimage##*/} 

root=#" $grubcfg

meta/classes/kernel.bbclass +4 -0
+            fi
+
+            # Rename old kernel if it conflicts with new kernel name.
+            if grep -q "/${KERNEL_IMAGETYPE}-${KERNEL_VERSION} 

root=" $grubcfg; then

meta/classes/kernel.bbclass +3 -0
+                timestamp=`date +%s`
+ kimage="/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}-$timestamp-back"
+                sed -i "s#${KERNEL_IMAGETYPE}-${KERNEL_VERSION} 

root=#${kimage##*/} root=#" $grubcfg

meta/classes/kernel.bbclass +11 -1
+                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=#"`

meta/classes/kernel.bbclass +8 -1
+
+            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=#"`

meta/classes/kernel.bbclass +14 -0
+
+            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'

meta/classes/kernel.bbclass +15 -0
+        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

Quoted 3 lines
      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: [email protected]
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.

#4 lore raw
Quoted 12 lines · Hongxu Jia
Quoted 10 lines · Mike Looijmans

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.

Quoted 7 lines

Yes, we should add a on-off to decide whether the method should be used or not,
and set off by default.

But I could not find a better location to do this, almost all of targets in oe-core may
need this, do you have any suggestions?

My intuition says, just create a "kernel-grub.bbclass". I don't see anything wrong with that yet.

On the other hand, it's more of a thing I'd expect in BSP or machine support layer.

Mike.

Quoted 147 lines
Quoted 147 lines

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.

Quoted 106 lines · Hongxu Jia

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]

---
  meta/classes/kernel.bbclass | 65
+++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 65 insertions(+)
meta/classes/kernel.bbclass +7 -0
index e039dfc..f0dd679 100644
@@ -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.

meta/classes/kernel.bbclass +3 -0
+            if grep -q "/${KERNEL_IMAGETYPE} root=" $grubcfg; then
+                kimage=`realpath /boot/${KERNEL_IMAGETYPE}`;
+                sed -i "s#${KERNEL_IMAGETYPE} root=#${kimage##*/}

root=#" $grubcfg

meta/classes/kernel.bbclass +4 -0
+            fi
+
+            # Rename old kernel if it conflicts with new kernel name.
+            if grep -q "/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}

root=" $grubcfg; then

meta/classes/kernel.bbclass +3 -0
+                timestamp=`date +%s`
+ kimage="/boot/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}-$timestamp-back"
+                sed -i "s#${KERNEL_IMAGETYPE}-${KERNEL_VERSION}

root=#${kimage##*/} root=#" $grubcfg

meta/classes/kernel.bbclass +11 -1
+                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=#"`

meta/classes/kernel.bbclass +8 -1
+
+            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=#"`

meta/classes/kernel.bbclass +14 -0
+
+            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'

meta/classes/kernel.bbclass +15 -0
+        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

Quoted 3 lines
      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: [email protected]
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.

Quoted 13 lines
Quoted 11 lines

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.

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: [email protected]
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.
_______________________________________________

Quoted 3 lines

Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core