Cygwin: Add '--names-only' flag to cygcheck

Add '--names-only' flag to cygcheck, to output just the bare package
names.

(cherry picked from commit 127166f707)
This commit is contained in:
Jon Turney 2023-11-24 16:17:05 +00:00
parent 3b617528e7
commit 736e7c709b
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
3 changed files with 31 additions and 15 deletions

View File

@ -118,6 +118,7 @@
<command>cygcheck</command> <command>cygcheck</command>
<arg choice="plain">-c</arg> <arg choice="plain">-c</arg>
<arg>-d</arg> <arg>-d</arg>
<arg>-n</arg>
<arg><replaceable>PACKAGE</replaceable></arg> <arg><replaceable>PACKAGE</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
@ -166,7 +167,8 @@ At least one command option or a PROGRAM is required, as shown above.
PROGRAM list library (DLL) dependencies of PROGRAM PROGRAM list library (DLL) dependencies of PROGRAM
-c, --check-setup show installed version of PACKAGE and verify integrity -c, --check-setup show installed version of PACKAGE and verify integrity
(or for all installed packages if none specified) (or for all installed packages if none specified)
-d, --dump-only just list packages, do not verify (with -c) -d, --dump-only do not verify packages (with -c)
-n, --names-only just list package names (implies -c -d)
-s, --sysinfo produce diagnostic system information (implies -c -d) -s, --sysinfo produce diagnostic system information (implies -c -d)
-r, --registry also scan registry for Cygwin settings (with -s) -r, --registry also scan registry for Cygwin settings (with -s)
-k, --keycheck perform a keyboard check session (must be run from a -k, --keycheck perform a keyboard check session (must be run from a
@ -196,7 +198,7 @@ Note: -c, -f, and -l only report on packages that are currently installed. To
dealing with Cygwin programs. If you are familiar with dealing with Cygwin programs. If you are familiar with
<command>dpkg</command> or <command>rpm</command>, <command>dpkg</command> or <command>rpm</command>,
<command>cygcheck</command> is similar in many ways. (The major <command>cygcheck</command> is similar in many ways. (The major
difference is that <command>setup.exe</command> handles installing and difference is that <command>setup</command> handles installing and
uninstalling packages; see <xref linkend="internet-setup"/> for more uninstalling packages; see <xref linkend="internet-setup"/> for more
information.) </para> information.) </para>
<para> The <literal>-c</literal> option checks the version and status of <para> The <literal>-c</literal> option checks the version and status of
@ -205,11 +207,12 @@ Note: -c, -f, and -l only report on packages that are currently installed. To
with no arguments it lists all packages. A package will be marked with no arguments it lists all packages. A package will be marked
<literal>Incomplete</literal> if files originally installed are no longer <literal>Incomplete</literal> if files originally installed are no longer
present. The best thing to do in that situation is reinstall the package present. The best thing to do in that situation is reinstall the package
with <command>setup.exe</command>. To see which files are missing, use with <command>setup</command>. To see which files are missing, use
the <literal>-v</literal> option. If you do not need to know the status the <literal>-v</literal> option. If you do not need to know the status
of each package and want <command>cygcheck</command> to run faster, add of each package and want <command>cygcheck</command> to run faster, add
the <literal>-d</literal> option and <command>cygcheck</command> will the <literal>-d</literal> option and <command>cygcheck</command> will
only output the name and version for each package. </para> only output the name and version for each package. Add the
<literal>-n</literal> option to output only the names of packages. </para>
<para> If you list one or more programs on the command line, <para> If you list one or more programs on the command line,
<command>cygcheck</command> will diagnose the runtime environment of that <command>cygcheck</command> will diagnose the runtime environment of that
program or programs, providing the names of DLL files on which the program or programs, providing the names of DLL files on which the

View File

@ -42,6 +42,7 @@ int givehelp = 0;
int keycheck = 0; int keycheck = 0;
int check_setup = 0; int check_setup = 0;
int dump_only = 0; int dump_only = 0;
int names_only = 0;
int find_package = 0; int find_package = 0;
int list_package = 0; int list_package = 0;
int grep_packages = 0; int grep_packages = 0;
@ -56,7 +57,7 @@ typedef __int64 longlong;
#endif #endif
/* In dump_setup.cc */ /* In dump_setup.cc */
void dump_setup (int, char **, bool); void dump_setup (int, char **, bool, bool);
void package_find (int, char **); void package_find (int, char **);
void package_list (int, char **); void package_list (int, char **);
/* In bloda.cc */ /* In bloda.cc */
@ -2113,7 +2114,8 @@ At least one command option or a PROGRAM is required, as shown above.\n\
PROGRAM list library (DLL) dependencies of PROGRAM\n\ PROGRAM list library (DLL) dependencies of PROGRAM\n\
-c, --check-setup show installed version of PACKAGE and verify integrity\n\ -c, --check-setup show installed version of PACKAGE and verify integrity\n\
(or for all installed packages if none specified)\n\ (or for all installed packages if none specified)\n\
-d, --dump-only just list packages, do not verify (with -c)\n\ -d, --dump-only do not verify packages (with -c)\n\
-n, --names-only just list package names (implies -c -d)\n\
-s, --sysinfo produce diagnostic system information (implies -c)\n\ -s, --sysinfo produce diagnostic system information (implies -c)\n\
-r, --registry also scan registry for Cygwin settings (with -s)\n\ -r, --registry also scan registry for Cygwin settings (with -s)\n\
-k, --keycheck perform a keyboard check session (must be run from a\n\ -k, --keycheck perform a keyboard check session (must be run from a\n\
@ -2141,6 +2143,7 @@ Note: -c, -f, and -l only report on packages that are currently installed. To\n\
struct option longopts[] = { struct option longopts[] = {
{"check-setup", no_argument, NULL, 'c'}, {"check-setup", no_argument, NULL, 'c'},
{"dump-only", no_argument, NULL, 'd'}, {"dump-only", no_argument, NULL, 'd'},
{"names-only", no_argument, NULL, 'n'},
{"sysinfo", no_argument, NULL, 's'}, {"sysinfo", no_argument, NULL, 's'},
{"registry", no_argument, NULL, 'r'}, {"registry", no_argument, NULL, 'r'},
{"verbose", no_argument, NULL, 'v'}, {"verbose", no_argument, NULL, 'v'},
@ -2154,7 +2157,7 @@ struct option longopts[] = {
{0, no_argument, NULL, 0} {0, no_argument, NULL, 0}
}; };
static char opts[] = "cdsrvkflphV"; static char opts[] = "cdnsrvkflphV";
static void static void
print_version () print_version ()
@ -2266,6 +2269,11 @@ main (int argc, char **argv)
case 'd': case 'd':
dump_only = 1; dump_only = 1;
break; break;
case 'n':
check_setup = 1;
dump_only = 1;
names_only = 1;
break;
case 'r': case 'r':
registry = 1; registry = 1;
break; break;
@ -2348,7 +2356,7 @@ main (int argc, char **argv)
} }
if (check_setup) if (check_setup)
dump_setup (verbose, argv, !dump_only); dump_setup (verbose, argv, !dump_only, names_only);
else if (find_package) else if (find_package)
package_find (verbose, argv); package_find (verbose, argv);
else if (list_package) else if (list_package)
@ -2367,7 +2375,7 @@ main (int argc, char **argv)
if (!check_setup) if (!check_setup)
{ {
puts (""); puts ("");
dump_setup (verbose, NULL, !dump_only); dump_setup (verbose, NULL, !dump_only, FALSE);
} }
if (!givehelp) if (!givehelp)

View File

@ -468,11 +468,13 @@ get_packages (char **argv)
} }
void void
dump_setup (int verbose, char **argv, bool check_files) dump_setup (int verbose, char **argv, bool check_files, bool names_only)
{ {
pkgver *packages = get_packages(argv); pkgver *packages = get_packages(argv);
if (!names_only)
puts ("Cygwin Package Information"); puts ("Cygwin Package Information");
if (packages == NULL) if (packages == NULL)
{ {
puts ("No setup information found"); puts ("No setup information found");
@ -486,12 +488,15 @@ dump_setup (int verbose, char **argv, bool check_files)
puts (""); puts ("");
} }
if (!names_only)
printf ("%-*s %-*s%s\n", package_len, "Package", printf ("%-*s %-*s%s\n", package_len, "Package",
check_files ? version_len : 7, "Version", check_files ? version_len : 7, "Version",
check_files ? " Status" : ""); check_files ? " Status" : "");
for (int i = 0; packages[i].name; i++) for (int i = 0; packages[i].name; i++)
{ {
if (check_files) if (names_only)
printf ("%s\n", packages[i].name);
else if (check_files)
printf ("%-*s %-*s%s\n", package_len, packages[i].name, printf ("%-*s %-*s%s\n", package_len, packages[i].name,
version_len, packages[i].ver, version_len, packages[i].ver,
check_package_files (verbose, packages[i].name) check_package_files (verbose, packages[i].name)