From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id B1842385AC2E; Wed, 29 Nov 2023 14:36:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1842385AC2E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1701268580; bh=9ql/SMkVULH+5wSkMQClfktCjFq63XuoYxetFlNB9PI=; h=From:To:Subject:Date:From; b=dWtVP5UZHw21u4U7t9qNGD5kK9igbRTatAhoyR4Eo3EBeYx0hAHh/n9QflZwkte72 fakG3Ka5P3nOeVljDtUX02zGS4AXa0A/qW73nvnpbYgN29tk7i3MkGyIyDdl/3uali VliO8cHaknZW/P03R4gRYw15zfk0JX52eMqmvNeg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jon Turney To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: Add '--names-only' flag to cygcheck X-Act-Checkin: newlib-cygwin X-Git-Author: Jon Turney X-Git-Refname: refs/heads/main X-Git-Oldrev: 5f15d7c5817b07a6b18cbab17342c95cb7b42be4 X-Git-Newrev: 127166f7070f67a3b322e72119df8a547fd1f85d Message-Id: <20231129143620.B1842385AC2E@sourceware.org> Date: Wed, 29 Nov 2023 14:36:20 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D127166f7070= f67a3b322e72119df8a547fd1f85d commit 127166f7070f67a3b322e72119df8a547fd1f85d Author: Jon Turney Date: Fri Nov 24 16:17:05 2023 +0000 Cygwin: Add '--names-only' flag to cygcheck =20 Add '--names-only' flag to cygcheck, to output just the bare package names. Diff: --- winsup/doc/utils.xml | 11 +++++++---- winsup/utils/mingw/cygcheck.cc | 18 +++++++++++++----- winsup/utils/mingw/dump_setup.cc | 17 +++++++++++------ 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/winsup/doc/utils.xml b/winsup/doc/utils.xml index 0390db20f..ad17c9796 100644 --- a/winsup/doc/utils.xml +++ b/winsup/doc/utils.xml @@ -135,6 +135,7 @@ cygcheck -c -d + -n PACKAGE @@ -201,7 +202,8 @@ At least one command option or a PROGRAM is required, a= s shown above. PROGRAM list library (DLL) dependencies of PROGRAM -c, --check-setup show installed version of PACKAGE and verify integr= ity (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) -r, --registry also scan registry for Cygwin settings (with -s) -k, --keycheck perform a keyboard check session (must be run from a @@ -251,7 +253,7 @@ Notes: dealing with Cygwin programs. If you are familiar with dpkg or rpm, cygcheck is similar in many ways. (The major - difference is that setup.exe handles installing a= nd + difference is that setup handles installing and uninstalling packages; see for mo= re information.) The -c option checks the version and status = of @@ -260,11 +262,12 @@ Notes: with no arguments it lists all packages. A package will be marked Incomplete if files originally installed are no l= onger present. The best thing to do in that situation is reinstall the pac= kage - with setup.exe. To see which files are missing, u= se + with setup. To see which files are missing, use the -v option. If you do not need to know the sta= tus of each package and want cygcheck to run faster, = add the -d option and cygcheck will - only output the name and version for each package. + only output the name and version for each package. Add the + -n option to output only the names of packages. <= /para> If you list one or more programs on the command line, cygcheck will diagnose the runtime environment of= that program or programs, providing the names of DLL files on which the 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 =3D 0; int keycheck =3D 0; int check_setup =3D 0; int dump_only =3D 0; +int names_only =3D 0; int find_package =3D 0; int list_package =3D 0; int grep_packages =3D 0; @@ -84,7 +85,7 @@ typedef __int64 longlong; #endif =20 /* 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 integr= ity\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[] =3D { {"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[] =3D { {0, no_argument, NULL, 0} }; =20 -static char opts[] =3D "cdsrvkfliephV"; +static char opts[] =3D "cdnsrvkfliephV"; =20 static void print_version () @@ -3093,6 +3096,11 @@ main (int argc, char **argv) case 'd': dump_only =3D 1; break; + case 'n': + check_setup =3D 1; + dump_only =3D 1; + names_only =3D 1; + break; case 'r': registry =3D 1; break; @@ -3205,7 +3213,7 @@ main (int argc, char **argv) } =20 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); } =20 if (!givehelp) diff --git a/winsup/utils/mingw/dump_setup.cc b/winsup/utils/mingw/dump_set= up.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) } =20 void -dump_setup (int verbose, char **argv, bool check_files) +dump_setup (int verbose, char **argv, bool check_files, bool names_only) { pkgver *packages =3D get_installed_packages (argv); =20 - puts ("Cygwin Package Information"); + if (!names_only) + puts ("Cygwin Package Information"); + if (packages =3D=3D NULL) { puts ("No setup information found"); @@ -484,12 +486,15 @@ dump_setup (int verbose, char **argv, bool check_file= s) puts (""); } =20 - 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 =3D 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)