# Import & Export Cygwin List of installed Packages

If you want to go from 32 to 64 bit [Cygwin](http://www.cygwin.com) but keep all the packages1, 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](http://cygwin.com/setup-x86_64.exe). Of course, this will also work with the old [setup-x86.exe](http://cygwin.com/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](http://cygwin.com/faq/faq.html#faq.setup.cli), 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("http://cygwin.com/%s" % setupfile) open(setupfile,'wb').write(r.read()) subprocess.call([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. 1. At least those that are available. [] ## 12 Replies to “Import & Export Cygwin List of installed Packages” 1. mhoenicka says: 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. Hemal says: 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. Ying says: 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: #!/bin/sh 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. I have so say, I am always happy when my blogging helps people =D.
5. Ed says:
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.
6. JJPandari says:
Great post! Also good for a sed/awk practice besides it's original purpose :)
7. Yamakuzure says:
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.
1. Dear Yamakuzure, that's really much better! I will update the blog post.
8. SkyDiver says:
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. SkyDiver says:
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.
9. Interesting. Good thing we kept both versions around. I will update the post again with a warning ;-).
10. guest says:
at Stack Overflow someone offers a bash script, that creates a "cyg-reinstall-.bat" file: Cygwin save package selections for later reinstall https://stackoverflow.com/questions/46829532/cygwin-save-package-selections-for-later-reinstall