Here is a patch that implements the -p option to cygcheck that was mentioned on
the list previously. It uses the WinInet API to hit the package-grep.cgi URL on
cygwin.com with the search regexp supplied by the user.
Rather than trying to parse the html output or requiring cygcheck to depend on
awk or something, I instead modified the cgi script to recognise an additional
parameter named 'plain'. If present in the request, the script replies with a
text/plain version of the results that cygcheck just copies to stdout.
Included in the patch is an update of the utils.sgml documentation for the new
parameter. As I understand it the man pages are created from this part of the
user's guide, so that should kill two birds with one stone.
I also document the new switch in the --help output. I took the liberty of
rewording it considerably, because the way that it described the options seemed
rather unintuitive -- there are certain combinations of allowed and unallowed
parameters, and rather than trying to explain for each switch which others it is
incompatible with, instead it gives a list of the acceptible forms of calling
the program. Here is the output after this patch:
$ cygcheck -h
Usage: cygcheck PROGRAM [ -v ] [ -h ]
cygcheck -c [ PACKAGE ] [ -d ]
cygcheck -s [ -r ] [ -v ] [ -h ]
cygcheck -k
cygcheck -f FILE [ FILE ... ]
cygcheck -l [ PACKAGE ] [ PACKAGE ... ]
cygcheck -p REGEXP
List system information, check installed packages, or query package database.
At least one command option or a PROGRAM is required, as shown above.
PROGRAM list library (DLL) dependencies of PROGRAM
-c, --check-setupshow installed version of PACKAGE and verify integrity
(or for all installed packages if none specified)
-d, --dump-only just list packages, do not verify (with -c)
-s, --sysinfoproduce 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
plain console only, not from a pty/rxvt/xterm)
-f, --find-package find the package that FILE belongs to
-l, --list-package list contents of PACKAGE (or all packages if none given)
-p, --package-query search for REGEXP in the entire cygwin.com package
repository (requies internet connectivity)
-v, --verboseproduce more verbose output
-h, --help annotate output with explanatory comments when given
with another command, otherwise print this help
-V, --versionprint the version of cygcheck and exit
Note: -c, -f, and -l only report on packages that are currently installed. To
search all official Cygwin packages use -p instead. The -p REGEXP matches
package names, descriptions, and names of files/paths within all packages.
The new --package-query command works more or less as you would expect.
Whatever you supply after -p is passed along to the CGI as if you'd entered it
in the web form. The only thing I changed was I omitted the directory name that
the package is in, so save a little bit of screen width. Here is a sample:
$ cygcheck -p 'cygintl-2\.dll'
Found 1 matches for 'cygintl-2\.dll'.
libintl2-0.12.1-3 GNU Internationalization runtime library
$ cygcheck -p 'libexpat.*\.a'
Found 2 matches for 'libexpat.*\.a'.
expat-1.95.7-1XML parser library written in C
expat-1.95.8-1XML parser library written in C
$ cygcheck -p '/ls\.exe'
Found 2 matches for '/ls\.exe'.
coreutils-5.2.1-5 GNU core utilities (includes fileutils, sh-utils and
textutils)
coreutils-5.3.0-6 GNU core utilities (includes fileutils, sh-utils and
textutils)
There is an additional unrelated bugfix that I included with this patch. The
bug was introduced with my patch to cygcheck that calls cygrunsrv. It did not
properly null-terminate the buffer that was read from popen(), which would
result in the strtok() loop erroniously calling "cygrunsrv --query "
after the last service. This resulted in an occasional spurious cygrunsrv error
to stdout if you ran "cygcheck -s" without -v. If the package-grep part of the
patch is not yet ready for primetime, I will resubmit just this fix by itself
since it's a pretty dumb bug.
I have tested the WinInet stuff on WinXP and Win98 and it seemed ok on both.
MSDN claims that this API exists as far back as Win95 and only requires IE 3.0.
I have tested the package-grep.cgi script locally.
In terms of error reporting cygcheck will emit an error if the HTTP response
code was not 200. It will also emit an error (and call FormatMessage to get a
textual version) if there is a problem connecting or resolving the domain.
Brian
winsup/utils:
2005-06-20 Brian Dessent <[EMAIL PROTECTED]>
* Makefile.in: Link cygcheck with libwininet.a.
* cygcheck.cc: Add