Skip to content

Commit f8b4ae2

Browse files
committed
condition: allow overriding of ConditionNeedsUpdate= on the kernel command line
This should be useful for addressing systemd#15724.
1 parent 3931056 commit f8b4ae2

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

man/kernel-command-line.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,15 @@
436436
will not query the user for basic system settings, even if the system boots up for the first time and the
437437
relevant settings are not initialized yet.</para></listitem>
438438
</varlistentry>
439+
440+
<varlistentry>
441+
<term><varname>systemd.condition-needs-update=</varname></term>
442+
443+
<listitem><para>Takes a boolean argument. If specified, overrides the result of
444+
<varname>ConditionNeedsUpdate=</varname> unit condition checks. See
445+
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
446+
details.</para></listitem>
447+
</varlistentry>
439448
</variablelist>
440449

441450
</refsect1>

man/systemd-update-done.service.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
<citerefentry project='man-pages'><refentrytitle>touch</refentrytitle><manvolnum>1</manvolnum></citerefentry>
5959
on it.</para>
6060

61+
<para>Note that if the <varname>systemd.condition-needs-update=</varname> kernel command line option is
62+
used it overrides the <varname>ConditionNeedsUpdate=</varname> unit condition checks. In that case
63+
<filename>systemd-update-done.service</filename> will not reset the condition state until a follow-up
64+
reboot where the kernel switch is not specified anymore.</para>
6165
</refsect1>
6266

6367
<refsect1>

man/systemd.unit.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,13 @@
12941294
<citerefentry><refentrytitle>systemd-update-done.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
12951295
to make sure they run before the stamp file's modification time gets reset indicating a completed
12961296
update.</para>
1297+
1298+
<para>If the <varname>systemd.condition-needs-update=</varname> option is specified on the kernel
1299+
command line (taking a boolean), it will override the result of this condition check, taking
1300+
precedence over any file modification time checks. If it is used
1301+
<filename>systemd-update-done.service</filename> will not have immediate effect on any following
1302+
<varname>ConditionNeedsUpdate=</varname> checks, until the system is rebooted where the kernel
1303+
command line option is not specified anymore.</para>
12971304
</listitem>
12981305
</varlistentry>
12991306

src/shared/condition.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,19 @@ static int condition_test_capability(Condition *c, char **env) {
548548
static int condition_test_needs_update(Condition *c, char **env) {
549549
struct stat usr, other;
550550
const char *p;
551+
bool b;
551552
int r;
552553

553554
assert(c);
554555
assert(c->parameter);
555556
assert(c->type == CONDITION_NEEDS_UPDATE);
556557

558+
r = proc_cmdline_get_bool("systemd.condition-needs-update", &b);
559+
if (r < 0)
560+
log_debug_errno(r, "Failed to parse systemd.condition-needs-update= kernel command line argument, ignoring: %m");
561+
if (r > 0)
562+
return b;
563+
557564
if (!path_is_absolute(c->parameter)) {
558565
log_debug("Specified condition parameter '%s' is not absolute, assuming an update is needed.", c->parameter);
559566
return true;

0 commit comments

Comments
 (0)