Possible to reconstruct deb package from installed?

It is possible the packages are still in your local .deb cache. See if it is there first before trying to rebuild it.

Try looking in /var/cache/apt/archives. That's where the apt cache is located on my Debian boxes (it should be in the same location on Ubuntu).

As @Zoredache mentions: If you are in the habit of running apt-get clean your local cache will be empty. Please see his answer on how to rebuild the package using the control file and scripts.


Under debian you have dpkg-repack for this task. Its just a perl-script and runs since debian/sarge. It also should do the trick under ubuntu.


It should be possible, but it will be a bit tricky.

A properly created Debian package when installed will leave most of the important details you need to do this in /var/lib/dpkg/info.

The first important file is /var/lib/dpkg/info/foo.list which should be a list of all the files included in the original package that were installed on your system. So start making a copy of all this files into some temporary directory.

The binary version of a Debian package will include a control archive that includes several scripts. Grab /var/lib/dpkg/info/foo.(postinst|postrm|preinst|prerm) those are your install/uninstall scripts. Another way to get a list is to run dpkg-query -c foo.

The other file you would need to create a Debian package is the control file. AFAIK, the package control file is not stored anywhere on the system, but you can get something close enough that you can reconstruct it by running the command dpkg-query -s foo | grep -v 'Status:'.

Anyway, with the file installed by the package and all the control files you should be able to re-construct the package. This Debian Binary Package Building HOWTO should give you enough details on how to use dpkg-deb to do this.


You could track down where the packages drop stuff, and use FPM

I just did this to build a deb from an installed webapp. fpm -s dir -t deb -n "webapp1" -v 1.0-mywebapp /var/www/pathtowebapp