* [PATCH] Cygwin: Add '--names-only' flag to cygcheck
@ 2023-11-24 17:06 Jon Turney
2023-11-24 18:31 ` Corinna Vinschen
0 siblings, 1 reply; 3+ messages in thread
From: Jon Turney @ 2023-11-24 17:06 UTC (permalink / raw)
To: cygwin-patches; +Cc: Jon Turney
Add '--names-only' flag to cygcheck, to output just the bare package
names.
---
Notes:
Rather than more hacky aftermarket solutions, let's make cygcheck output
something more useful for feeding into setup.
Next step would be to adjust setup's argument parsing so 'setup -P
"$(cygcheck -n)"' works as expected.
winsup/utils/mingw/cygcheck.cc | 18 +++++++++++++-----
winsup/utils/mingw/dump_setup.cc | 17 +++++++++++------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/winsup/utils/mingw/cygcheck.cc b/winsup/utils/mingw/cygcheck.cc
index 9d6f19203..1dde2ecba 100644
--- a/winsup/utils/mingw/cygcheck.cc
+++ b/winsup/utils/mingw/cygcheck.cc
@@ -55,6 +55,7 @@ int givehelp = 0;
int keycheck = 0;
int check_setup = 0;
int dump_only = 0;
+int names_only = 0;
int find_package = 0;
int list_package = 0;
int grep_packages = 0;
@@ -84,7 +85,7 @@ typedef __int64 longlong;
#endif
/* In dump_setup.cc */
-void dump_setup (int, char **, bool);
+void dump_setup (int, char **, bool, bool);
void package_find (int, char **);
void package_list (int, char **);
/* In bloda.cc */
@@ -2913,7 +2914,8 @@ At least one command option or a PROGRAM is required, as shown above.\n\
PROGRAM list library (DLL) dependencies of PROGRAM\n\
-c, --check-setup show installed version of PACKAGE and verify integrity\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\
-r, --registry also scan registry for Cygwin settings (with -s)\n\
-k, --keycheck perform a keyboard check session (must be run from a\n\
@@ -2962,6 +2964,7 @@ Notes:\n\
struct option longopts[] = {
{"check-setup", no_argument, NULL, 'c'},
{"dump-only", no_argument, NULL, 'd'},
+ {"names-only", no_argument, NULL, 'n'},
{"sysinfo", no_argument, NULL, 's'},
{"registry", no_argument, NULL, 'r'},
{"verbose", no_argument, NULL, 'v'},
@@ -2985,7 +2988,7 @@ struct option longopts[] = {
{0, no_argument, NULL, 0}
};
-static char opts[] = "cdsrvkfliephV";
+static char opts[] = "cdnsrvkfliephV";
static void
print_version ()
@@ -3093,6 +3096,11 @@ main (int argc, char **argv)
case 'd':
dump_only = 1;
break;
+ case 'n':
+ check_setup = 1;
+ dump_only = 1;
+ names_only = 1;
+ break;
case 'r':
registry = 1;
break;
@@ -3205,7 +3213,7 @@ main (int argc, char **argv)
}
if (check_setup)
- dump_setup (verbose, argv, !dump_only);
+ dump_setup (verbose, argv, !dump_only, names_only);
else if (find_package)
package_find (verbose, argv);
else if (list_package)
@@ -3224,7 +3232,7 @@ main (int argc, char **argv)
if (!check_setup)
{
puts ("");
- dump_setup (verbose, NULL, !dump_only);
+ dump_setup (verbose, NULL, !dump_only, FALSE);
}
if (!givehelp)
diff --git a/winsup/utils/mingw/dump_setup.cc b/winsup/utils/mingw/dump_setup.cc
index 06aa06f81..050679a0d 100644
--- a/winsup/utils/mingw/dump_setup.cc
+++ b/winsup/utils/mingw/dump_setup.cc
@@ -466,11 +466,13 @@ get_installed_packages (char **argv, size_t *count)
}
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_installed_packages (argv);
- puts ("Cygwin Package Information");
+ if (!names_only)
+ puts ("Cygwin Package Information");
+
if (packages == NULL)
{
puts ("No setup information found");
@@ -484,12 +486,15 @@ dump_setup (int verbose, char **argv, bool check_files)
puts ("");
}
- printf ("%-*s %-*s%s\n", package_len, "Package",
- check_files ? version_len : 7, "Version",
- check_files ? " Status" : "");
+ if (!names_only)
+ printf ("%-*s %-*s%s\n", package_len, "Package",
+ check_files ? version_len : 7, "Version",
+ check_files ? " Status" : "");
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,
version_len, packages[i].ver,
check_package_files (verbose, packages[i].name)
--
2.42.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Cygwin: Add '--names-only' flag to cygcheck
2023-11-24 17:06 [PATCH] Cygwin: Add '--names-only' flag to cygcheck Jon Turney
@ 2023-11-24 18:31 ` Corinna Vinschen
2023-11-29 16:07 ` Jon Turney
0 siblings, 1 reply; 3+ messages in thread
From: Corinna Vinschen @ 2023-11-24 18:31 UTC (permalink / raw)
To: cygwin-patches
On Nov 24 17:06, Jon Turney wrote:
> Add '--names-only' flag to cygcheck, to output just the bare package
> names.
Push it!
> ---
>
> Notes:
> Rather than more hacky aftermarket solutions, let's make cygcheck output
> something more useful for feeding into setup.
>
> Next step would be to adjust setup's argument parsing so 'setup -P
> "$(cygcheck -n)"' works as expected.
Or cygcheck could just create a comma-separated list? Either way is fine.
Thanks,
Corinna
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Cygwin: Add '--names-only' flag to cygcheck
2023-11-24 18:31 ` Corinna Vinschen
@ 2023-11-29 16:07 ` Jon Turney
0 siblings, 0 replies; 3+ messages in thread
From: Jon Turney @ 2023-11-29 16:07 UTC (permalink / raw)
To: Corinna Vinschen, Cygwin Patches
On 24/11/2023 18:31, Corinna Vinschen wrote:
> On Nov 24 17:06, Jon Turney wrote:
>> Add '--names-only' flag to cygcheck, to output just the bare package
>> names.
>
> Push it!
>
I added changes to the manpage to document this option as well, before
pushing it.
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-29 16:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-24 17:06 [PATCH] Cygwin: Add '--names-only' flag to cygcheck Jon Turney
2023-11-24 18:31 ` Corinna Vinschen
2023-11-29 16:07 ` Jon Turney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).