Import & Export Cygwin List of installed Packages

If you want to go from 32 to 64 bit [Cygwin]( but keep all the packages ((At least those that are available.)), you might find yourself in a spot where you would like to export the list of cygwin packages and also be able to install cygwin with all these packages again. I will tell you how. Open your Cygwin shell and enter
grep " 1$" /etc/setup/installed.db | awk '{print $1}' > packagelist
This will dump a list of all *selected* packages and is the kind contribution of Yamakuzure-san. Earlier, I had proposed the following command:
cygcheck -c -d | sed -e "1,2d" -e 's/ .*$//' > packagelist
which will simply dump a list of *installed* packages, including all the dependencies (possibly cluttering up your cygwin backup file). In the comments below you'll see that my command worked better in one case. If you decide to try both, leave a comment about how they performed for you. To install Cygwin 64 from such a package file, download [setup-x86_64]( Of course, this will also work with the old [setup-x86.exe]( if you are reading this just for the sake backing up your cygwin install configuration. Execute the installer with the command line parameters
./setup-x86_64 -P `awk 'NR==1{printf $1}{printf ",%s", $1}' packagelist`
The **awk** command reads your file and turns it into a comma-separated list, then this string is passed as the argument to the **-P** option of the installer. It may not be documented with great detail in the [Cygwin installer command-line options](, but CSV is exactly what the **-P** option expects. Since you might want to use **cygcheck** to backup your cygwin-install, you might not have **awk** and a bash shell at your disposal at the time of install. However, you should certainly have some kind of python installed already. Here is a python script that will read your packages correctly and install cygwin with them selected:
from urllib import request
import sys, getopt, subprocess
build = 'x86'
packagefile = 'packagelist'
opts, args = getopt.getopt(sys.argv[1:],'',['64','packages='])
for o,a in opts:
    if o == '--64': build = 'x86_64'
    if o == '--packages':
        packagefile = a
setupfile = "setup-%s.exe" % build
packages = ','.join([ x.strip() for x in open(packagefile).readlines()])
r = request.urlopen("" % setupfile)
open(setupfile,'wb').write([setupfile, '-P', packages ])
In fact, it first downloads the current setup executable from the cygwin server and then launches it. It accepts the option --64 to install 64 bit cygwin and the option --packages=packagelist to select a file with a list of packages.

15 Replies to “Import & Export Cygwin List of installed Packages”

  1. Poor man's awk: load the cygcheck-generated package list into Calc or any other spreadsheet. Select all packages, cut, and transpose paste (all packages are now in one row, one package per column). Now save the file as .csv using commas as delimiters.
  2. Thank you for this. My awk did not like the backslashes before dollars, had to change \\$1 to $1. I am trying to install all packages on a system that are installed on one another. Instead of wondering where to get awk on the new system, I created the file with all packages separated by comma on the machine with cygwin itself.
  3. Thanks for putting up these instructions, was a real time saver for helping me keep multiple Cygwin installations up-to-date. Modified the process slightly, I made a shell script to generate a batch file that runs setup-x86_64.exe with all the package files. No AWK or Python required on the target system where I want to install Cygwin:
    echo -n "setup-x86_64.exe -P " > update.bat
    cygcheck -c -d | sed -e "1,2d" -e 's/ .*$//' | awk 'NR==1{printf \$1}{printf ",%s", \$1}' >> update.bat
    You can change that to pass additional parameters to setup, such as doing a silent install or specifying the location of a local install directory etc. Hope that helps someone!
  4. Thanks for this very helpful post. I'm amazed that the Cygwin setup program doesn't generate a list of installed packages (as CSV or XML) - with the intent that it be useable for another installation. I am also surprised that the setup program does not provide an option implementing the following: if ( latest package is available on disk ) install from disk else install from internet The above capabilities would be particularly useful when installing to multiple computers. Install to computer A. Use package list and download directory to install to computers B, C, and D.
  5. Using cygcheck is quite inspired, but using the installation db is simpler. This:
    grep " 1$" /etc/setup/installed.db | awk 'NR==1{printf $1}{printf ",%s", $1}'
    will only select selected packages. With your method, you install a cygwin where all dependencies are suddenly picked.
  6. Hi, thanks for a very handy post. It really helped me make the shift from a 32-bit to a 64-bit system. I used Yamakuzure's variation and after a while I realized that my Python binaries were not installed on the 64-bit system. Luckily I kept the 32-bit version so I re-exported the package list using rattle's original suggestion and this time Python was included. FYI. Thanks again.
    1. Forgot to mention that other binaries were added when I re-exported, so it seems like Yamakuzure's version doesn't produce a complete list.
  7. at Stack Overflow someone offers a bash script, that creates a "cyg-reinstall-.bat" file: Cygwin save package selections for later reinstall
  8. Thank you so much for sharing this! For me, the actual package versions are useful to know as well (albeit in *many* circumstances I'll just want the latest version), I may still need a particular version for some reason or another (e.g. python). So, it's great to see that the setup info is in /etc/setup/installed.db and all you need to do is just swap out the $1 for $2 so it lists the actual package version, like so:
    grep " 1$" /etc/setup/installed.db | awk '{print $2}' > packagelist
  9. Very helpful instructions, providing exactly what I was looking for. However, I just want to add some nitpicking information: using sed is not really required, awk is capable of doing the job by itself (no need for piping):
    awk '/ 1$/{print $1}' /etc/setup/installed.db > packagelist
  10. Sorry, the command got messed up. Here now without Markdown 's fenced code blocks: awk '/ 1$/{print $1}' /etc/setup/installed.db > packagelist

Leave a Reply

Your email address will not be published. Required fields are marked *