From: dongshengyuan <545258830@qq.com> Date: Tue, 28 Jul 2026 11:59:25 +0000 (+0800) Subject: tools: add -n shortcut for --dry-run X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5ffb3860627f5a12951ab3a6759b038fa37e73b;p=thirdparty%2Fsystemd.git 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: 2479f0bb095d9e9f9c56c8110efc87fe0b0f59c0 --- diff --git a/NEWS b/NEWS index 5e451eb82c4..1c6e644137a 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/TODO.md b/TODO.md index 190788aab0d..689bcf8549a 100644 --- a/TODO.md +++ b/TODO.md @@ -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. diff --git a/man/bootctl.xml b/man/bootctl.xml index bf5d2bf2309..ab003ddaf10 100644 --- a/man/bootctl.xml +++ b/man/bootctl.xml @@ -615,11 +615,12 @@ + Dry run for and . In dry run mode, the unlink and cleanup operations only print the files that would get deleted - without actually deleting them. + without actually deleting them. The short option was added in version 262. diff --git a/man/systemd-oomd.service.xml b/man/systemd-oomd.service.xml index 9d04c9da98d..9c735a9383e 100644 --- a/man/systemd-oomd.service.xml +++ b/man/systemd-oomd.service.xml @@ -114,10 +114,12 @@ + Do a dry run of systemd-oomd: when a kill is triggered, print it - to the log instead of killing the cgroup. + to the log instead of killing the cgroup. The short option was added in + version 262. diff --git a/man/systemd-repart.xml b/man/systemd-repart.xml index fa7b282bc0e..c8955e8ee23 100644 --- a/man/systemd-repart.xml +++ b/man/systemd-repart.xml @@ -171,13 +171,15 @@ + Takes a boolean. If this switch is not specified, is the implied default. Controls whether systemd-repart executes the requested re-partition operations or whether it should only show what it would do. Unless is specified systemd-repart will not actually - touch the device's partition table. + touch the device's partition table. The short option is equivalent to + and was added in version 262. diff --git a/man/systemd-sysusers.xml b/man/systemd-sysusers.xml index c7210d13cc3..6a6d8c907db 100644 --- a/man/systemd-sysusers.xml +++ b/man/systemd-sysusers.xml @@ -127,9 +127,10 @@ + Process the configuration and figure out what entries would be created, but do not - actually write anything. + actually write anything. The short option was added in version 262. diff --git a/man/systemd-tmpfiles.xml b/man/systemd-tmpfiles.xml index 8a4e56cc134..4fd276019dc 100644 --- a/man/systemd-tmpfiles.xml +++ b/man/systemd-tmpfiles.xml @@ -203,9 +203,11 @@ + Process the configuration and print what operations would be performed, but do not - actually change anything in the file system. + actually change anything in the file system. The short option was added in + version 262. diff --git a/src/bootctl/bootctl.c b/src/bootctl/bootctl.c index 7956b01ffcf..d28b0f3f3e4 100644 --- a/src/bootctl/bootctl.c +++ b/src/bootctl/bootctl.c @@ -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; diff --git a/src/oom/oomd.c b/src/oom/oomd.c index 62eecfc065c..7f1a4d0550c 100644 --- a/src/oom/oomd.c +++ b/src/oom/oomd.c @@ -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; diff --git a/src/repart/repart.c b/src/repart/repart.c index ae41fc0d2e5..77fa5b7c3bd 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -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); diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 8eb1ae13c59..9c52bce66bd 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -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; diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 464384b22bd..28a4c9a9870 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -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; diff --git a/test/units/TEST-22-TMPFILES.15.sh b/test/units/TEST-22-TMPFILES.15.sh index 78be11357df..5080e85c172 100755 --- a/test/units/TEST-22-TMPFILES.15.sh +++ b/test/units/TEST-22-TMPFILES.15.sh @@ -13,7 +13,7 @@ home='/somewhere' dst='/tmp/L/1' src="$home" HOME="$home" \ -systemd-tmpfiles --dry-run --create - <"$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" diff --git a/test/units/TEST-87-AUX-UTILS-VM.bootctl.sh b/test/units/TEST-87-AUX-UTILS-VM.bootctl.sh index c91211e8f8f..b35ab3e695f 100755 --- a/test/units/TEST-87-AUX-UTILS-VM.bootctl.sh +++ b/test/units/TEST-87-AUX-UTILS-VM.bootctl.sh @@ -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"