aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Maciej Nowak <tomek_n@o2.pl>2020-01-14 18:45:45 +0100
committerPetr Štetiar <ynezz@true.cz>2020-03-01 21:36:00 +0100
commitb9c1cf16579c53b51524f753313732817ea1439d (patch)
treea1904d4508615bb614b7cde4c90d0e1e2d058931
parentb322243d2f768a04a04831c45dabc627a41c4570 (diff)
downloadupstream-b9c1cf16579c53b51524f753313732817ea1439d.tar.gz
upstream-b9c1cf16579c53b51524f753313732817ea1439d.tar.bz2
upstream-b9c1cf16579c53b51524f753313732817ea1439d.zip
x86: add preinit hook for bootloader upgrade
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>
-rw-r--r--target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader19
-rw-r--r--target/linux/x86/base-files/lib/upgrade/platform.sh3
2 files changed, 21 insertions, 1 deletions
diff --git a/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader b/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader
new file mode 100644
index 0000000000..3a4e756b1e
--- /dev/null
+++ b/target/linux/x86/base-files/lib/preinit/81_upgrade_bootloader
@@ -0,0 +1,19 @@
+#!/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
diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
index 8be96dfcd4..53c751861c 100644
--- a/target/linux/x86/base-files/lib/upgrade/platform.sh
+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
@@ -60,7 +60,8 @@ platform_do_bootloader_upgrade() {
-m "/tmp/device.map" \
-d "/tmp/boot/boot/grub" \
-r "hd0,msdos1" \
- "/dev/$diskdev"
+ "/dev/$diskdev" \
+ && touch /boot/grub/upgraded
umount /tmp/boot
fi