@@ -4,7 +4,7 @@ set -xeuo pipefail
44. ${KOLA_EXT_DATA} /libtest.sh
55
66tmpdir=$( mktemp -d)
7- cd ${tmpdir}
7+ cd " ${tmpdir} "
88echo " using tmpdir: ${tmpdir} "
99touch .testtmp
1010trap cleanup EXIT
@@ -21,20 +21,38 @@ function cleanup () {
2121
2222# Mount the EFI partition.
2323tmpefimount=$( mount_tmp_efi)
24- bootmount=/boot
24+ # Path to <tmp_efi_mount>/EFI
2525tmpefidir=${tmpefimount} /EFI
26+ # /usr/lib/bootupd/updates
2627bootupdir=/usr/lib/bootupd/updates
28+ # fedora
2729efisubdir=fedora
30+ # /usr/lib/bootupd/updates/EFI
31+ efiupdir=${bootupdir} /EFI
32+ # /usr/lib/ostree-boot/efi/EFI
33+ ostbaseefi=/usr/lib/ostree-boot/efi/EFI
34+ # /usr/lib/ostree-boot/efi/EFI/fedora
35+ ostefi=${ostbaseefi} /${efisubdir}
2836shimx64=shimx64.efi
2937grubx64=grubx64.efi
30- efilib=/usr/lib/efi
38+ usrlibefi=/usr/lib/efi
39+ # Path to <tmp_efi_mount>/EFI/fedora
3140tmpefisubdir=${tmpefidir} /${efisubdir}
3241
42+ if [ -d efilib ]; then efilib_exists=true; else efilib_exists=false; fi
43+
3344prepare_efi_update () {
3445 test -w /usr
3546 rm -rf ${bootupdir} /EFI.json
3647}
3748
49+ prepare_efi_update_old_layout () {
50+ test -w /usr
51+ mkdir -p ${ostbaseefi}
52+ cp -a ${efiupdir} .orig/* ${ostbaseefi} /
53+ rm -rf ${efiupdir} ${bootupdir} /EFI.json
54+ }
55+
3856# backup: update_metadata_move EFI EFI-bak
3957# restore: update_metadata_move EFI-bak EFI
4058update_metadata_move () {
@@ -48,18 +66,30 @@ update_metadata_move() {
4866 mv -- " $src " " $dst "
4967}
5068
51- # Find the files under usr/lib/efi after transferred
52- shim_path=$( find ${efilib} -name shim.efi)
53- shimx64_path=$( find ${efilib} -name ${shimx64} )
54- grubx64_path=$( find ${efilib} -name ${grubx64} )
69+ if $efilib_exists ; then
70+ # Find the files under usr/lib/efi after transferred
71+ shim_path=$( find ${usrlibefi} -name shim.efi)
72+ shimx64_path=$( find ${usrlibefi} -name ${shimx64} )
73+ grubx64_path=$( find ${usrlibefi} -name ${grubx64} )
5574
56- test -n " ${shimx64_path} " && test -n " ${grubx64_path} "
57- ! test -d " /usr/lib/bootupd/updates/EFI"
75+ test -n " ${shimx64_path} " && test -n " ${grubx64_path} "
76+ test -d " /usr/lib/bootupd/updates/EFI" && exit 1
77+ else
78+ shim_path=$( find ${bootupdir} -name shim.efi)
79+ shimx64_path=$( find ${bootupdir} -name ${shimx64} )
80+ grubx64_path=$( find ${bootupdir} -name ${grubx64} )
81+
82+ test -n " ${shimx64_path} " && test -n " ${grubx64_path} "
83+ fi
5884
5985bootupctl status > out.txt
6086evr=$( rpm -q grub2-common --qf ' %{EVR}' )
6187assert_file_has_content_literal out.txt ' Component EFI'
62- assert_file_has_content_literal out.txt ' Installed: grub2-' " ${evr} "
88+ if $efilib_exists ; then
89+ assert_file_has_content_literal out.txt ' Installed: grub2-' " ${evr} "
90+ else
91+ assert_file_has_content_literal out.txt ' Installed: grub2-efi-x64-'
92+ fi
6393assert_file_has_content_literal out.txt ' Update: At latest version'
6494assert_file_has_content out.txt ' ^CoreOS aleph version:'
6595ok status
@@ -75,10 +105,16 @@ assert_file_has_content err.txt 'error: This command requires root privileges'
75105# From here we'll fake updates
76106test -w /usr || rpm-ostree usroverlay
77107
78- prepare_efi_update
108+ if $efilib_exists ; then
109+ prepare_efi_update
110+ rm -v " ${shim_path} "
111+ echo bootupd-test-changes >> " ${grubx64_path} "
112+ else
113+ prepare_efi_update_old_layout
114+ rm -v ${ostefi} /shim.efi
115+ echo bootupd-test-changes >> ${ostefi} /grubx64.efi
116+ fi
79117
80- rm -v ${shim_path}
81- echo bootupd-test-changes >> ${grubx64_path}
82118/usr/libexec/bootupd generate-update-metadata /
83119ver=$( jq -r .version < ${bootupdir} /EFI.json)
84120vers=$( jq -r .versions < ${bootupdir} /EFI.json)
@@ -92,14 +128,23 @@ mv new.json ${bootupdir}/EFI.json
92128
93129bootupctl status | tee out.txt
94130assert_file_has_content_literal out.txt ' Component EFI'
95- assert_file_has_content_literal out.txt ' Installed: grub2-' " ${evr} "
131+ if $efilib_exists ; then
132+ assert_file_has_content_literal out.txt ' Installed: grub2-' " ${evr} "
133+ else
134+ assert_file_has_content_literal out.txt ' Installed: grub2-efi-x64-'
135+ fi
96136assert_not_file_has_content out.txt ' Installed: grub2-.*,test'
97137assert_file_has_content_literal out.txt ' Update: Available:'
98138ok update avail
99139
100140bootupctl status --json > status.json
101141jq -r ' .components.EFI.installed.version' < status.json > installed.txt
102- assert_file_has_content installed.txt ' ^grub2-' " ${evr} "
142+
143+ if $efilib_exists ; then
144+ assert_file_has_content installed.txt ' ^grub2-' " ${evr} "
145+ else
146+ assert_file_has_content installed.txt ' ^grub2-efi-x64'
147+ fi
103148
104149bootupctl update | tee out.txt
105150assert_file_has_content out.txt ' Updated EFI: grub2-.*,test'
@@ -115,13 +160,13 @@ ok validate after update
115160
116161# FIXME see above
117162# assert_file_has_content ${tmpefidir}/${efisubdir}/somenew.efi 'somenewfile'
118- if test -f ${tmpefisubdir} /shim.efi; then
163+ if test -f " ${tmpefisubdir} /shim.efi" ; then
119164 fatal " failed to remove file"
120165fi
121- if ! grep -q ' bootupd-test-changes' ${tmpefisubdir} /${grubx64} ; then
166+ if ! grep -q ' bootupd-test-changes' " ${tmpefisubdir} /${grubx64} " ; then
122167 fatal " failed to update modified file"
123168fi
124- cmp ${tmpefisubdir} /${shimx64} ${shimx64_path}
169+ cmp " ${tmpefisubdir} /${shimx64} " " ${shimx64_path} "
125170ok filesystem changes
126171
127172bootupctl update | tee out.txt
162207 assert_not_file_has_content out.txt ' Adopted and updated: EFI:'
163208fi
164209
165- echo " some additions" >> ${tmpefisubdir} /${shimx64}
210+ echo " some additions" >> " ${tmpefisubdir} /${shimx64} "
166211if bootupctl validate 2> err.txt; then
167212 fatal " unexpectedly passed validation"
168213fi
0 commit comments