dpkg-repack
Rebuild installed packages into Debian archives
SYNOPSIS
dpkg-repack [option...] package...
PARAMETERS
-a, --arch=<arch>
Override the detected architecture for the package
-?, -h, --help
Display help summary and exit
--license
Show the software license text
-r, --root=<dir>
Use <dir> as the filesystem root directory
-v, --version
Display version information and exit
--force-badpath
Include files in paths not typically allowed in Debian packages
--nocrossarch
Prevent cross-architecture package building
DESCRIPTION
dpkg-repack is a utility for reconstructing a .deb package from an installed package on a Debian-based system. It scans the filesystem to identify all files owned by the specified package, including their permissions, ownership, MD5 checksums, and conffile status. The tool then rebuilds a new .deb archive with this information, making it invaluable for recovering from broken package installations, database corruptions, or when modifications to an unpacked package need to be preserved in a redistributable format.
It operates by querying the dpkg database for file lists and metadata, then uses dpkg-deb internally to assemble the package. This process handles most standard cases effectively but relies on the package still being registered in the dpkg status. Common use cases include fixing partially installed packages, creating backups of customized software, or preparing modified binaries for further distribution. However, it's not intended as a replacement for proper source rebuilding, as it may not capture all dynamic elements like generated scripts or database triggers perfectly.
CAVEATS
May miss some metadata like triggers or complex scripts; rejects non-standard paths by default; output overwrites existing files without warning; not suitable for production package creation.
OUTPUT
Generates <package>_<version>_<arch>.deb in the current directory.
Example: dpkg-repack vim produces vim_2:8.2.2434-3+deb11u1_amd64.deb
DEPENDENCIES
Requires dpkg-dev, fakeroot, and dpkg; run as root for accurate permissions.
HISTORY
Originally developed by Richard Kettlewell in 2004 as part of the dpkg-repack package; integrated into Debian repositories and maintained by Debian developers for recovering and repackaging purposes.
SEE ALSO
dpkg(8), dpkg-deb(1), dpkg-query(1)


