bootupd icon indicating copy to clipboard operation
bootupd copied to clipboard

efi: update the ESP by creating a tmpdir and RENAME_EXCHANGE

Open HuijingHei opened this issue 8 months ago • 30 comments

See Timothée's comment https://github.com/coreos/bootupd/issues/454#issuecomment-2178227050 Reuse TMP_PREFIX, logic is like this:

  • cp -a fedora .btmp.fedora
    • We start with a copy to make sure to keep all other files that we do not explicitly track in bootupd
  • Update the content of .btmp.fedora with the new binaries
  • Exchange .btmp.fedora -> fedora
  • Remove now "old" .btmp.fedora

If we have a file not in a directory in EFI, then we can copy it to .btmp.foo and then act on it and finally rename it. No need to copy the entire EFI.

Additional info for the logic:

  • for removals, copy to temp dir, remove file in temp dir; if have a file not in a directory, remove it directly
  • for changes/additions, copy to temp dir, write files in temp dir; if have a file not in a directory, copy as temp file
  • Do local exchange/rename and remove temp dir/file

And use insert() instead of push() to match starts_with() when scanning temp files & dirs.

Fixes https://github.com/coreos/bootupd/issues/454


filetree: add failpoint when doing exchange Inspired by https://github.com/coreos/bootupd/pull/669#issuecomment-2220760948

HuijingHei avatar Jun 19 '24 12:06 HuijingHei