]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysupdate: add feature select
authorLennart Poettering <lennart@amutable.com>
Wed, 24 Jun 2026 15:55:01 +0000 (17:55 +0200)
committerLennart Poettering <lennart@amutable.com>
Mon, 13 Jul 2026 15:36:10 +0000 (17:36 +0200)
Prepartion for the next commit: also allow selecting the all or
suggested features.

src/sysupdate/sysupdate.c
src/sysupdate/sysupdate.h

index 5ecc919ebdb9b4969d160aeb908a89fe6d07e75a..f334756b9f8f549541e28a0390b6782006995117 100644 (file)
@@ -65,6 +65,7 @@ static char *arg_root = NULL;
 static char *arg_image = NULL;
 static bool arg_reboot = false;
 static int arg_cleanup = -1;
+static SelectMode arg_feature_select = SELECT_EXPLICIT;
 static char *arg_component = NULL;
 static SelectMode arg_component_select = SELECT_EXPLICIT;
 static int arg_verify = -1;
@@ -144,6 +145,7 @@ static int context_from_cmdline(Context *ret) {
         context.offline = arg_offline;
         context.cleanup = arg_cleanup;
         context.component_select = arg_component_select;
+        context.feature_select = arg_feature_select;
 
         if (strdup_to(&context.definitions, arg_definitions) < 0)
                 return log_oom();
@@ -185,6 +187,7 @@ static int context_from_base_with_component(const Context *base, const char *com
         context.verify = base->verify;
         context.offline = base->offline;
         context.cleanup = base->cleanup;
+        context.feature_select = base->feature_select;
 
         if (strdup_to(&context.root, base->root) < 0)
                 return log_oom();
@@ -1763,6 +1766,8 @@ static int verb_list(int argc, char *argv[], uintptr_t _data, void *userdata) {
         if (r < 0)
                 return r;
 
+        if (context.feature_select != SELECT_EXPLICIT)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--feature-all/--feature-suggested is not supported for '%s'.", argv[0]);
         if (context.component_select != SELECT_EXPLICIT)
                 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "--component-all/--component-suggested currently not supported for '%s'.", argv[0]);
 
@@ -1839,6 +1844,8 @@ static int verb_features(int argc, char *argv[], uintptr_t _data, void *userdata
         if (r < 0)
                 return r;
 
+        if (context.feature_select != SELECT_EXPLICIT)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--feature-all/--feature-suggested is not supported for '%s'.", argv[0]);
         if (context.component_select != SELECT_EXPLICIT)
                 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "--component-all/--component-suggested currently not supported for '%s'.", argv[0]);
 
@@ -2031,6 +2038,8 @@ static int verb_enable_feature(int argc, char *argv[], uintptr_t _data, void *us
         if (r < 0)
                 return r;
 
+        if (context.feature_select != SELECT_EXPLICIT)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--feature-all/--feature-suggested is not supported for '%s'.", argv[0]);
         if (context.component_select != SELECT_EXPLICIT)
                 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "--component-all currently not supported for '%s'.", argv[0]);
 
@@ -2090,6 +2099,8 @@ static int verb_check_new(int argc, char *argv[], uintptr_t _data, void *userdat
         if (r < 0)
                 return r;
 
+        if (context.feature_select != SELECT_EXPLICIT)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--feature-all/--feature-suggested is not supported for '%s'.", argv[0]);
         if (context.component_select != SELECT_EXPLICIT)
                 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "--component-all/--component-suggested currently not supported for '%s'.", argv[0]);
 
@@ -2195,6 +2206,8 @@ static int verb_update_impl(int argc, char **argv, UpdateActionFlags action_flag
         if (r < 0)
                 return r;
 
+        if (context.feature_select != SELECT_EXPLICIT)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--feature-all/--feature-suggested is not supported for '%s'.", argv[0]);
         if (context.component_select != SELECT_EXPLICIT)
                 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "--component-all/--component-suggested currently not supported for '%s'.", argv[0]);
 
@@ -2309,6 +2322,8 @@ static int verb_vacuum(int argc, char *argv[], uintptr_t _data, void *userdata)
         if (r < 0)
                 return r;
 
+        if (context.feature_select != SELECT_EXPLICIT)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--feature-all/--feature-suggested is not supported for '%s'.", argv[0]);
         if (context.component_select != SELECT_EXPLICIT)
                 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "--component-all/--component-suggested currently not supported for '%s'.", argv[0]);
 
@@ -2340,6 +2355,8 @@ static int verb_cleanup(int argc, char *argv[], uintptr_t _data, void *userdata)
         if (context.cleanup == 0)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invocation of 'cleanup' with --cleanup=no is contradictory, refusing.");
 
+        if (context.feature_select != SELECT_EXPLICIT)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--feature-all/--feature-suggested is not supported for '%s'.", argv[0]);
         if (!IN_SET(context.component_select, SELECT_EXPLICIT, SELECT_ALL))
                 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "--component-suggested currently not supported for '%s'.", argv[0]);
 
@@ -2405,6 +2422,8 @@ static int verb_pending_or_reboot(int argc, char *argv[], uintptr_t _data, void
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                        "The --root=/--image= switches may not be combined with the '%s' operation.", argv[0]);
 
+        if (context.feature_select != SELECT_EXPLICIT)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--feature-all/--feature-suggested is not supported for '%s'.", argv[0]);
         if (context.component || context.component_select != SELECT_EXPLICIT)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                        "The --component=, --component-all and --component-suggested switches may not be combined with the '%s' operation, which only applies to the booted OS version.", argv[0]);
@@ -2510,6 +2529,8 @@ static int verb_components(int argc, char *argv[], uintptr_t _data, void *userda
         if (r < 0)
                 return r;
 
+        if (context.feature_select != SELECT_EXPLICIT)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--feature-all/--feature-suggested is not supported for '%s'.", argv[0]);
         if (context.component_select != SELECT_EXPLICIT)
                 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "--component-all/--component-suggested currently not supported for '%s'.", argv[0]);
         if (context.definitions)
@@ -2630,6 +2651,8 @@ static int verb_enable_component(int argc, char *argv[], uintptr_t _data, void *
         if (r < 0)
                 return r;
 
+        if (context.feature_select != SELECT_EXPLICIT)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--feature-all/--feature-suggested is not supported for '%s'.", argv[0]);
         if (context.definitions)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                        "The --definitions= switch may not be combined with '%s'.", argv[0]);
@@ -2851,6 +2874,14 @@ static int parse_argv(int argc, char *argv[], char ***remaining_args) {
                         arg_component_select = SELECT_SUGGESTED;
                         break;
 
+                OPTION('a', "feature-all", NULL, "Select all features"):
+                        arg_feature_select = SELECT_ALL;
+                        break;
+
+                OPTION('s', "feature-suggested", NULL, "Select all suggested features"):
+                        arg_feature_select = SELECT_SUGGESTED;
+                        break;
+
                 OPTION_LONG("definitions", "DIR",
                             "Find transfer definitions in specified directory"):
                         r = parse_path_argument(opts.arg, /* suppress_root= */ false, &arg_definitions);
index f0e25a239dbf1d830a2d2154a045c27413b3ad2b..1930367093596514b42547f5480d92da1970816a 100644 (file)
@@ -23,6 +23,7 @@ typedef struct Context {
         int cleanup;
         char *component;
         SelectMode component_select;
+        SelectMode feature_select;
         int verify;
         ImagePolicy *image_policy;
         bool offline;