sysupdated: Split Update() into Acquire() and Install() D-Bus methods (#40628)
These mirror the `sysupdate acquire` and `sysupdate install` verbs, which are themselves a split of `sysupdate update` into downloading and installing stages. I have dropped the existing `Update()` method in the final commit, as per the suggestion on https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/2004#note_2145880. If the D-Bus API for `sysupdated` is considered stable now, though, I can drop that commit. CC @AdrianVovk Fixes https://github.com/systemd/systemd/issues/34814
This commit is contained in:
@@ -21,6 +21,8 @@ if [[ ! -x "$SYSUPDATE" ]]; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
have_updatectl=$([[ -x "$SYSUPDATED" ]] && command -v updatectl)
|
||||
|
||||
# Loopback devices may not be supported. They are used because sfdisk cannot
|
||||
# change the sector size of a file, and we want to test both 512 and 4096 byte
|
||||
# sectors. If loopback devices are not supported, we can only test one sector
|
||||
@@ -112,6 +114,16 @@ update_now() {
|
||||
elif [[ "$update_type" == "split" ]]; then
|
||||
"$SYSUPDATE" --verify=no acquire
|
||||
"$SYSUPDATE" --verify=no update
|
||||
elif [[ "$update_type" == "updatectl" ]]; then
|
||||
if $have_updatectl; then
|
||||
systemctl start systemd-sysupdated
|
||||
updatectl update
|
||||
else
|
||||
# Gracefully fall back to sysupdate
|
||||
"$SYSUPDATE" --verify=no update
|
||||
fi
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
(! "$SYSUPDATE" --verify=no check-new)
|
||||
}
|
||||
@@ -150,8 +162,14 @@ verify_version_current() {
|
||||
cmp "$WORKDIR/source/dir-$version/bar.txt" "$WORKDIR/dirs/current/bar.txt"
|
||||
}
|
||||
|
||||
verify_object_fields() {
|
||||
local updatectl_output="${1:?}"
|
||||
|
||||
[[ "${updatectl_output}" != *"Unrecognized object field"* ]] || exit 1
|
||||
}
|
||||
|
||||
for sector_size in "${SECTOR_SIZES[@]}"; do
|
||||
for update_type in monolithic split-offline split; do
|
||||
for update_type in monolithic split-offline split updatectl; do
|
||||
# Disk size of:
|
||||
# - 1MB for GPT
|
||||
# - 4 partitions of 2048 sectors each
|
||||
@@ -352,7 +370,7 @@ EOF
|
||||
# Create sixth version, update using updatectl and verify it replaced the
|
||||
# correct version
|
||||
new_version "$sector_size" v6
|
||||
if [[ -x "$SYSUPDATED" ]] && command -v updatectl; then
|
||||
if $have_updatectl; then
|
||||
systemctl start systemd-sysupdated
|
||||
"$SYSUPDATE" --verify=no check-new
|
||||
updatectl update
|
||||
@@ -370,12 +388,12 @@ EOF
|
||||
# testing for specific output, but this will at least catch obvious crashes
|
||||
# and allow updatectl to run under the various sanitizers. We create a
|
||||
# component so that updatectl has multiple targets to list.
|
||||
if [[ -x "$SYSUPDATED" ]] && command -v updatectl; then
|
||||
if $have_updatectl; then
|
||||
mkdir -p /run/sysupdate.test.d/
|
||||
cp "$CONFIGDIR/01-first.transfer" /run/sysupdate.test.d/01-first.transfer
|
||||
updatectl list
|
||||
updatectl list host
|
||||
updatectl list host@v6
|
||||
verify_object_fields "$(updatectl list 2>&1)"
|
||||
verify_object_fields "$(updatectl list host 2>&1)"
|
||||
verify_object_fields "$(updatectl list host@v6 2>&1)"
|
||||
updatectl check
|
||||
rm -r /run/sysupdate.test.d
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user