If you want to go from 32 to 64 bit [Cygwin](http://www.cygwin.com) 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
cygcheck -c -d | sed -e "1,2d" -e 's/ .*$//' > packagelist
./setup-x86_64 -P `awk 'NR==1{printf $1}{printf ",%s", $1}' packagelist`
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 ])
--64 to install 64 bit cygwin and the option --packages=packagelist to select a file with a list of packages.
/etc/setup/installed.dband all you need to do is just swap out the$1for$2so it lists the actual package version, like so:sedis not really required,awkis capable of doing the job by itself (no need for piping):