views:

951

answers:

3

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
A: 

At this point I would check the content of the .deb file that is created. You can use dpkg-deb -c for that purpose.

If the init script is in the .deb, it should get installed in /etc/init.d, just like this:

...
drwxr-xr-x root/root         0 2009-06-03 14:01 ./etc/
drwxr-xr-x root/root         0 2009-06-03 14:01 ./etc/init.d/
-rwxr-xr-x root/root      2558 2009-02-13 11:27 ./etc/init.d/balance
...

If your run a recent version of Debian, the content of your package may be generate from debian/tmp instead of debian/project as you seem to expect. You can move the files from debian/projet to debian/tmp using dh_install.

A: 

Just a guess, are you using a -P option to other dh_* scripts but not this one? If you use that option, you need to use it on all the dh_* scripts.

Mark Baker
+3  A: 

I believe you should be looking at the utility script "update-rc.d" which takes care of creating / removing symlinks in /etc/init.d/ .

Use this script in the DEBIAN control files "postinst" & "postrm".

E.g. for 'postinst': update-rc.d mswitch start 20 2 3 4 5 . stop 0 1 6 .

E.g. for 'postrm': update-rc.d mswitch remove

jldupont