Copying Cygwin installation from one computer to another?

I have a computer that has a Cygwin installation that has been customized over the years by installing additional packages as needed using Cygwin's setup program.

I'd like to duplicate this installation on a second computer, with the same set of packages installed.

How can I do this in a way that doesn't involve manually going through the list of installed packages on the first computer and entering it in the installation checkboxes on the second?

The two ways that I know of are to copy the directory of downloaded installation packages from the first computer and do an "install from disk" on the second, selecting everything -- but that will include packages that were installed and later removed, as well as what is currently installed. Alternately, the Google search I tried found suggestions to just copy the installation itself, which obviously will prevent setup.exe from later updating it because the information about what's installed will change. I suppose one plausible way would be to copy the actual installation and the configuration file for setup.exe that records what has been installed, if there isn't a cleaner way to do it, but I don't know what configuration information would need to be copied for this to work -- and I'd assume there has to be a better way, doesn't there?

(Addendum: I see from the answers to Cygwin package management how to dump a list of packages that are installed on the first computer, but not how to use the dumped file to duplicate the installation on the second.... Presumably it should be possible to take that dumped list and use it as input either to the -P option of setup or to pycmg, although that doesn't retain the same package versions and it's messy enough that I still would expect a better solution.)


I have done this by copying the entire cygwin directory over. The only issue I hit was with environment variables I had custom defined.

Edit-

I copied both the package and installed directories over.