From 695958aed9a0b555e2b607e297c89f38d91f2526 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Thu, 18 Jul 2024 11:13:25 -0400 Subject: [PATCH] swupdate-ab: improve error handling if mnt_point is empty Depending on where the error occurs, mnt_point can be empty. If this is the case, this error can happen: Status: 4 message: ERROR util.c : read_lines_notify : 1166 : swupdate-ab.sh: Error: destination partition "/dev/mmcblk0p2" not found Status: 4 message: ERROR util.c : read_lines_notify : 1166 : swupdate-ab.sh: Error 1 occurred Status: 4 message: ERROR util.c : read_lines_notify : 1166 : BusyBox v1.36.1 () multi-call binary. Status: 4 message: ERROR util.c : read_lines_notify : 1166 : Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]... Status: 2 message: [__run_cmd] : /tmp/scripts/swupdate-ab.sh preinst p2 command returned 1 Add check for valid mnt_point before trying to unmount. --- recipes-support/swupdate/swupdate-ab/update.header.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes-support/swupdate/swupdate-ab/update.header.sh b/recipes-support/swupdate/swupdate-ab/update.header.sh index 53df653..8eed7e4 100644 --- a/recipes-support/swupdate/swupdate-ab/update.header.sh +++ b/recipes-support/swupdate/swupdate-ab/update.header.sh @@ -26,10 +26,12 @@ catch() { if [ "$1" != "0" ]; then # Error handling goes here - echo "Error $1 occurred" + printf >&2 "$(basename ${0}): Error $1 occurred\n" - if mount | grep -q ${mnt_point}; then - unmount_destination_partition + if [ -n "${mnt_point}" ]; then + if mount | grep -q ${mnt_point}; then + unmount_destination_partition + fi fi fi } -- 2.20.1