|
|
ac3a84 |
From 79c16ad7a09623b987a50a0d04a61fed41e45a77 Mon Sep 17 00:00:00 2001
|
|
|
ac3a84 |
From: Mike Yuan <me@yhndnzj.com>
|
|
|
ac3a84 |
Date: Sun, 27 Nov 2022 21:18:44 +0800
|
|
|
ac3a84 |
Subject: [PATCH] systemctl: allow suppress the warning of no install info
|
|
|
ac3a84 |
using --no-warn
|
|
|
ac3a84 |
|
|
|
ac3a84 |
In cases like packaging scripts, it might be desired to use
|
|
|
ac3a84 |
enable/disable on units without install info. So, adding an
|
|
|
ac3a84 |
option '--no-warn' to suppress the warning.
|
|
|
ac3a84 |
|
|
|
ac3a84 |
(cherry picked from commit 108d35ac7d435b4f1378a9c0fa50858263475e09)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Related: #2141979
|
|
|
ac3a84 |
---
|
|
|
ac3a84 |
man/systemctl.xml | 18 ++++++++++++++++--
|
|
|
ac3a84 |
src/systemctl/systemctl-enable.c | 2 +-
|
|
|
ac3a84 |
src/systemctl/systemctl.c | 9 +++++++++
|
|
|
ac3a84 |
src/systemctl/systemctl.h | 1 +
|
|
|
ac3a84 |
4 files changed, 27 insertions(+), 3 deletions(-)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
diff --git a/man/systemctl.xml b/man/systemctl.xml
|
|
|
ac3a84 |
index f743c182fe..d909dc4db4 100644
|
|
|
ac3a84 |
--- a/man/systemctl.xml
|
|
|
ac3a84 |
+++ b/man/systemctl.xml
|
|
|
ac3a84 |
@@ -771,6 +771,9 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
|
|
|
ac3a84 |
account.
|
|
|
ac3a84 |
</para>
|
|
|
ac3a84 |
|
|
|
ac3a84 |
+ <para>When using this operation on units without install information, a warning about it is shown.
|
|
|
ac3a84 |
+ <option>--no-warn</option> can be used to suppress the warning.</para>
|
|
|
ac3a84 |
+
|
|
|
ac3a84 |
<para>Enabling units should not be confused with starting (activating) units, as done by the
|
|
|
ac3a84 |
<command>start</command> command. Enabling and starting units is orthogonal: units may be enabled without
|
|
|
ac3a84 |
being started and started without being enabled. Enabling simply hooks the unit into various suggested
|
|
|
ac3a84 |
@@ -814,8 +817,8 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
|
|
|
ac3a84 |
executed. This output may be suppressed by passing <option>--quiet</option>.
|
|
|
ac3a84 |
</para>
|
|
|
ac3a84 |
|
|
|
ac3a84 |
- <para>This command honors <option>--system</option>, <option>--user</option>, <option>--runtime</option>
|
|
|
ac3a84 |
- and <option>--global</option> in a similar way as <command>enable</command>.</para>
|
|
|
ac3a84 |
+ <para>This command honors <option>--system</option>, <option>--user</option>, <option>--runtime</option>,
|
|
|
ac3a84 |
+ <option>--global</option> and <option>--no-warn</option> in a similar way as <command>enable</command>.</para>
|
|
|
ac3a84 |
</listitem>
|
|
|
ac3a84 |
</varlistentry>
|
|
|
ac3a84 |
|
|
|
ac3a84 |
@@ -1997,6 +2000,17 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
|
|
|
ac3a84 |
</listitem>
|
|
|
ac3a84 |
</varlistentry>
|
|
|
ac3a84 |
|
|
|
ac3a84 |
+ <varlistentry>
|
|
|
ac3a84 |
+ <term><option>--no-warn</option></term>
|
|
|
ac3a84 |
+
|
|
|
ac3a84 |
+ <listitem>
|
|
|
ac3a84 |
+ <para>Don't generate the warning shown by default when using
|
|
|
ac3a84 |
+ <command>enable</command> or <command>disable</command> on units
|
|
|
ac3a84 |
+ without install information (i.e. don't have or have an empty
|
|
|
ac3a84 |
+ [Install] section).</para>
|
|
|
ac3a84 |
+ </listitem>
|
|
|
ac3a84 |
+ </varlistentry>
|
|
|
ac3a84 |
+
|
|
|
ac3a84 |
<varlistentry>
|
|
|
ac3a84 |
<term><option>--no-block</option></term>
|
|
|
ac3a84 |
|
|
|
ac3a84 |
diff --git a/src/systemctl/systemctl-enable.c b/src/systemctl/systemctl-enable.c
|
|
|
ac3a84 |
index aea66872de..86d9f602fa 100644
|
|
|
ac3a84 |
--- a/src/systemctl/systemctl-enable.c
|
|
|
ac3a84 |
+++ b/src/systemctl/systemctl-enable.c
|
|
|
ac3a84 |
@@ -67,7 +67,7 @@ int verb_enable(int argc, char *argv[], void *userdata) {
|
|
|
ac3a84 |
InstallChange *changes = NULL;
|
|
|
ac3a84 |
size_t n_changes = 0;
|
|
|
ac3a84 |
int carries_install_info = -1;
|
|
|
ac3a84 |
- bool ignore_carries_install_info = arg_quiet;
|
|
|
ac3a84 |
+ bool ignore_carries_install_info = arg_quiet || arg_no_warn;
|
|
|
ac3a84 |
int r;
|
|
|
ac3a84 |
|
|
|
ac3a84 |
if (!argv[1])
|
|
|
ac3a84 |
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
|
|
|
ac3a84 |
index 91954d91e6..57e9966d3c 100644
|
|
|
ac3a84 |
--- a/src/systemctl/systemctl.c
|
|
|
ac3a84 |
+++ b/src/systemctl/systemctl.c
|
|
|
ac3a84 |
@@ -83,6 +83,7 @@ bool arg_show_types = false;
|
|
|
ac3a84 |
int arg_check_inhibitors = -1;
|
|
|
ac3a84 |
bool arg_dry_run = false;
|
|
|
ac3a84 |
bool arg_quiet = false;
|
|
|
ac3a84 |
+bool arg_no_warn = false;
|
|
|
ac3a84 |
bool arg_full = false;
|
|
|
ac3a84 |
bool arg_recursive = false;
|
|
|
ac3a84 |
bool arg_with_dependencies = false;
|
|
|
ac3a84 |
@@ -276,6 +277,8 @@ static int systemctl_help(void) {
|
|
|
ac3a84 |
" kexec, suspend, hibernate, suspend-then-hibernate,\n"
|
|
|
ac3a84 |
" hybrid-sleep, default, rescue, emergency, and exit.\n"
|
|
|
ac3a84 |
" -q --quiet Suppress output\n"
|
|
|
ac3a84 |
+ " --no-warn Don't generate warning when trying to enable/disable\n"
|
|
|
ac3a84 |
+ " units without install information\n"
|
|
|
ac3a84 |
" --wait For (re)start, wait until service stopped again\n"
|
|
|
ac3a84 |
" For is-system-running, wait until startup is completed\n"
|
|
|
ac3a84 |
" --no-block Do not wait until operation finished\n"
|
|
|
ac3a84 |
@@ -432,6 +435,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
|
|
|
ac3a84 |
ARG_READ_ONLY,
|
|
|
ac3a84 |
ARG_MKDIR,
|
|
|
ac3a84 |
ARG_MARKED,
|
|
|
ac3a84 |
+ ARG_NO_WARN,
|
|
|
ac3a84 |
};
|
|
|
ac3a84 |
|
|
|
ac3a84 |
static const struct option options[] = {
|
|
|
ac3a84 |
@@ -464,6 +468,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
|
|
|
ac3a84 |
{ "no-wall", no_argument, NULL, ARG_NO_WALL },
|
|
|
ac3a84 |
{ "dry-run", no_argument, NULL, ARG_DRY_RUN },
|
|
|
ac3a84 |
{ "quiet", no_argument, NULL, 'q' },
|
|
|
ac3a84 |
+ { "no-warn", no_argument, NULL, ARG_NO_WARN },
|
|
|
ac3a84 |
{ "root", required_argument, NULL, ARG_ROOT },
|
|
|
ac3a84 |
{ "image", required_argument, NULL, ARG_IMAGE },
|
|
|
ac3a84 |
{ "force", no_argument, NULL, 'f' },
|
|
|
ac3a84 |
@@ -925,6 +930,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
|
|
|
ac3a84 |
arg_marked = true;
|
|
|
ac3a84 |
break;
|
|
|
ac3a84 |
|
|
|
ac3a84 |
+ case ARG_NO_WARN:
|
|
|
ac3a84 |
+ arg_no_warn = true;
|
|
|
ac3a84 |
+ break;
|
|
|
ac3a84 |
+
|
|
|
ac3a84 |
case '.':
|
|
|
ac3a84 |
/* Output an error mimicking getopt, and print a hint afterwards */
|
|
|
ac3a84 |
log_error("%s: invalid option -- '.'", program_invocation_name);
|
|
|
ac3a84 |
diff --git a/src/systemctl/systemctl.h b/src/systemctl/systemctl.h
|
|
|
ac3a84 |
index 2454c4c714..1a7a6e28d3 100644
|
|
|
ac3a84 |
--- a/src/systemctl/systemctl.h
|
|
|
ac3a84 |
+++ b/src/systemctl/systemctl.h
|
|
|
ac3a84 |
@@ -65,6 +65,7 @@ extern bool arg_show_types;
|
|
|
ac3a84 |
extern int arg_check_inhibitors;
|
|
|
ac3a84 |
extern bool arg_dry_run;
|
|
|
ac3a84 |
extern bool arg_quiet;
|
|
|
ac3a84 |
+extern bool arg_no_warn;
|
|
|
ac3a84 |
extern bool arg_full;
|
|
|
ac3a84 |
extern bool arg_recursive;
|
|
|
ac3a84 |
extern bool arg_with_dependencies;
|