Unpack, modify and repack deb files

ubuntu_logo_81x81There are instances when you need to modify some file(s) inside a deb package and repack it for installation. This can be done very easily on Ubuntu and Debian using dkpg-deb:

  1. Copy the deb file to a directory
  2. Create the directory structure
    $ mkdir -p newpack oldpack/DEBIAN
  3. Extract the filesystem tree
    $ dpkg-deb -x file.deb oldpack/
  4. Extract the control information files
    $ dpkg-deb -e file.deb oldpack/DEBIAN
  5. Modify something if you want
  6. Repackage the deb file under newpack directory using xz compression
    $ dpkg-deb -Z xz -b oldpack/ newpack/

Leave a Reply

Your email address will not be published. Required fields are marked *