Search code examples
linuxdebdpkg

Files installed from debian package with dpkg do not belong to root


I created a binary package with this command:

dpkg-deb --build -z9 -Zlzma $(DEB_SRC_DIR) $(DEB_DEST_DIR)

and install it on my Ubuntu 12.04 with this command:

sudo dpkg -i /path/to/package

The contents of the package I think are irrelevant.

Despite the sudo command the files in the installation directory belong to the current user and not to root as I expected.

How can I fix that?


Solution

  • Try to run the dpkg-deb command with fakeroot:

    `fakeroot dpkg-deb ...`
    

    (This will only help if the files in the source directory already have the correct ownership, which they probably dont. The problem you're actually trying to solve here, is to create an archive with files in it that belong to user root, which is where fakeroot theoretically helps.)

    Let me say though, that what you are doing is not the best way for creating a binary package (far from it).

    Instead, create a debian/ directory with dh_make (from the dh-make package), and edit the control file and changelog accordingly. You also need a file debian/install that lists what files you are installing and where they should go. There are various guides on the net (and on Stack Overflow) that explain this process. For example, look at the Debian New Maintainers' Guide.

    You can then use dpkg-buildpackage to create a real, standard-conforming Debian package with your files in a reproducible way.

    dpkg-deb is a low-level tool for manipulating existing deb files; it's not meant to be used for package creation.