# Create a random extra payload
echo $RANDOM >"$WORKDIR/source/uki-extra-$version.efi"
+ # Create a random optional payload
+ echo $RANDOM >"$WORKDIR/source/optional-$version.efi"
+
# Create tarball of a directory
mkdir -p "$WORKDIR/source/dir-$version"
echo $RANDOM >"$WORKDIR/source/dir-$version/foo.txt"
mkdir -p "$d"
done
- cat >"$CONFIGDIR/01-first.conf" <<EOF
+ cat >"$CONFIGDIR/01-first.transfer" <<EOF
[Source]
Type=regular-file
Path=$WORKDIR/source
MatchPartitionType=root-x86-64
EOF
- cat >"$CONFIGDIR/02-second.conf" <<EOF
+ cat >"$CONFIGDIR/02-second.transfer" <<EOF
[Source]
Type=regular-file
Path=$WORKDIR/source
MatchPartitionType=root-x86-64-verity
EOF
- cat >"$CONFIGDIR/03-third.conf" <<EOF
+ cat >"$CONFIGDIR/03-third.transfer" <<EOF
[Source]
Type=directory
Path=$WORKDIR/source
InstancesMax=3
EOF
- cat >"$CONFIGDIR/04-fourth.conf" <<EOF
+ cat >"$CONFIGDIR/04-fourth.transfer" <<EOF
[Source]
Type=regular-file
Path=$WORKDIR/source
InstancesMax=2
EOF
- cat >"$CONFIGDIR/05-fifth.conf" <<EOF
+ cat >"$CONFIGDIR/05-fifth.transfer" <<EOF
[Source]
Type=regular-file
Path=$WORKDIR/source
MatchPattern=uki_@v.efi.extra.d/extra.addon.efi
Mode=0444
InstancesMax=2
+EOF
+
+ cat >"$CONFIGDIR/optional.feature" <<EOF
+[Feature]
+Description=Optional Feature
+EOF
+
+ cat >"$CONFIGDIR/99-optional.transfer" <<EOF
+[Transfer]
+Features=optional
+
+[Source]
+Type=regular-file
+Path=$WORKDIR/source
+MatchPattern=optional-@v.efi
+
+[Target]
+Type=regular-file
+Path=/EFI/Linux
+PathRelativeTo=boot
+MatchPattern=uki_@v.efi.extra.d/optional.efi
+Mode=0444
+InstancesMax=2
EOF
rm -rf "${WORKDIR:?}"/{esp,xbootldr,source}
verify_version "$blockdev" "$sector_size" v3 1
verify_version_current "$blockdev" "$sector_size" v5 2
+ # Now let's try enabling an optional feature
+ test ! -f "$WORKDIR/xbootldr/EFI/Linux/uki_v5.efi.extra.d/optional.efi"
+ mkdir "$CONFIGDIR/optional.feature.d"
+ echo -e "[Feature]\nEnabled=true" > "$CONFIGDIR/optional.feature.d/enable.conf"
+ "$SYSUPDATE" --offline list v5 | grep -q "incomplete"
+ update_now
+ "$SYSUPDATE" --offline list v5 | grep -qv "incomplete"
+ verify_version "$blockdev" "$sector_size" v3 1
+ verify_version_current "$blockdev" "$sector_size" v5 2
+ test -f "$WORKDIR/xbootldr/EFI/Linux/uki_v5.efi.extra.d/optional.efi"
+
+ # And now let's disable it and make sure it gets cleaned up
+ rm -r "$CONFIGDIR/optional.feature.d"
+ (! "$SYSUPDATE" --verify=no check-new)
+ "$SYSUPDATE" vacuum
+ "$SYSUPDATE" --offline list v5 | grep -qv "incomplete"
+ verify_version "$blockdev" "$sector_size" v3 1
+ verify_version_current "$blockdev" "$sector_size" v5 2
+ test ! -f "$WORKDIR/xbootldr/EFI/Linux/uki_v5.efi.extra.d/optional.efi"
+
# Create sixth version, update using updatectl and verify it replaced the
# correct version
new_version "$sector_size" v6
# component so that updatectl has multiple targets to list.
if [[ -x "$SYSUPDATED" ]] && command -v updatectl; then
mkdir -p /run/sysupdate.test.d/
- cp "$CONFIGDIR/01-first.conf" /run/sysupdate.test.d/01-first.conf
+ cp "$CONFIGDIR/01-first.transfer" /run/sysupdate.test.d/01-first.transfer
updatectl list
updatectl list host
updatectl list host@v6
# see above)
new_version "$sector_size" v7
- cat >"$CONFIGDIR/02-second.conf" <<EOF
+ cat >"$CONFIGDIR/02-second.transfer" <<EOF
[Source]
Type=url-file
Path=file://$WORKDIR/source
MatchPartitionType=root-x86-64-verity
EOF
- cat >"$CONFIGDIR/03-third.conf" <<EOF
+ cat >"$CONFIGDIR/03-third.transfer" <<EOF
[Source]
Type=url-tar
Path=file://$WORKDIR/source
verify_version "$blockdev" "$sector_size" v6 1
verify_version_current "$blockdev" "$sector_size" v7 2
+ # Let's make sure that we don't break our backwards-compat for .conf files
+ # (what .transfer files were called before v257)
+ for i in "$CONFIGDIR/"*.conf; do echo mv "$i" "${i%.conf}.transfer"; done
+ new_version "$sector_size" v8
+ update_now
+ verify_version_current "$blockdev" "$sector_size" v8 1
+ verify_version "$blockdev" "$sector_size" v7 2
+
# Cleanup
[[ -b "$blockdev" ]] && losetup --detach "$blockdev"
rm "$BACKING_FILE"