Skip to content

Commit b90faa9

Browse files
authored
Merge pull request #1018 from HuijingHei/update-component-removal
bootupd: Handle component removal when doing updates
2 parents 7b30eb6 + 887b813 commit b90faa9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/bootupd.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,12 @@ pub(crate) fn status() -> Result<Status> {
391391
// adoptable list, and adoption proceeds automatically.
392392
//
393393
// Therefore, calling `query_adopt_state()` alone is sufficient.
394-
if let Some(adopt_ver) = crate::component::query_adopt_state()? {
394+
if let Some(adopt_ver) = component::query_adopt_state()? {
395+
let component = component::new_from_name(&name)?;
396+
// Skip if the update metadata could not be found
397+
if component.query_update(&sysroot)?.is_none() {
398+
continue;
399+
};
395400
ret.adoptable.insert(name.to_string(), adopt_ver);
396401
} else {
397402
log::trace!("Not adoptable: {}", name);

tests/kola/test-bootupd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ bootupctl update | tee out.txt
115115
assert_file_has_content_literal out.txt 'No update available for any component'
116116
assert_not_file_has_content_literal out.txt 'Updated EFI'
117117

118+
# Verify that we skipped update if update metadata not found
119+
mount -o remount,rw /boot
120+
rm -f /boot/bootupd-state.json ${bootupdir}/BIOS.json
121+
bootupctl update | tee out.txt
122+
assert_file_has_content out.txt 'Adopted and updated: EFI: grub2-.*'
123+
assert_not_file_has_content out.txt 'Adopted and updated: BIOS:'
124+
118125
echo "some additions" >> ${tmpefisubdir}/${shimx64}
119126
if bootupctl validate 2>err.txt; then
120127
fatal "unexpectedly passed validation"

0 commit comments

Comments
 (0)