importd: teach all backends --system/--user mode

The runtime scope logic is internally already in place, let's expose
this via getopt() command line too. This way importd later can propagate
the invocation scope down to the backends.
This commit is contained in:
Lennart Poettering
2025-08-18 09:12:27 +02:00
parent 570366b6e1
commit b76a76ac15
4 changed files with 60 additions and 4 deletions

View File

@@ -207,7 +207,9 @@ static int help(int argc, char *argv[], void *userdata) {
" --version Show package version\n"
" --format=FORMAT Select format\n"
" --class=CLASS Select image class (machine, sysext, confext,\n"
" portable)\n",
" portable)\n"
" --system Operate in per-system mode\n"
" --user Operate in per-user mode\n",
program_invocation_short_name,
ansi_underline(),
ansi_normal(),
@@ -223,6 +225,8 @@ static int parse_argv(int argc, char *argv[]) {
ARG_VERSION = 0x100,
ARG_FORMAT,
ARG_CLASS,
ARG_SYSTEM,
ARG_USER,
};
static const struct option options[] = {
@@ -230,6 +234,8 @@ static int parse_argv(int argc, char *argv[]) {
{ "version", no_argument, NULL, ARG_VERSION },
{ "format", required_argument, NULL, ARG_FORMAT },
{ "class", required_argument, NULL, ARG_CLASS },
{ "system", no_argument, NULL, ARG_SYSTEM },
{ "user", no_argument, NULL, ARG_USER },
{}
};
@@ -262,6 +268,14 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_SYSTEM:
arg_runtime_scope = RUNTIME_SCOPE_SYSTEM;
break;
case ARG_USER:
arg_runtime_scope = RUNTIME_SCOPE_USER;
break;
case '?':
return -EINVAL;

View File

@@ -280,7 +280,9 @@ static int help(int argc, char *argv[], void *userdata) {
" subvolume\n"
" --sync=BOOL Controls whether to sync() before completing\n"
" --class=CLASS Select image class (machine, sysext, confext,\n"
" portable)\n",
" portable)\n"
" --system Operate in per-system mode\n"
" --user Operate in per-user mode\n",
program_invocation_short_name,
ansi_underline(),
ansi_normal(),
@@ -302,6 +304,8 @@ static int parse_argv(int argc, char *argv[]) {
ARG_BTRFS_QUOTA,
ARG_SYNC,
ARG_CLASS,
ARG_SYSTEM,
ARG_USER,
};
static const struct option options[] = {
@@ -315,6 +319,8 @@ static int parse_argv(int argc, char *argv[]) {
{ "btrfs-quota", required_argument, NULL, ARG_BTRFS_QUOTA },
{ "sync", required_argument, NULL, ARG_SYNC },
{ "class", required_argument, NULL, ARG_CLASS },
{ "system", no_argument, NULL, ARG_SYSTEM },
{ "user", no_argument, NULL, ARG_USER },
{}
};
@@ -377,6 +383,14 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_SYSTEM:
arg_runtime_scope = RUNTIME_SCOPE_SYSTEM;
break;
case ARG_USER:
arg_runtime_scope = RUNTIME_SCOPE_USER;
break;
case '?':
return -EINVAL;

View File

@@ -290,7 +290,9 @@ static int help(int argc, char *argv[], void *userdata) {
" --offset=BYTES Offset to seek to in destination\n"
" --size-max=BYTES Maximum number of bytes to write to destination\n"
" --class=CLASS Select image class (machine, sysext, confext,\n"
" portable)\n",
" portable)\n"
" --system Operate in per-system mode\n"
" --user Operate in per-user mode\n",
program_invocation_short_name,
ansi_underline(),
ansi_normal(),
@@ -315,6 +317,8 @@ static int parse_argv(int argc, char *argv[]) {
ARG_OFFSET,
ARG_SIZE_MAX,
ARG_CLASS,
ARG_SYSTEM,
ARG_USER,
};
static const struct option options[] = {
@@ -331,6 +335,8 @@ static int parse_argv(int argc, char *argv[]) {
{ "offset", required_argument, NULL, ARG_OFFSET },
{ "size-max", required_argument, NULL, ARG_SIZE_MAX },
{ "class", required_argument, NULL, ARG_CLASS },
{ "system", no_argument, NULL, ARG_SYSTEM },
{ "user", no_argument, NULL, ARG_USER },
{}
};
@@ -430,6 +436,14 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_SYSTEM:
arg_runtime_scope = RUNTIME_SCOPE_SYSTEM;
break;
case ARG_USER:
arg_runtime_scope = RUNTIME_SCOPE_USER;
break;
case '?':
return -EINVAL;

View File

@@ -275,7 +275,9 @@ static int help(int argc, char *argv[], void *userdata) {
" --class=CLASS Select image class (machine, sysext, confext,\n"
" portable)\n"
" --keep-download=BOOL Keep a copy pristine copy of the downloaded file\n"
" around\n",
" around\n"
" --system Operate in per-system mode\n"
" --user Operate in per-user mode\n",
program_invocation_short_name,
ansi_underline(),
ansi_normal(),
@@ -306,6 +308,8 @@ static int parse_argv(int argc, char *argv[]) {
ARG_SIZE_MAX,
ARG_CLASS,
ARG_KEEP_DOWNLOAD,
ARG_SYSTEM,
ARG_USER,
};
static const struct option options[] = {
@@ -328,6 +332,8 @@ static int parse_argv(int argc, char *argv[]) {
{ "size-max", required_argument, NULL, ARG_SIZE_MAX },
{ "class", required_argument, NULL, ARG_CLASS },
{ "keep-download", required_argument, NULL, ARG_KEEP_DOWNLOAD },
{ "system", no_argument, NULL, ARG_SYSTEM },
{ "user", no_argument, NULL, ARG_USER },
{}
};
@@ -508,6 +514,14 @@ static int parse_argv(int argc, char *argv[]) {
auto_keep_download = false;
break;
case ARG_SYSTEM:
arg_runtime_scope = RUNTIME_SCOPE_SYSTEM;
break;
case ARG_USER:
arg_runtime_scope = RUNTIME_SCOPE_USER;
break;
case '?':
return -EINVAL;