firmware: finalise mtree health check

Not what I was expecting from a base tool like mtree...

* Missing files are not seen as an error condition, so
  remove our ignored files (they show up as nonexistent)
  and then count how many files are missing.  If there
  is at least a missing file show the output and don't
  say everything is swell.

* Since we prefilter MTREE_OUT on a real error just show
  the output since it's likely there's an error to see.
This commit is contained in:
Franco Fichtner 2018-11-21 09:01:16 +01:00
parent 57bef4363f
commit 9325d87b4e

View File

@ -86,12 +86,19 @@ set_check()
MTREE_OUT=$(${MTREE} -X ${TMPFILE} < ${FILE} 2>&1)
MTREE_RET=${?}
MTREE_OUT=$(echo "${MTREE_OUT}" | grep -Fvx "${GREP_PATTERNS}")
MTREE_MIA=$(echo "${MTREE_OUT}" | grep -c ' missing$')
if [ ${MTREE_RET} -eq 0 ]; then
echo "No problems detected." >> ${PKG_PROGRESS_FILE} 2>&1
if [ "${MTREE_MIA}" = "0" ]; then
echo "No problems detected." >> ${PKG_PROGRESS_FILE} 2>&1
else
echo "Missing files: ${MTREE_MIA}" >> ${PKG_PROGRESS_FILE} 2>&1
echo "${MTREE_OUT}" >> ${PKG_PROGRESS_FILE} 2>&1
fi
else
echo "Error ${MTREE_RET} ocurred." >> ${PKG_PROGRESS_FILE} 2>&1
echo -n "${MTREE_OUT}" | grep -Fvx "${GREP_PATTERNS}" | \
>> ${PKG_PROGRESS_FILE} 2>&1
echo "${MTREE_OUT}" >> ${PKG_PROGRESS_FILE} 2>&1
fi
rm ${TMPFILE}