Skip to content
Snippets Groups Projects
Commit 0763f91a authored by Frederic Danis's avatar Frederic Danis
Browse files

lib: Fix U-Boot check_bootcounter


Since addition of EFI support, the bootcounter variables are shared between
the different bootloader check parts.
Variables set using read function in pipe subshell are not available
outside of this subshell, and so unset for the rest of the function.

Signed-off-by: default avatarFrédéric Danis <frederic.danis@collabora.com>
parent f9106c9c
No related branches found
No related tags found
2 merge requests!33lib: Fix U-Boot check_bootcounter,!32Backport to v2022pre: lib: Add EFI support to {check,set}_bootcounter
......@@ -326,20 +326,22 @@ EFIBOOTDIR="/boot/efi/loader/entries"
check_bootcounter()
{
if [ -f /boot/uboot.cnt ]; then
od -t x1 -An /boot/uboot.cnt | (
read -r m ver cnt uflag
# Special case for old format
if [ "$m" = "bc" ]; then
cnt="$ver"
ver="00"
# NB: due the bug in legacy U-Boot -- it always create the uboot.cnt and
# increase the counter, so it is not possible to detect the upgrade
# state properly. Hence set the upgrade state for the legacy into
# requested value to avoid failures.
uflag="${4:-1}"
fi
)
uboot_counter=$(od -t x1 -An /boot/uboot.cnt)
m=$(echo $uboot_counter | cut -d ' ' -f 1)
# Special case for old format
if [ "$m" = "bc" ]; then
cnt=$(echo $uboot_counter | cut -d ' ' -f 2)
ver="00"
# NB: due the bug in legacy U-Boot -- it always create the uboot.cnt and
# increase the counter, so it is not possible to detect the upgrade
# state properly. Hence set the upgrade state for the legacy into
# requested value to avoid failures.
uflag="${4:-1}"
else
ver=$(echo $uboot_counter | cut -d ' ' -f 2)
cnt=$(echo $uboot_counter | cut -d ' ' -f 3)
uflag=$(echo $uboot_counter | cut -d ' ' -f 4)
fi
elif [ -f ${EFIBOOTDIR}/ostree-0-2*.conf ]; then
m="$1"
ver="${2:-00}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment