Repack a .deb-archive with dpkg-deb

I just needed to repack a Debian package to solve this problem. After a quick spin to #debian I got this solution:

$ mkdir -p extract/DEBIAN
$ dpkg-deb -x package.deb extract/
$ dpkg-deb -e package.deb extract/DEBIAN
[...do something, e.g. edit the control file...]
$ mkdir build
$ dpkg-deb -b extract/ build/
  • -x extracts the package contents
  • -e extracts the control files
  • -b builds the new package

Done.

  • prvul

    Thank you very much! It worked perfect. Just one question, does this apply to Ubuntu packages as well? I mean, repacked deb worked on ubuntu for me, but is this also the “Ubuntu way” of repacking debs?

    • http://maff.ailoo.net/ Mathias

      I’d say this is the apt/dpkg way of repacking debs, so it should apply to all Debian-based distros (like, for example, Ubuntu ;))

  • prvul

    Thank you very much! It worked perfect. Just one question, does this apply to Ubuntu packages as well? I mean, repacked deb worked on ubuntu for me, but is this also the “Ubuntu way” of repacking debs?

    • http://maff.ailoo.net/ Mathias

      I’d say this is the apt/dpkg way of repacking debs, so it should apply to all Debian-based distros (like, for example, Ubuntu ;))

  • Pingback: Some thoughts about dependencies in packages - Tenzer.dk()

  • fbartels

    Hi,
    thanks for this awesome mini howto. just what i needed to put an aditional file into a package.

  • fbartels

    Hi,
    thanks for this awesome mini howto. just what i needed to put an aditional file into a package.

  • Steffen

    Hello,
    this info about dpkg-deb was just what I missed since I had to give up dpkg-repackage for a while. Repackaging current iptables-amd64 as iptables-i386 with slightly modified dependencies was a matter of seconds. (This is needed, since iptables for i386 won’t work with any amd64-kernel on stock i386 Debian installations, even not with amd64-lib installed.
    Thank you for your valueable hint.

  • Steffen

    Hello,
    this info about dpkg-deb was just what I missed since I had to give up dpkg-repackage for a while. Repackaging current iptables-amd64 as iptables-i386 with slightly modified dependencies was a matter of seconds. (This is needed, since iptables for i386 won’t work with any amd64-kernel on stock i386 Debian installations, even not with amd64-lib installed.
    Thank you for your valueable hint.

  • Anonymous

    This was quite helpful; thank you. I had to google around for some time before finding this.

  • http://verwijs.wordpress.com/ André Verwijs

    so far so good, used it for mysql package…

  • Pingback: Repack a .DEB archive | 0ddn1x: tricks with *nix()

  • אוהד

    nice to know…
    you saved me a lot of time!

  • Pingback: Correcting obsolete dependency requirements in DEB packages | Rohit Bhute()