I have been experimenting with Cygwin attempting to get a "bare-bones", minimal install. I do find that installing utilities like grep, gawk, sed and similar tools has dependencies on cygwin, base-Cygwin and sometimes unwanted tools like bash, coreutils etc., I have not attempted to completely understand why this dependency exists, but that's not my goal. I wanted to get only the tools and their required dlls installed and started examining the Cygwin package. I discovered that not using the setup.exe supplied by Cygwin is an alternative way to accomplish minimal Cygwin installs. And this is how I got it done.
- Use the setup.exe supplied by Cygwin to download all the packages - download only and no install.
- Once the download is successfully completed, individual packages like zlib, gawk, grep, libiconv are found under the x86/release or x86_64/release directory.
- Each package is 'tar'red and compressed using tool 'xz' or bzip and stored in respective directories.
To install a specific tool like sed or gawk, all that needs to be done, is to extract the tool executable and its dependencies (.dll)
Before you attempt the following, please ensure you have a tool like
7z.exe, xz.exe, bzip2 or other that is capable of uncompressing an
.xz or bzip archive
Installing gawk example below :
- Extract gawk.exe from gawk-4.1.3-1.tar.xz archive using the command - 7z.exe e -so gawk-4.1.3-1.tar.xz | tar xvf -
- Once that is done, you should find gawk.exe in a subfolder usually, usr/bin under the release/gawk folder
- Find the dependencies for gawk - you can do this in a couple of ways.
Examine the Cygwin setup.ini file found in x86 or x86_64 folder. Look for the string '@ gawk' and in the lines after this line you should find a "requires:" line that lists the dependencies.
Mine reads like this - "requires: bash cygwin libgmp10 libintl8 libmpfr4 libreadline7"
For gawk to run, bash is not a must since we have the windows command shell. (bash is included to get a few other dlls required by gawk. However, that causes a lot more unnecessary files to be installed). The other dependencies contain files that gawk needs to run. Extract each of the above packages using tools like 7z or xz into individual files.
After all the dependencies are extracted, copy your needed tool(s) (grep/sed/gawk) to a folder and all the dependent .dlls You should now be able to run your tool with the minimum set of .dlls required in a bare-bones cygwin installation.
Caution : It may not be sufficient to just extract the dependencies listed in setup.ini for each tool. Sometimes, you may need to execute/run the tool to discover that there are more dlls required.
There are other means of finding out the dlls required by an exe - you can use dumpbin from MS or dependency walker, ndepends or similar tools to find the list of dependent dlls
Consult - https://stackoverflow.com/questions/362560/how-do-i-detect-the-dlls-required-by-an-application https://stackoverflow.com/questions/475148/how-do-i-find-out-which-dlls-an-executable-will-load
I also brute forced the dependent dll info by just running the tool and installing the missing dlls listed one by one by extracting from the required packages.
When you run a exe and if it errors out with a missing .dll message, search for the package that contains the dll here - https://cygwin.com/cgi-bin2/package-grep.cgi . Enter the full/partial name of the missing dll to find the name of the package containing the dll.
Eventually, I have ended up with a bare-bones cygwin install with only the tools and dlls that I need. Example : gawk - gawk.exe and the following dlls - cygwin1.dll, cyggmp-10.dll, cygiconv-2.dll, cygintl-8.dll, cygmpfr-4.dll, cyggcc_s-seh-1.dll, cygncursesw-10.dll, cygreadline7.dll
sed - sed.exe and dlls - cygwin1.dll, cygintl-8.dll
Hope this is found useful. The Cywin installer also does dll re-basing, which I will not venture into here