blob: 1548f50598388a8e7114956e271e249082e9b39d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
From 78d26166a8ad1bc8d29822d45a6a382b87fa095d Mon Sep 17 00:00:00 2001
From: Awais Belal <awais_belal@mentor.com>
Date: Mon, 14 Jan 2019 19:40:50 +0500
Subject: [PATCH 4/7] init-install-efi: pick kernel and rootfs from grub.env
This allows for simply modifying variables to switch between
different kernels and rootfs from user-space without having to
modify grub configurations directly.
Signed-off-by: Awais Belal <awais_belal@mentor.com>
---
init-install-efi.sh | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/init-install-efi.sh b/init-install-efi.sh
index 2adfe02..d69520f 100644
--- a/init-install-efi.sh
+++ b/init-install-efi.sh
@@ -287,6 +287,7 @@ mkdir -p $EFIDIR
cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR
GRUBCFG="$EFIDIR/grub.cfg"
+GRUBENV="$EFIDIR/grub.env"
if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then
root_part_uuid=$(blkid -o value -s PARTUUID ${rootfs1})
cp /run/media/$1/EFI/BOOT/grub.cfg $GRUBCFG
@@ -297,9 +298,14 @@ if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then
sed -i "/initrd /d" $GRUBCFG
# Delete any LABEL= strings
sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
+ # Mentor- SWUpdate - force grub to load our env which we'll use to specify RFS and KERNEL
+ sed -i "1iload_env --file ${GRUBENV#\/boot}" $GRUBCFG
+ # Set current and fallback rootfs using variable via our grub.env
+ grub-editenv $GRUBENV set "RFS=PARTUUID=$root_part_uuid"
+ grub-editenv $GRUBENV set "FB_RFS=PARTUUID=$root_part_uuid"
# Replace root= and add additional standard boot options
# We use root as a sentinel value, as vmlinuz is no longer guaranteed
- sed -i "s/ root=[^ ]*/ root=PARTUUID=$root_part_uuid rw $rootwait quiet /g" $GRUBCFG
+ sed -i "s/ root=[^ ]*/ root=\$RFS rw $rootwait quiet /g" $GRUBCFG
fi
if [ -d /run/media/$1/loader ]; then
@@ -321,15 +327,25 @@ fi
umount /tgt_root
+if [ -e "/proc/cmdline" ]; then
+ current_kernel=$(basename $(cat /proc/cmdline | awk '{print $1}' | cut -d"=" -f2))
+fi
# Copy kernel artifacts. To add more artifacts just add to types
# For now just support kernel types already being used by something in OE-core
for types in bzImage zImage vmlinux vmlinuz fitImage; do
# MEL - SWUpdate - copy all kernel images as <image>A, this is our first copy
for kernel in `find /run/media/$1/ -name $types*`; do
kernel_name=$(basename $kernel)
- cp $kernel /boot/${kernel_name}A
+ cp ${kernel} /boot/${kernel_name}A
if [ -e $GRUBCFG ]; then
- sed -i "s/\/${kernel_name} /\/${kernel_name}A /" $GRUBCFG
+ if [ "${kernel_name}" = "${current_kernel}" ]; then
+ sed -i "s/\/${kernel_name} /\/\$KERNEL /" $GRUBCFG
+ # Set the current and fallback kernel to current kernel's <image>A
+ grub-editenv $GRUBENV set "KERNEL=${kernel_name}A"
+ grub-editenv $GRUBENV set "FB_KERNEL=${kernel_name}A"
+ else
+ sed -i "s/\/${kernel_name} /\/${kernel_name}A /" $GRUBCFG
+ fi
fi
done
done
--
2.11.1
|