Skip to content

Commit

Permalink
updog: new subcommand to revert 'update-apply'
Browse files Browse the repository at this point in the history
Adds a new subcommand for reverting actions done by 'update-apply'.
Used to "deactivate" an update.
  • Loading branch information
etungsten committed Jun 17, 2020
1 parent 5400266 commit d540035
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sources/updater/updog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum Command {
Update,
UpdateImage,
UpdateApply,
RevertUpdateApply,
}

#[derive(Debug, Deserialize)]
Expand Down Expand Up @@ -92,6 +93,8 @@ SUBCOMMANDS:
update-apply Update boot flags (after having called update-image)
[ -r | --reboot ] Reboot after updating boot flags
revert-update-apply Revert actions done by 'update-apply'
GLOBAL OPTIONS:
[ -j | --json ] JSON-formatted output
[ --log-level trace|debug|info|warn|error ] Set logging verbosity");
Expand Down Expand Up @@ -266,6 +269,16 @@ fn update_flags() -> Result<()> {
Ok(())
}

fn revert_update_flags() -> Result<()> {
let mut gpt_state = State::load().context(error::PartitionTableRead)?;
// This actually wipes all the priority bits in the inactive partition
gpt_state.cancel_upgrade();
// The update is still in the inactive partition so mark the inactive partition as valid
gpt_state.mark_inactive_valid();
gpt_state.write().context(error::PartitionTableWrite)?;
Ok(())
}

fn set_common_query_params(
transport: &HttpQueryTransport,
current_version: &Version,
Expand Down Expand Up @@ -567,6 +580,9 @@ fn main_inner() -> Result<()> {
initiate_reboot()?;
}
}
Command::RevertUpdateApply => {
revert_update_flags()?;
}
Command::Prepare => {
// TODO unimplemented
}
Expand Down

0 comments on commit d540035

Please sign in to comment.