package.init is not getting installed

Tony Meyer picture Tony Meyer · May 26, 2009 · Viewed 9.3k times · Source

I have a project.init file in the debian directory (along with rules, control, etc), and I have dh_installinit in my rules file (in the binary-arch rule).

When dpkg-buildpackage completes, the init script has been copied to debian/project/etc/init.d/project, and the various pre/post scripts have been created.

However, when I actually install the .deb (with dpkg -i), the init.d script does not get installed, so I must be missing part of this process. The "New Maintainer's Guide" is pretty sparse on init.d details (it basically says not to use them, because they are too advanced).

The verbose output of the dh_installinit command is:

dh_installinit
    install -p -m755 debian/project.init debian/project/etc/init.d/project
    echo "# Automatically added by dh_installinit">> debian/project.postinst.debhelper
    sed "s/#SCRIPT#/project/;s/#INITPARMS#/defaults/;s/#ERROR_HANDLER#/exit \$?/" /usr/share/debhelper/autoscripts/postinst-init >> debian/project.postinst.debhelper
    echo '# End automatically added section' >> debian/project.postinst.debhelper
    echo "# Automatically added by dh_installinit">> debian/project.prerm.debhelper
    sed "s/#SCRIPT#/project/;s/#INITPARMS#/defaults/;s/#ERROR_HANDLER#/exit \$?/" /usr/share/debhelper/autoscripts/prerm-init >> debian/project.prerm.debhelper
    echo '# End automatically added section' >> debian/project.prerm.debhelper
    echo "# Automatically added by dh_installinit">> debian/project.postrm.debhelper
    sed "s/#SCRIPT#/project/;s/#INITPARMS#/defaults/;s/#ERROR_HANDLER#/exit \$?/" /usr/share/debhelper/autoscripts/postrm-init >> debian/project.postrm.debhelper
    echo '# End automatically added section' >> debian/project.postrm.debhelper

Answer

Mikel picture Mikel · Sep 19, 2012

Does your package have an entry for your init script under the Conffiles block in /var/lib/dpkg/status, e.g.

Package: <project>
...
Conffiles:
 /etc/init.d/<project> d41d8cd98f00b204e9800998ecf8427e

and does /var/lib/dpkg/info/<project>.conffiles contain /etc/init.d/<project>?

Here's what's happening...

init scripts are marked as configuration files by default, since they live under /etc.1

I'm guessing you installed the package, removed the init file, then reinstalled the package.

In this case, removing the init file counts as modifying it2, and dpkg refuses to "overwrite" the "configuration file".

You should be able to fix the problem by removing the Conffiles section from /var/lib/dpkg/status.

Notes:

  1. conffiles - Debian New Maintainer's Guide
  2. An empty file has MD5sum d41d8cd98f00b204e9800998ecf8427e, but any non-matching checksum will cause the same behavior