This commit fills the void for current OpenWrt installations which will
be still on old bootloader version even after "x86: add bootloader
upgrade on sysupgrade", since it performs bootloader upgrade only on
sysupgrade. To keep all OpenWrt deploynents on the same GRUB version,
add preinit hook, which will perform upgrade of the bootloader on first
boot after sysupgrade.
It's temporary solution and should be deleted, when the first release
including this hook will no longer be supported by OpenWrt team.
We can assume that all installations should be on current bootolader
version and from there sysupgrade routine will be sufficient.
Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
--- /dev/null
+#!/bin/sh
+
+upgrade_bootloader() {
+ local diskdev
+
+ . /lib/upgrade/common.sh
+
+ if [ ! -f /boot/grub/upgraded ] && export_bootdevice && export_partdevice diskdev 0; then
+ echo "(hd0) /dev/$diskdev" > /tmp/device.map
+ /usr/sbin/grub-bios-setup \
+ -m "/tmp/device.map" \
+ -d "/boot/grub" \
+ -r "hd0,msdos1" \
+ "/dev/$diskdev" \
+ && touch /boot/grub/upgraded
+ fi
+}
+
+[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main upgrade_bootloader
-m "/tmp/device.map" \
-d "/tmp/boot/boot/grub" \
-r "hd0,msdos1" \
- "/dev/$diskdev"
+ "/dev/$diskdev" \
+ && touch /boot/grub/upgraded
umount /tmp/boot
fi