validate_update

Function validate_update 

Source
pub(crate) fn validate_update(
    storage: &Storage,
    booted_cfs: &BootedComposefs,
    host: &Host,
    img_digest: &str,
    config_verity: &Sha512HashValue,
    is_switch: bool,
) -> Result<UpdateAction>
Expand description

Determines what action should be taken for the update

Cases:

  • The verity is the same as that of the currently booted deployment

    Nothing to do here as we’re currently booted

  • The verity is the same as that of the staged deployment

    Nothing to do, as we only get a “staged” deployment if we have /run/composefs/staged-deployment which is the last thing we create while upgrading

  • The verity is the same as that of the rollback deployment

    Nothing to do since this is a rollback deployment which means this was unstaged at some point

  • The verity is not found

    The update/switch might’ve been canceled before /run/composefs/staged-deployment was created, or at any other point in time, or it’s a new one. Any which way, we can overwrite everything

§Arguments

  • storage - The global storage object
  • booted_cfs - Reference to the booted composefs deployment
  • host - Object returned by get_composefs_status
  • img_digest - The SHA256 sum of the target image
  • config_verity - The verity of the Image config splitstream
  • is_switch - Whether this is an update operation or a switch operation

§Returns

  • UpdateAction::Skip - Skip the update/switch as we have it as a deployment
  • UpdateAction::UpdateOrigin - Just update the target imgref in the origin file
  • UpdateAction::Proceed - Proceed with the update