diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-02-22 18:50:32 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-03-01 22:25:42 +0100 |
commit | b146afc4492e083e8f08301285b88f7202e93052 (patch) | |
tree | dd6b6785dd72fb19ed9007f396f32ed2867ed3ea /src/import/importd.c | |
parent | importd: validate local image names with the right helper (diff) | |
download | systemd-b146afc4492e083e8f08301285b88f7202e93052.tar.xz systemd-b146afc4492e083e8f08301285b88f7202e93052.zip |
importd: make keeping pristine copy of downloaded images optional
Previously, when downloading an image, importd would first download them
into one image which it would then consider immutable (named after the
originating URL/etag), and then immediately make a copy of it (named
after the client chosen name).
This makes some sense in VM/container cases where the images are
typically mutable, and thus the original downloaded copy is of some
value.
For sysexts/confexts/portable this doesn't make much sense though, as
they are typically immutable. Hence make the concept optional.
This adds --keep-download=yes/no as a new option that controls the
above. Moreover it disables the behaviour for all image classes but
"machine". The behaviour remains enabled for "machine", for compat.
Diffstat (limited to 'src/import/importd.c')
-rw-r--r-- | src/import/importd.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/import/importd.c b/src/import/importd.c index 41c329b0f2..a07ceb2288 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -386,6 +386,7 @@ static int transfer_start(Transfer *t) { NULL, /* verify argument */ NULL, /* --class= */ NULL, /* class argument */ + NULL, /* --keep-download= */ NULL, /* maybe --force */ NULL, /* maybe --read-only */ NULL, /* if so: the actual URL */ @@ -466,6 +467,10 @@ static int transfer_start(Transfer *t) { cmd[k++] = image_class_to_string(t->class); } + if (IN_SET(t->type, TRANSFER_PULL_TAR, TRANSFER_PULL_RAW)) + cmd[k++] = FLAGS_SET(t->flags, IMPORT_PULL_KEEP_DOWNLOAD) ? + "--keep-download=yes" : "--keep-download=no"; + if (FLAGS_SET(t->flags, IMPORT_FORCE)) cmd[k++] = "--force"; if (FLAGS_SET(t->flags, IMPORT_READ_ONLY)) @@ -1041,7 +1046,7 @@ static int method_pull_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_er return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Image class '%s' not known", sclass); - if (flags & ~(IMPORT_FORCE|IMPORT_READ_ONLY)) + if (flags & ~(IMPORT_FORCE|IMPORT_READ_ONLY|IMPORT_PULL_KEEP_DOWNLOAD)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Flags 0x%" PRIx64 " invalid", flags); } else { |