UpstartCompatibleInitScripts

Differences between revisions 4 and 5
Revision 4 as of 2013-05-19 00:56:59
Size: 2783
Editor: vorlon
Comment:
Revision 5 as of 2013-05-30 22:53:43
Size: 3118
Editor: vorlon
Comment:
Deletions are marked like this. Additions are marked like this.
Line 55: Line 55:

== Other notes ==
* Since the new init script will be a no-op, packages which normally restart in the postinst (instead of stopping in the prerm and starting in the postinst) *MUST* handle stopping the service in their preinst when upgrading from a pre-upstart-capable version. See the Debian udev package for an example of this.

Beginning in saucy, the upstart job support in debhelper and sysvinit has been synchronized with current Debian policy. This enables patches for upstart jobs to be safely forwarded to Debian for the first time, following a few simple steps.

These instructions all assume the package is using debhelper (and in particular, dh_installinit) for maintainer script handling of jobs/init scripts. If a package is not using dh_installinit, or if it is calling dh_installinit with the --noscripts option, particular care must be taken to properly handle upgrades from packages using the older style of upstart job support in Ubuntu. This page does not attempt to document the required steps if you are not using dh_installinit; if you have questions, consult the dh_installinit source, or just convert the package to use debhelper.

Step-by-step

  • Make sure that the upstart jobs and init scripts in the package have matching names. If the names do not match, either the init script should be split (cf. /etc/init.d/samba->/etc/init.d{s,n}mbd in the samba package), or dummy upstart jobs should be created (cf. /etc/init/mountall.sh.conf in the mountall package) so that the names line up. Without this, insserv will not correctly detect that the upstart job has started and dependency-based booting will fail.

  • Edit the init scripts to call init_is_upstart and exit without taking any action if running on an upstart system. E.g.:

. /lib/lsb/init-functions

case $1 in
    start)
        if init_is_upstart; then
            exit 1
        fi
        [...]
        ;;
    stop)
        if init_is_upstart; then
            exit 0
        fi
        [...]
        ;;
    restart|force-reload)
        if init_is_upstart; then
            exit 1
        fi
        [...]
        ;;
esac
  • Manually add a versioned dependency on lsb-base for the use of init_is_upstart:

Depends: [...], lsb-base (>= 4.1+Debian3), [...]

Results

For a source package foo with the following contents:

debian/foo.init
debian/foo.default
debian/foo.upstart

... you should end up with a binary package with the following contents:

/etc/init.d/foo
/etc/default/foo
/etc/init/foo.conf

... and with the following dependencies:

Depends: [...] lsb-base (>= 4.1+Debian3), sysv-rc (>= 2.88dsf-24)

Upgrading the package should give you /etc/init.d/foo as a real file. If, after upgrading, you still see a symlink to /lib/init/upstart-job, or if there is an /etc/init.d/foo.dpkg-new on the system, something is wrong! Do not upload to Ubuntu until you have figured out why and fixed it.

And always, always do a boot test before you upload! Smile :)

Other notes

* Since the new init script will be a no-op, packages which normally restart in the postinst (instead of stopping in the prerm and starting in the postinst) *MUST* handle stopping the service in their preinst when upgrading from a pre-upstart-capable version. See the Debian udev package for an example of this.

UpstartCompatibleInitScripts (last edited 2013-05-30 22:54:20 by vorlon)