importd: add support for downloading sysext/confext/portable images too

This adds "Ex" versions of all bus calls import implements, that make
two changes:

1. A "class" parameter is added that allows choosing between
   machine/sysext/confext/portable images to download. Depending on the
   chose class the target directory is selected differently (i.e. not
   just /var/lib/machines/, but alternatively /var/lib/portables/,
   /var/lib/extensions/, /var/lib/confexts/.

2. The boolean flags are replaced by a 64bit flags parameter.
This commit is contained in:
Lennart Poettering
2024-03-01 22:25:42 +01:00
parent 83d7411209
commit 7af5785d77
15 changed files with 473 additions and 106 deletions
+16 -4
View File
@@ -23,6 +23,7 @@
#include "verbs.h"
static ImportCompressType arg_compress = IMPORT_COMPRESS_UNKNOWN;
static ImageClass arg_class = IMAGE_MACHINE;
static void determine_compression_from_filename(const char *p) {
@@ -63,7 +64,7 @@ static int export_tar(int argc, char *argv[], void *userdata) {
int r, fd;
if (hostname_is_valid(argv[1], 0)) {
r = image_find(IMAGE_MACHINE, argv[1], NULL, &image);
r = image_find(arg_class, argv[1], NULL, &image);
if (r == -ENOENT)
return log_error_errno(r, "Machine image %s not found.", argv[1]);
if (r < 0)
@@ -135,7 +136,7 @@ static int export_raw(int argc, char *argv[], void *userdata) {
int r, fd;
if (hostname_is_valid(argv[1], 0)) {
r = image_find(IMAGE_MACHINE, argv[1], NULL, &image);
r = image_find(arg_class, argv[1], NULL, &image);
if (r == -ENOENT)
return log_error_errno(r, "Machine image %s not found.", argv[1]);
if (r < 0)
@@ -190,14 +191,16 @@ static int export_raw(int argc, char *argv[], void *userdata) {
static int help(int argc, char *argv[], void *userdata) {
printf("%1$s [OPTIONS...] {COMMAND} ...\n"
"\n%4$sExport container or virtual machine images.%5$s\n"
"\n%4$sExport disk images.%5$s\n"
"\n%2$sCommands:%3$s\n"
" tar NAME [FILE] Export a TAR image\n"
" raw NAME [FILE] Export a RAW image\n"
"\n%2$sOptions:%3$s\n"
" -h --help Show this help\n"
" --version Show package version\n"
" --format=FORMAT Select format\n",
" --format=FORMAT Select format\n"
" --class=CLASS Select image class (machine, sysext, confext,\n"
" portable)\n",
program_invocation_short_name,
ansi_underline(),
ansi_normal(),
@@ -212,12 +215,14 @@ static int parse_argv(int argc, char *argv[]) {
enum {
ARG_VERSION = 0x100,
ARG_FORMAT,
ARG_CLASS,
};
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
{ "format", required_argument, NULL, ARG_FORMAT },
{ "class", required_argument, NULL, ARG_CLASS },
{}
};
@@ -250,6 +255,13 @@ static int parse_argv(int argc, char *argv[]) {
"Unknown format: %s", optarg);
break;
case ARG_CLASS:
arg_class = image_class_from_string(optarg);
if (arg_class < 0)
return log_error_errno(arg_class, "Failed to parse --class= argument: %s", optarg);
break;
case '?':
return -EINVAL;