How to find which cygwin package contains a particular file

cygwin - finding dependencies, file and package information

I always forget the commands so, a blog seem in order. The cygcheck program is a cygwin application allowing to gather information on files, packages or query package database. A few examples are below:

How to find from which package the program 'more.exe' belong to?

There are  afew ways to do this. The simplest is

% which more   # find where it is
/usr/bin/more.exe
% cygcheck -f /usr/bin/more.exe
util-linux-2.17.2-1

But if you are not sure which more.exe need to be checked, you may want to use the following instead.

% cygcheck -p more.exe
Found 8 matches for more.exe
bvi/bvi-1.3.2-1	Binary vi-like editor
qt4-qtdemo/qt4-qtdemo-4.5.3-1	Qt4 demos and examples
util-linux/util-linux-2.13.1-2	Random collection of Linux utilities
util-linux/util-linux-2.14.1-1	Random collection of Linux utilities
util-linux/util-linux-2.17.2-1	Random collection of Linux utilities
xmore/xmore-1.0.1-2	X.Org plain text browser
xmore/xmore-1.0.2-1	X.Org plain text browser
xorg-x11-bin/xorg-x11-bin-6.8.99.901-1	Obsolete package

OK, several answers come above (since -p was used, a REGEXP on more.exe) but you may infer the package is util-linux (the rest are derivatives, xmore.exe for example is installed as /usr/X11R6/bin/xmore.exe and matches more.exe). In other words, the answer is not always straight forward.

Now, this example has a single answer

% cygcheck -p less.exe
Found 2 matches for less.exe
less/less-436-1	A file pager program, similar to more(1)
less/less-444-1	A file pager program, similar to more(1)

Only the less package has this program (two revisions shows up in the query as a regexp was used). Note the answer with -f would provide your installed package version as single answer

% cygcheck -f /usr/bin/less.exe
less-444-1

Important Note: cygcheck actually requires an outgoing network connection to the cygwin web site. Essentially, it will POST a query to

http://cygwin.com/cgi-bin2/package-grep.cgi

 

How to find dependencies of more.exe?

Without the -p, the simple command would give different information on the more.exe executable.

% cygcheck more.exe
Found: F:\cygwin\bin\more.exe
F:\cygwin\bin\more.exe
  F:\cygwin\bin\cyggcc_s-1.dll
    F:\cygwin\bin\cygwin1.dll
      C:\Windows\system32\KERNEL32.dll
        C:\Windows\system32\API-MS-Win-Core-RtlSupport-L1-1-0.dll
        C:\Windows\system32\ntdll.dll
        C:\Windows\system32\KERNELBASE.dll
        C:\Windows\system32\API-MS-Win-Core-ProcessThreads-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Heap-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Memory-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Handle-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Synch-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-File-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-IO-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-ThreadPool-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-LibraryLoader-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-NamedPipe-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Misc-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-SysInfo-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Localization-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-ProcessEnvironment-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-String-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Debug-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-ErrorHandling-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Fibers-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Util-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Profile-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Security-Base-L1-1-0.dll
  F:\cygwin\bin\cygintl-8.dll
    F:\cygwin\bin\cygiconv-2.dll
  F:\cygwin\bin\cygncursesw-10.dll

In this command, all depencies (.dll) of more.exe are showed. If any of those are updated, it may influence the behavior of your program. If any is missing, it may stop working entirely. You may also use the '-v' command line option for the verbose mode (it shows the dll version information).

Which brings to ...

 

How to check if a package is properly installed?

Now that we know more.exe is part of the util-linux package, let us check if this package is properly installed. This can be done by issuing the command:

% cygcheck -c util-linux
Cygwin Package Information
Package              Version        Status
util-linux           2.17.2-1       OK

In this case, the package is all fine and properly installed. Here is an example of a package I had corrupt

% cygcheck -c gdbm
Cygwin Package Information
Package              Version        Status
gdbm                 1.8.3-20       Incomplete

Hum ... now, what is missing? The simplest is to re-install the package and try again.

OK, now you are curious and want to know what is installed from util-linux or the less package

How do I list the files installed by a package?

The -l command line option does this for you.

% cygcheck -l less
/usr/bin/less.exe
/usr/bin/lessecho.exe
/usr/bin/lesskey.exe
/usr/share/man/man1/less.1.gz
/usr/share/man/man1/lessecho.1.gz
/usr/share/man/man1/lesskey.1.gz

You can do the same for util-linux (the list is much longer so, will skip for this help). But you may also check the executables it has installed just like this

% cygcheck -l util-linux | grep bin  # this will include bin and sbin
/usr/bin/cal.exe
/usr/bin/chkdupexe
/usr/bin/col.exe
/usr/bin/colcrt.exe
/usr/bin/colrm.exe
/usr/bin/column.exe
/usr/bin/ddate.exe
/usr/bin/flock.exe
/usr/bin/getopt.exe
/usr/bin/hexdump.exe
/usr/bin/ipcmk.exe
/usr/bin/isosize.exe
/usr/bin/line.exe
/usr/bin/logger.exe
/usr/bin/look.exe
/usr/bin/mcookie.exe
/usr/bin/more.exe
/usr/bin/namei.exe
/usr/bin/pg.exe
/usr/bin/rename.exe
/usr/bin/renice.exe
/usr/bin/rev.exe
/usr/bin/script.exe
/usr/bin/scriptreplay.exe
/usr/bin/setsid.exe
/usr/bin/tailf.exe
/usr/bin/ul.exe
/usr/bin/uuidgen.exe
/usr/bin/whereis.exe
/usr/sbin/agetty.exe
/usr/sbin/blkid.exe
/usr/sbin/cfdisk.exe
/usr/sbin/fdisk.exe
/usr/sbin/findfs.exe
/usr/sbin/fsck.cramfs.exe
/usr/sbin/fsck.exe
/usr/sbin/fsck.minix.exe
/usr/sbin/mkfs.bfs.exe
/usr/sbin/mkfs.cramfs.exe
/usr/sbin/mkfs.exe
/usr/sbin/mkfs.minix.exe
/usr/sbin/mkswap.exe
/usr/sbin/sfdisk.exe
/usr/sbin/uuidd.exe
/usr/sbin/wipefs.exe
Verifying your cygwin installation integrity

The command

% cygcheck -s -v -r

Will generate an extensive report - this how I did find that my package gdbm was corrupt - the report told specifically

Missing file: /usr/lib/gdbm/testdbm.exe from package gdbm
Missing file: /usr/lib/gdbm/testgdbm.exe from package gdbm
Missing file: /usr/lib/gdbm/testndbm.exe from package gdbm
gdbm                           1.8.3-20             Incomplete

which shows exactly what is missing. You can repair by re-installing the package from setup.exe but in some cases, you may need to first locate all files from that package, remove using setup.exe, check it is removed from a command line (and remove if files remain) and re-install. I noticed that if the signature of a file is not the same as the one from the package iniitally installed, the update or re-install would not override it (hence a forced deletion from the command line is needed).

More information?

This quick help is not meant to be complete. For more information, please go to the cygwin utilities manpage on the cygwin site.