tools: add -n shortcut for --dry-run

Accept -n as a short option for --dry-run in bootctl,
systemd-oomd, systemd-sysusers, and systemd-tmpfiles.

For systemd-repart, make -n equivalent to --dry-run=yes,
while keeping --dry-run=BOOL available.

Follow-up for: 2479f0bb09
This commit is contained in:
dongshengyuan
2026-07-29 03:47:58 +09:00
committed by Yu Watanabe
parent efc207d7ab
commit f5ffb38606
16 changed files with 31 additions and 15 deletions
+5
View File
@@ -68,6 +68,11 @@ CHANGES WITH 262:
IPv4ProxyARP=yes but has no effect if IPv4ProxyARP= has been set to
false. This mirrors the behavior of IPv6ProxyNDPAddress=.
Changes in various tools:
* bootctl, systemd-oomd, systemd-repart, systemd-sysusers, and
systemd-tmpfiles now accept -n as a short option for --dry-run.
Changes in the TPM Subsystem:
* The way that NvPCRs are anchored has been improved. They are now
-1
View File
@@ -2739,7 +2739,6 @@ SPDX-License-Identifier: LGPL-2.1-or-later
- teach tmpfiles.d m/M to move / atomic move + symlink old -> new
- add new line type for setting btrfs subvolume attributes (i.e. rw/ro)
- tmpfiles: add new line type for setting fcaps
- add -n as shortcut for --dry-run in tmpfiles & sysusers & possibly other places
- add new line type for moving files from some source dir to some
target dir. then use that to move sysexts/confexts and stuff from initrd
tmpfs to /run/, so that host can pick things up.
+2 -1
View File
@@ -615,11 +615,12 @@
</varlistentry>
<varlistentry>
<term><option>-n</option></term>
<term><option>--dry-run</option></term>
<listitem><para>Dry run for <option>unlink</option> and <option>cleanup</option>.</para>
<para>In dry run mode, the unlink and cleanup operations only print the files that would get deleted
without actually deleting them.</para>
without actually deleting them. The short option <option>-n</option> was added in version 262.</para>
<xi:include href="version-info.xml" xpointer="v253"/></listitem>
</varlistentry>
+3 -1
View File
@@ -114,10 +114,12 @@
<variablelist>
<varlistentry>
<term><option>-n</option></term>
<term><option>--dry-run</option></term>
<listitem><para>Do a dry run of <command>systemd-oomd</command>: when a kill is triggered, print it
to the log instead of killing the cgroup.</para>
to the log instead of killing the cgroup. The short option <option>-n</option> was added in
version 262.</para>
<xi:include href="version-info.xml" xpointer="v253"/></listitem>
</varlistentry>
+3 -1
View File
@@ -171,13 +171,15 @@
<variablelist>
<varlistentry>
<term><option>-n</option></term>
<term><option>--dry-run=</option></term>
<listitem><para>Takes a boolean. If this switch is not specified, <option>--dry-run=yes</option> is
the implied default. Controls whether <filename>systemd-repart</filename> executes the requested
re-partition operations or whether it should only show what it would do. Unless
<option>--dry-run=no</option> is specified <filename>systemd-repart</filename> will not actually
touch the device's partition table.</para>
touch the device's partition table. The short option <option>-n</option> is equivalent to
<option>--dry-run=yes</option> and was added in version 262.</para>
<xi:include href="version-info.xml" xpointer="v245"/></listitem>
</varlistentry>
+2 -1
View File
@@ -127,9 +127,10 @@
</varlistentry>
<varlistentry>
<term><option>-n</option></term>
<term><option>--dry-run</option></term>
<listitem><para>Process the configuration and figure out what entries would be created, but do not
actually write anything.</para>
actually write anything. The short option <option>-n</option> was added in version 262.</para>
<xi:include href="version-info.xml" xpointer="v250"/></listitem>
</varlistentry>
+3 -1
View File
@@ -203,9 +203,11 @@
</varlistentry>
<varlistentry>
<term><option>-n</option></term>
<term><option>--dry-run</option></term>
<listitem><para>Process the configuration and print what operations would be performed, but do not
actually change anything in the file system.</para>
actually change anything in the file system. The short option <option>-n</option> was added in
version 262.</para>
<xi:include href="version-info.xml" xpointer="v256"/></listitem>
</varlistentry>
+1 -1
View File
@@ -612,7 +612,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
return r;
break;
OPTION_LONG("dry-run", NULL, "Dry run (unlink and cleanup)"):
OPTION('n', "dry-run", NULL, "Dry run (unlink and cleanup)"):
arg_dry_run = true;
break;
+2 -2
View File
@@ -62,8 +62,8 @@ static int parse_argv(int argc, char *argv[]) {
OPTION_COMMON_VERSION:
return version();
OPTION_LONG("dry-run", NULL,
"Only print destructive actions instead of doing them"):
OPTION('n', "dry-run", NULL,
"Only print destructive actions instead of doing them"):
arg_dry_run = true;
break;
+4
View File
@@ -10251,6 +10251,10 @@ static int parse_argv(int argc, char *argv[]) {
OPTION_GROUP("Operation"): {}
OPTION_SHORT('n', NULL, "Run dry-run operation"):
arg_dry_run = true;
break;
OPTION_LONG("dry-run", "BOOL",
"Whether to run dry-run operation"):
r = parse_boolean_argument("--dry-run=", opts.arg, &arg_dry_run);
+1 -1
View File
@@ -2182,7 +2182,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
arg_replace = opts.arg;
break;
OPTION_LONG("dry-run", NULL, "Just print what would be done"):
OPTION('n', "dry-run", NULL, "Just print what would be done"):
arg_dry_run = true;
break;
+1 -1
View File
@@ -4622,7 +4622,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
arg_replace = opts.arg;
break;
OPTION_LONG("dry-run", NULL, "Just print what would be done"):
OPTION('n', "dry-run", NULL, "Just print what would be done"):
arg_dry_run = true;
break;
+1 -1
View File
@@ -13,7 +13,7 @@ home='/somewhere'
dst='/tmp/L/1'
src="$home"
HOME="$home" \
systemd-tmpfiles --dry-run --create - <<EOF
systemd-tmpfiles -n --create - <<EOF
L $dst - - - - %h
EOF
test ! -h "$dst"
+1 -1
View File
@@ -249,7 +249,7 @@ PaddingMinBytes=92M
EOF
systemd-repart --definitions="$defs" \
--dry-run=yes \
-n \
--seed="$seed" \
--include-partitions=home,swap \
"-"
+1 -1
View File
@@ -34,7 +34,7 @@ root="$(mktemp -d)"
cred="$(mktemp -d)"
mkdir -p "$root/etc"
printf 'relative-shell' >"$cred/passwd.shell.creduser"
(! env CREDENTIALS_DIRECTORY="$cred" systemd-sysusers --dry-run --root="$root" --inline 'u creduser 999 "Cred User" / -')
(! env CREDENTIALS_DIRECTORY="$cred" systemd-sysusers -n --root="$root" --inline 'u creduser 999 "Cred User" / -')
(! env CREDENTIALS_DIRECTORY="$cred" systemd-sysusers --root="$root" --inline 'u creduser 999 "Cred User" / -')
(! grep -F creduser "$root/etc/passwd" >/dev/null 2>&1)
rm -rf "$root" "$cred"
+1 -1
View File
@@ -619,7 +619,7 @@ EOF
test -f "$ESP/$TOKEN/testuki.efi"
# --- Test 5: --dry-run leaves everything in place ---
"${BOOTCTL[@]}" --dry-run unlink "${TOKEN}-commit_30.conf"
"${BOOTCTL[@]}" -n unlink "${TOKEN}-commit_30.conf"
test -f "$ESP/loader/entries/${TOKEN}-commit_30.conf"
test -f "$ESP/$TOKEN/testuki.efi"