sysupdate: Add --transfer-source=
In mkosi, I want to add a sysupdate verb to wrap systemd-sysupdate. The definitions will be picked up from mkosi.sysupdate/ and passed to systemd-sysupdate. I want users to be able to write transfer definitions that are independent of the output directory used by mkosi. To make this possible, it should be possible to specify the directory that transfer sources should be looked up in on the sysupdate command line. Let's allow this via a new --transfer-source= option. Additionally, transfer sources that want to take advantage of this feature should specify PathRelativeTo=directory to indicate the configured Path= is interpreted relative to the tranfer source directory specified on the CLI. This allows for the following transfer definition to be put in mkosi.sysupdate: """ [Transfer] ProtectVersion=%A [Source] Type=regular-file Path=/ PathRelativeTo=directory MatchPattern=ParticleOS_@v.usr-%a.@u.raw [Target] Type=partition Path=auto MatchPattern=ParticleOS_@v MatchPartitionType=usr PartitionFlags=0 ReadOnly=1 """
This commit is contained in:
@@ -557,6 +557,14 @@ int transfer_read_definition(Transfer *t, const char *path) {
|
||||
return log_syntax(NULL, LOG_ERR, path, 1, SYNTHETIC_ERRNO(EINVAL),
|
||||
"Source specification lacks Path=.");
|
||||
|
||||
if (t->source.path_relative_to == PATH_RELATIVE_TO_EXPLICIT && !arg_transfer_source)
|
||||
return log_syntax(NULL, LOG_ERR, path, 1, SYNTHETIC_ERRNO(EINVAL),
|
||||
"PathRelativeTo=explicit requires --transfer-source= to be specified.");
|
||||
|
||||
if (t->target.path_relative_to == PATH_RELATIVE_TO_EXPLICIT)
|
||||
return log_syntax(NULL, LOG_ERR, path, 1, SYNTHETIC_ERRNO(EINVAL),
|
||||
"PathRelativeTo=explicit can only be used in source specifications.");
|
||||
|
||||
if (t->source.path) {
|
||||
if (RESOURCE_IS_FILESYSTEM(t->source.type) || t->source.type == RESOURCE_PARTITION)
|
||||
if (!path_is_absolute(t->source.path) || !path_is_normalized(t->source.path))
|
||||
@@ -618,11 +626,11 @@ int transfer_resolve_paths(
|
||||
|
||||
assert(t);
|
||||
|
||||
r = resource_resolve_path(&t->source, root, node);
|
||||
r = resource_resolve_path(&t->source, root, arg_transfer_source, node);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = resource_resolve_path(&t->target, root, node);
|
||||
r = resource_resolve_path(&t->target, root, /*relative_to_directory=*/ NULL, node);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user