1111# bootc switch <into that image> --apply
1212# Verify we boot into the new image
1313#
14+ # For composefs builds, it additionally verifies that composefs is
15+ # still active after upgrade. For sealed UKI builds, it checks that
16+ # both the original and upgrade UKIs exist on the ESP.
17+ #
1418use std assert
1519use tap .nu
1620
@@ -21,6 +25,7 @@ journalctl --list-boots
2125
2226let st = bootc status -- json | from json
2327let booted = $st.status.booted.image
28+ let is_composefs = (tap is_composefs )
2429
2530# Parse the kernel commandline into a list.
2631# This is not a proper parser, but good enough
@@ -50,6 +55,12 @@ RUN touch /usr/share/testing-bootc-upgrade-apply
5055 podman build - t $imgsrc .
5156 }
5257
58+ # For composefs, save state so we can verify it's preserved after upgrade.
59+ if $is_composefs {
60+ " true" | save /var/was-composefs
61+ $st.status.booted.composefs.verity | save /var/original-verity
62+ }
63+
5364 # Now, switch into the new image
5465 print $" Applying ($imgsrc )"
5566 bootc switch -- transport containers-storage ($imgsrc )
@@ -63,7 +74,47 @@ def second_boot [] {
6374 assert equal $booted.image.image $" (imgsrc )"
6475
6576 # Verify the new file exists
66- " /usr/share/testing-bootc-upgrade-apply" | path exists
77+ assert (" /usr/share/testing-bootc-upgrade-apply" | path exists ) " upgrade marker file should exist"
78+
79+ # If the previous boot was composefs, verify composefs survived the upgrade
80+ let was_composefs = (" /var/was-composefs" | path exists )
81+ if $was_composefs {
82+ assert $is_composefs " composefs should still be active after upgrade"
83+
84+ let composefs_info = $st.status.booted.composefs
85+ print $" composefs info: ($composefs_info )"
86+
87+ assert (($composefs_info.verity | str length ) > 0 ) " composefs verity digest should be present"
88+
89+ # For UKI boot type, verify both the original and upgrade UKIs exist on the ESP
90+ if ($composefs_info.bootType | str downcase ) == " uki" {
91+ let bootloader = ($composefs_info.bootloader | str downcase )
92+
93+ let boot_dir = if $bootloader == " systemd" {
94+ mkdir /var/tmp/efi
95+ mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
96+ " /var/tmp/efi/EFI/Linux/bootc"
97+ } else {
98+ " /sysroot/boot/EFI/Linux/bootc"
99+ }
100+
101+ let original_verity = (open /var/original-verity | str trim )
102+ let upgrade_verity = $composefs_info.verity
103+
104+ print $" boot_dir: ($boot_dir )"
105+ print $" original verity: ($original_verity )"
106+ print $" upgrade verity: ($upgrade_verity )"
107+
108+ # The two verities must differ since the upgrade image has different content
109+ assert ($original_verity != $upgrade_verity ) " upgrade should produce a different verity digest"
110+
111+ # There should be two .efi UKI files on the ESP: one for the booted
112+ # deployment (upgrade) and one for the rollback (original)
113+ let efi_files = (glob $" ($boot_dir )/*.efi" )
114+ print $" EFI files: ($efi_files )"
115+ assert (($efi_files | length ) >= 2 ) $" expected at least 2 UKIs on ESP, found ($efi_files | length )"
116+ }
117+ }
67118
68119 tap ok
69120}
0 commit comments