sysupdate: honor default MatchPartitionType= for partitions

sysupdate.d(5) documents linux-generic as the default
MatchPartitionType= for partition targets. After 10eaca4159,
omitting the option left partition_type_set false and update failed
before acquiring the image.

Reproducer: create a partition target transfer without
MatchPartitionType= and run systemd-sysupdate update.

Before: update failed with:
Partition type must be set for partition targets.

After: update succeeds on a linux-generic slot and installs the
version, leaving the GPT label as part-v1.

Follow-up for: 10eaca4159

(cherry picked from commit a3ab9d2c1a)
This commit is contained in:
dongshengyuan authored and Luca Boccassi committed 2026-09-09 10:08:19 +01:00
1 parent 54652ccf35
commit 4746b8dfd2
1 file changed
+6 -2
+6 -2
View File
@@ -600,6 +600,11 @@ int transfer_read_definition(Transfer *t, const char *path, const char **dirs, H
return log_syntax(NULL, LOG_ERR, path, 1, SYNTHETIC_ERRNO(EINVAL),
"Target Type= must be one of partition, regular-file, directory, subvolume.");
if (t->target.type == RESOURCE_PARTITION && !t->target.partition_type_set) {
t->target.partition_type = gpt_partition_type_from_uuid(SD_GPT_LINUX_GENERIC);
t->target.partition_type_set = true;
}
if ((IN_SET(t->source.type, RESOURCE_URL_FILE, RESOURCE_PARTITION, RESOURCE_REGULAR_FILE) &&
!IN_SET(t->target.type, RESOURCE_PARTITION, RESOURCE_REGULAR_FILE)) ||
(IN_SET(t->source.type, RESOURCE_URL_TAR, RESOURCE_TAR, RESOURCE_DIRECTORY, RESOURCE_SUBVOLUME) &&
@@ -1243,8 +1248,7 @@ int transfer_compute_temporary_paths(Transfer *t, Instance *i, InstanceMetadata
if (!r)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Formatted pattern is not suitable as GPT partition label, refusing: %s", formatted_pattern);
if (!t->target.partition_type_set)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Partition type must be set for partition targets.");
assert(t->target.partition_type_set);
/* Derive temporary partition type UUIDs for partial/pending states from the configured
* partition type. This avoids the need for label prefixes. */