flash_bmc: Add Apply method to flash updates from runtime

This commit adds methods to Validate (not exposed), Apply,
GetUpdateProgress, and Abort along with an auto_apply attribute.

A PrepareForUpdate method is also added that will write bootloader
environment to instruct the initramfs init script to copy necessary
file system state into RAM to allow the flash to be updated.

Together these methods take the prior Update method and chain
on the Validate phase which checks the image can be applied
concurrently (and could be extended to check signatures).  If
validation fails auto_apply is cleared.   If auto_apply remains
true then Apply is called which will perform the check again
(implicitly in the update script) and update the flash contents,
saving its output to a temporary file.

The GetUpdateProgress will return the status variable followed
by the output from the update script, with status that was
overwritten with a carriage return stripped.  As each new phase
(erase, write, and verify) of each image is encountered the
message will be extended.

An Abort method will kill an in-progress update, erase the logfile,
and remove any pending images.  A new image can be unpacked at this
time.

Note: the current method to clear all persistent files removes the
whitelist and all future calls will clear all files from the read
write layer.  This maybe addressed in a future update.

Signed-off-by: Milton Miller <miltonm@us.ibm.com>
1 file changed