Enhance miniboot prestaged install bundle checks

The current miniboot install bundle check rejects
a local install if a container image set check
fails.

This update changes the install bundle check to
conform to the following rules and assumption:

Assumption:
  - the bootimage filename can be arbitrary but
    the filename, excluding the extension, must
    match that of its md5 check file. Example:
    If the iso is named 'bootimage.iso' then the
    check filename must be 'bootimage.md5'.

Rules:
  - There must be an iso image for there to be a local install.
  - There must be an md5 check file of the same filename as
    the iso filename and that check must pass for there to
    be a local install.
  - If there is/are container image check file(s) then run the
    check and log the result.
  - Local install should never be rejected due to missing or
    failed container image set checks.

Test Plan:

PASS: Verify local install with correct iso and check file
      naming convention for both iso and container image set
PASS: Verify local install if container images are missing
PASS: Verify local install if container image set check fails
PASS: Verify check logging for both accepted and rejects cases
PASS: Verify remote install succeeds when local install is rejected
PASS: Verify remote install succeeds with no prestaging

Change-Id: I772ea826233d49a64e4021cf4e28dcae1239b338
Story: 2009291
Task: 43930
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
This commit is contained in:
Eric MacDonald 2021-11-17 11:40:20 -05:00
parent b9b9b42671
commit 14cac85e31
1 changed files with 71 additions and 29 deletions

View File

@ -14,8 +14,10 @@ KS="Miniboot pre:"
wlog "${KS} local install check"
image=false
check=true
iso_check=false
iso_mount=false
prestaging_files=false
# Look for and validate the local iso image
if [ -e ${BACKUP_DEVICE} ]; then
mkdir -p ${BACKUP_MOUNT}
@ -32,46 +34,82 @@ if [ -e ${BACKUP_DEVICE} ]; then
# change to prestaging dir and load the file names
cd ${BACKUP_MOUNT}/${SW_VERSION}
# loop over the files if there are any
# Local Install Bundle Validation:
#
# ISO Image: There must be an iso image whose base
# filename matches an md5 check file and
# that check must pass.
#
# Container Images: Missing container image check file(s) or
# container image validation check failure
# does not reject a Local Install.
#
# Find the iso image first.
# - there should be only one so use the first one found
# just in case there are others there.
# Loop over the files if there are any looking for the iso
iso_filename=""
for file in $(ls -A .) ; do
prestaging_files=true
filename="${file%.*}"
extension="${file##*.}"
wlog "${KS} prestaged file : ${file}"
if [ "${extension}" = "md5" ] ; then
md5sum -c "${file}"
if [ $? -eq 0 ] ; then
wlog "${KS} ${filename} check passed"
else
wlog "${KS} ${filename} check failed"
check=false
if [ "${extension}" = "iso" ] ; then
iso_filename="${filename}"
fi
elif [ "${extension}" = "iso" ] ; then
# found the iso name for the mount operation below
# Found the iso name for the mount operation below
BOOTIMAGE_ISO=${BACKUP_MOUNT}/${SW_VERSION}/${file}
wlog "${KS} found prestaged iso image ${BOOTIMAGE_ISO}"
image=true
if [ -f ${filename}.md5 ] ; then
md5sum -c "${filename}.md5"
if [ $? -eq 0 ] ; then
wlog "${KS} ${file} iso check passed"
iso_check=true
mkdir -p ${BOOTIMAGE_MOUNT}
mount -o loop ${BOOTIMAGE_ISO} ${BOOTIMAGE_MOUNT}
if [ $? -eq 0 ] ; then
iso_mount=true
wlog "${KS} local iso mounted ${BOOTIMAGE_MOUNT}"
else
wlog "${KS} local iso mount failed"
fi
else
wlog "${KS} ${file} iso check failed"
fi
else
wlog "${KS} no iso image check file found ${filename}.md5"
fi
break
fi
done
else
# Loop over the files again this time to run checks
# on md5 files that are not the iso.
# Such files are expected to be checks for container image sets.
# Failure of container image sets check will not reject
# the local install.
for file in $(ls -A .) ; do
prestaging_files=true
filename="${file%.*}"
extension="${file##*.}"
if [ "${extension}" = "md5" -a "${filename}" != "${iso_filename}" ] ; then
wlog "${KS} prestaged file : ${file}"
md5sum -c "${file}"
if [ $? -eq 0 ] ; then
wlog "${KS} ${file} check passed"
else
wlog "${KS} ${file} check failed"
fi
fi
done
fi
if [ "${prestaging_files}" = false ] ; then
wlog "${KS} no prestaged files"
fi
else
wlog "${KS} Error: ${BACKUP_MOUNT} not mounted"
fi
if [ "${check}" = true ] ; then
if [ "${image}" = true -a "${BOOTIMAGE_ISO}" != "" ]; then
wlog "${KS} local iso found : ${BOOTIMAGE_ISO}"
mkdir -p ${BOOTIMAGE_MOUNT}
mount -o loop ${BOOTIMAGE_ISO} ${BOOTIMAGE_MOUNT}
wlog "${KS} local iso mounted for local install"
else
wlog "${KS} local iso file not found"
fi
else
wlog "${KS} local install rejected due to validity check error"
fi
else
wlog "${KS} mount of ${BACKUP_DEVICE} to ${BACKUP_MOUNT} failed rc:$rc"
fi
@ -79,6 +117,10 @@ else
wlog "${KS} backup device ${BACKUP_DEVICE} does not exist"
fi
if [ "${iso_check}" = true -a "${iso_mount}" = true ] ; then
wlog "${KS} Local Install ready"
fi
#
# This controls where the packages come from.
# Lower cost has higher priority ; making local install preferred.