mirror of
https://github.com/systemd/systemd.git
synced 2024-10-27 01:55:22 +03:00
udevadm-verify: introduce --no-summary option
When udevadm verify is invoked by an analyzer tool like rpminspect to verify individual udev rules files, the summary just clutters the output, so provide an option to turn the summary off.
This commit is contained in:
parent
ddf0d5cc0d
commit
9e36da1541
@ -780,6 +780,13 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--no-summary</option></term>
|
||||
<listitem>
|
||||
<para>Do not show summary.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<xi:include href="standard-options.xml" xpointer="help" />
|
||||
</variablelist>
|
||||
</refsect2>
|
||||
|
@ -64,7 +64,7 @@ _udevadm() {
|
||||
[MONITOR_ARG]='-s --subsystem-match -t --tag-match'
|
||||
[TEST]='-a --action -N --resolve-names'
|
||||
[TEST_BUILTIN]='-a --action'
|
||||
[VERIFY]='-N --resolve-names --root'
|
||||
[VERIFY]='-N --resolve-names --root --no-summary'
|
||||
[WAIT]='-t --timeout --initialized=no --removed --settle'
|
||||
[LOCK]='-t --timeout -d --device -b --backing -p --print'
|
||||
)
|
||||
|
@ -109,6 +109,7 @@ _udevadm_verify(){
|
||||
_arguments \
|
||||
{-N+,--resolve-names=}'[When to resolve names.]:resolve:(early never)' \
|
||||
'--root=[Operate on catalog hierarchy under specified directory]:directories:_directories' \
|
||||
{--no-summary}'[Do not show summary.]' \
|
||||
{-h,--help}'[Print help text.]' \
|
||||
'*::files:_files'
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
static ResolveNameTiming arg_resolve_name_timing = RESOLVE_NAME_EARLY;
|
||||
static char *arg_root = NULL;
|
||||
static bool arg_summary = true;
|
||||
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
|
||||
|
||||
@ -37,6 +38,7 @@ static int help(void) {
|
||||
" -V --version Show package version\n"
|
||||
" -N --resolve-names=early|never When to resolve names\n"
|
||||
" --root=PATH Operate on an alternate filesystem root\n"
|
||||
" --no-summary Do not show summary\n"
|
||||
"\nSee the %s for details.\n",
|
||||
program_invocation_short_name,
|
||||
ansi_highlight(),
|
||||
@ -49,12 +51,14 @@ static int help(void) {
|
||||
static int parse_argv(int argc, char *argv[]) {
|
||||
enum {
|
||||
ARG_ROOT = 0x100,
|
||||
ARG_NO_SUMMARY,
|
||||
};
|
||||
static const struct option options[] = {
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, 'V' },
|
||||
{ "resolve-names", required_argument, NULL, 'N' },
|
||||
{ "root", required_argument, NULL, ARG_ROOT },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, 'V' },
|
||||
{ "resolve-names", required_argument, NULL, 'N' },
|
||||
{ "root", required_argument, NULL, ARG_ROOT },
|
||||
{ "no-summary", no_argument, NULL, ARG_NO_SUMMARY },
|
||||
{}
|
||||
};
|
||||
|
||||
@ -87,6 +91,9 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
break;
|
||||
case ARG_NO_SUMMARY:
|
||||
arg_summary = false;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
return -EINVAL;
|
||||
@ -172,16 +179,17 @@ static int verify_rules(UdevRules *rules, char **files) {
|
||||
|
||||
r = verify_rules_filelist(rules, files, &fail_count, &success_count, /* walk_dirs */ true);
|
||||
|
||||
printf("\n%s%zu udev rules files have been checked.%s\n"
|
||||
" Success: %zu\n"
|
||||
"%s Fail: %zu%s\n",
|
||||
ansi_highlight(),
|
||||
fail_count + success_count,
|
||||
ansi_normal(),
|
||||
success_count,
|
||||
fail_count > 0 ? ansi_highlight_red() : "",
|
||||
fail_count,
|
||||
fail_count > 0 ? ansi_normal() : "");
|
||||
if (arg_summary)
|
||||
printf("\n%s%zu udev rules files have been checked.%s\n"
|
||||
" Success: %zu\n"
|
||||
"%s Fail: %zu%s\n",
|
||||
ansi_highlight(),
|
||||
fail_count + success_count,
|
||||
ansi_normal(),
|
||||
success_count,
|
||||
fail_count > 0 ? ansi_highlight_red() : "",
|
||||
fail_count,
|
||||
fail_count > 0 ? ansi_normal() : "");
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -134,6 +134,8 @@ rm "${rules_dir}/loop.rules"
|
||||
# Empty rules.
|
||||
touch "${rules_dir}/empty.rules"
|
||||
assert_0 --root="${workdir}"
|
||||
: >"${exo}"
|
||||
assert_0 --root="${workdir}" --no-summary
|
||||
|
||||
# Directory with a single *.rules file.
|
||||
cp "${workdir}/default_output_1_success" "${exo}"
|
||||
|
Loading…
Reference in New Issue
Block a user