]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysupdate: include default component for feature-all 43154/head
authordongshengyuan <545258830@qq.com>
Sun, 26 Jul 2026 04:17:17 +0000 (12:17 +0800)
committerdongshengyuan <545258830@qq.com>
Sun, 26 Jul 2026 07:26:06 +0000 (15:26 +0800)
--component-all is documented to include the default component-less
installation. Do not drop it merely because the context operates on a
root/image, or because all its transfers are currently disabled by
features.

This lets --component-all --feature-all enable-feature write the
default component feature drop-ins instead of succeeding with no
components selected.

TEST-72-SYSUPDATE covers both all transfers disabled by features and
the same default component feature operation under --root=.

Repro: create a default feata.feature plus a transfer gated by feata,
then run:
build/systemd-sysupdate --root="$root" --component-all --feature-all enable-feature

Before: no drop-in was written.

Follow-up for: 4481661a75acc01b5d66aa36443a7b80b557e4ba

src/sysupdate/sysupdate.c
test/units/TEST-72-SYSUPDATE.sh

index 07f6f7ab777f6e835c0d27cd45ed3feae4cfb194..9ae80a2a8bf5df75d56a477c21b29881ea234992 100644 (file)
@@ -2949,15 +2949,13 @@ static int context_list_components(Context *context, char ***ret_component_names
         if (ret_component_names)
                 *ret_component_names = TAKE_PTR(z);
 
-        /* Does the system have at least one transfer file in /etc/sysupdate.d, which can be considered a
-         * TARGET_HOST? See target_get_argument() in sysupdated.c */
+        /* Does the system have at least one transfer file in sysupdate.d, which can be considered the
+         * default component-less installation? */
         if (ret_has_default_component)
                 *ret_has_default_component =
                         !context->definitions &&
                         !context->component &&
-                        !context->root &&
-                        !context->image &&
-                        context->n_transfers > 0;
+                        context->n_transfers + context->n_disabled_transfers > 0;
 
         return 0;
 }
index f1c4b951c9dbf570d51b826da356442d8b1c20a0..1ddb2ac9b9df4a1025cfacae8380a6c90567b320 100755 (executable)
@@ -1833,6 +1833,50 @@ assert_dropin "$(feat_enable_dropin_default featc)" yes
 test ! -e "$(feat_enable_dropin_default featb)"
 set_machine_tags ""
 
+# --component-all must still include the default component when all of its
+# transfers are currently disabled by features.
+compfeat_reset
+compfeat_source v1
+mkdir -p /run/sysupdate.d
+compfeat_transfer /run/sysupdate.d/50-feata.transfer feata "$CF/target-default" feata
+cat >/run/sysupdate.d/feata.feature <<EOF
+[Feature]
+Description=Feature A
+EOF
+"$SYSUPDATE" --component-all enable-feature --feature-all
+assert_dropin "$(feat_enable_dropin_default feata)" yes
+
+# --component-all must include the default component under --root= too.
+ROOT_FEATURE="$WORKDIR/root-feature"
+ROOT_FEATURE_ROOT="$ROOT_FEATURE/root"
+rm -rf "$ROOT_FEATURE"
+mkdir -p "$ROOT_FEATURE_ROOT/etc/sysupdate.d" \
+         "$ROOT_FEATURE_ROOT/source" \
+         "$ROOT_FEATURE_ROOT/target"
+cat >"$ROOT_FEATURE_ROOT/etc/sysupdate.d/50-feata.transfer" <<EOF
+[Transfer]
+Features=feata
+
+[Source]
+Type=regular-file
+Path=/source
+MatchPattern=feata-@v.bin
+
+[Target]
+Type=regular-file
+Path=/target
+MatchPattern=feata-@v.bin
+InstancesMax=2
+EOF
+cat >"$ROOT_FEATURE_ROOT/etc/sysupdate.d/feata.feature" <<EOF
+[Feature]
+Description=Feature A
+EOF
+"$SYSUPDATE" --root="$ROOT_FEATURE_ROOT" --component-all enable-feature --feature-all
+assert_dropin "$ROOT_FEATURE_ROOT$(feat_enable_dropin_default feata)" yes
+
+rm -rf "$ROOT_FEATURE"
+
 # ---------------------------------------------------------------------------
 # Features scoped to a named component, and across all components at once
 # ---------------------------------------------------------------------------