RedSoft
RedSoft

Reputation: 371

Minimal Cygwin installation + Perl + Gcc

I would like to have a specific Cygwin installation as one zip-file archive in order to deploy then on different Windows PCs. After investigating the problem the suggested way to perform this is "trial-and-error" Cygwin installation and packages choosing (What packages should I install with Cygwin to make it not bloated but also have everything I would need as a developer?) May be more concrete requirement will help: I need minimal Cygwin installation + Perl + famous Perl libraries (Win32::API, etc) + GNU make + Gcc compilation tools. Which packages should I select when installing Cygwin?

Upvotes: 1

Views: 2395

Answers (2)

Agnatha
Agnatha

Reputation: 31

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 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.

  1. Download only the packages you want from any of the Cygwin mirror sites using ftp or http. Alternatively you can use the setup.exe supplied by Cygwin to download all the packages - download only and no install.
  2. 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.
  3. 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 :

  1. 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 -
  2. Once that is done, you should find gawk.exe in a subfolder usually, usr/bin under the release/gawk folder
  3. 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 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 unecessary 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 - How do I detect the DLLs required by an application? How do I find out which dlls an executable will load?

I also brute forced this 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 tool and 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.

Upvotes: 1

golimar
golimar

Reputation: 2548

With Cygwin's dependence system, you should just make a new installation, unselect every package, and then select Perl, make and gcc, and it will install only the required packages for that. I think some of the dependent packages are just recommended and not required, but the Cygwin installer conveniently marks them as recommended.

Upvotes: 0

Related Questions