From c62251b658b47e6a9a85d9c435973a40dbbb39e1 Mon Sep 17 00:00:00 2001 From: Vadym Hlushko <62022266+vadymhlushko-mlnx@users.noreply.github.com> Date: Fri, 4 Feb 2022 04:03:17 +0200 Subject: [PATCH] [install.sh] Fixed the sed pattern to match the current image revision (#9813) #### Why I did it The test plan described in the `How to verify it` section caused an issue when 3 images (instead of 2) were present when executing `show boot` or `sonic-installer list` commands: ``` root@sonic:/home/admin# show boot Current: SONiC-OS-master.0-dirty-20220118.165941 Next: SONiC-OS-master.0-dirty-20220118.165941 Available: SONiC-OS-master.0-dirty-20220118.165941 SONiC-OS-202012.201-a0376a6e5_Internal SONiC-OS-202012.201-a0376a6e5_Internal_RPC ``` #### How I did it Fixed the `sed` pattern to match the current image revision in the `install.sh` script. #### How to verify it Test plan: 1. Install the `imageA` by using ONIE 2. Install the `imageA-rpc` by using `sonic-installer` 3. Reboot the switch 4. Swap to the `imageA` - `sonic-installer set-default imageA` 5. Reboot the switch 6. Install the `imageB` by using `sonic-installer` 7. Check an installed images - `show boot` 8. Reboot the switch 9. Check an installed images - `show boot` --- installer/x86_64/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/x86_64/install.sh b/installer/x86_64/install.sh index 733dea43da..dbab4d54ab 100755 --- a/installer/x86_64/install.sh +++ b/installer/x86_64/install.sh @@ -652,7 +652,7 @@ fi # Note: assume that apparmor is supported in the kernel demo_grub_entry="$demo_volume_revision_label" if [ "$install_env" = "sonic" ]; then - old_sonic_menuentry=$(cat /host/grub/grub.cfg | sed "/$running_sonic_revision/,/}/!d") + old_sonic_menuentry=$(cat /host/grub/grub.cfg | sed "/^menuentry '${demo_volume_label}-${running_sonic_revision}'/,/}/!d") grub_cfg_root=$(echo $old_sonic_menuentry | sed -e "s/.*root\=\(.*\)rw.*/\1/") onie_menuentry=$(cat /host/grub/grub.cfg | sed "/menuentry ONIE/,/}/!d") elif [ "$install_env" = "build" ]; then