Add "set -eo pipefail" to obmc-flash-bmc
Have seen failures that weren't detected in obmc-flash-bmc.
Move to "set -eo pipefail", so all failures will cause the
script to fail and exit. Removed checks for the rc. Also,
removed the ubi attach command since done in U-Boot now.
Added a check for if the ubi block exists, so not get a
failure when it does exist already.
Resolves openbmc/openbmc#2801
Change-Id: Iaa60d041d1247761fd25a8ae33421f7b3c7335dd
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
index 90ed71d..899d0f0 100644
--- a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
+++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc
@@ -1,4 +1,5 @@
-#!/bin/sh
+#!/bin/bash
+set -eo pipefail
# Get the root mtd device number (mtdX) from "/dev/ubiblockX_Y on /"
findrootmtd() {
@@ -169,10 +170,6 @@
block="/dev/ubiblock${ubidevid}"
if [ ! -e "$block" ]; then
ubiblock --create "/dev/ubi${ubidevid}"
- if [ $? != 0 ]; then
- echo "Unable to create ubiblock ${name}:${ubidevid}"
- return 1
- fi
fi
}
@@ -181,10 +178,6 @@
ubidevid="${vol#ubi}"
img="/tmp/images/${version}/${imgfile}"
ubiupdatevol "/dev/ubi${ubidevid}" "${img}"
- if [ $? != 0 ]; then
- echo "Unable to update volume ${name}!"
- return 1
- fi
}
ubi_remove() {
@@ -237,8 +230,6 @@
IFS=',' read -r -a mtds <<< "$mtds"
mtds=($(echo "${mtds[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
for mtd in ${mtds[@]}; do
- # Re-attach mtd device to ubi if not already done
- ubiattach /dev/ubi_ctrl -m "${mtd}" -d "${mtd}" &> /dev/null
# Get information on all ubi volumes
ubinfo=$(ubinfo -d ${mtd})
presentVolumes=${ubinfo##*:}
@@ -255,7 +246,11 @@
if [ ! -d ${mountdir} ]; then
mkdir -p "${mountdir}"
- ubiblock --create /dev/ubi${mtd}_${element} &> /dev/null
+ # U-Boot will create the ubiblock for the running version, but not
+ # for the version on the other chip
+ if [ ! -e "/dev/ubiblock${mtd}_${element}" ]; then
+ ubiblock --create /dev/ubi${mtd}_${element}
+ fi
mount -t squashfs -o ro "/dev/ubiblock${mtd}_${element}" "${mountdir}"
fi
fi
@@ -455,8 +450,3 @@
exit 1
;;
esac
-rc=$?
-if [ ${rc} -ne 0 ]; then
- echo "$0: error ${rc}"
- exit ${rc}
-fi