8

dh_installinit looks for debian/$(package).service, but a package may provide multiple services.

Is it possible for one to bundle multiples .service for one package with this method?

Zulgrib
  • 984

2 Answers2

9

You can call dh_installinit multiple times with different --name parameters to install multiple services:

override_dh_installinit:
        dh_installinit --name=service1
        dh_installinit --name=service2

(or similar approaches if you're not using short dh style). If your source package builds multiple binary packages, you can add -p options to limit dh_installinit's action to the appropriate package.

Stephen Kitt
  • 434,908
  • @ Stephen Kitt How does this work with service files? The man page section for the --name option only mentions .upstart, .init & .default file types. --- Install the init script (and default file) as well as upstart job file using the filename name instead of the default filename, which is the package name. When this parameter is used, dh_installinit looks for and installs files named debian/package.name.init, debian/package.name.default and debian/package.name.upstart instead of the usual debian/package.init, debian/package.default and debian/package.upstart. – Wimateeka Feb 07 '18 at 18:50
  • 1
    @Wimateeka well spotted, the documentation is out of date there. --name is handled globally for all debhelper commands, by Debian::Debhelper::Dh_Getopt, ::Dh_Lib and ::Buildsystem; it works for all supported file types. See for example cups and glibc which both use dh_installinit with a --name argument to install systemd services. – Stephen Kitt Feb 07 '18 at 21:24
8

Starting from compatibility level 11, dh_installinit no longer handles systemd services. Use dh_installsystemd instead:

override_dh_installsystemd:
    dh_installsystemd --name=service1
    dh_installsystemd --name=service2

(The above assumes that you have two service files: debian/<package-name>.service1.service and debian/<package-name>.service2.service.)

Yd Ahhrk
  • 373
  • This is better in newer packages. An important note, though, the debian/compat (or dependency in debian/control) must be at least 12 otherwise the override_dh_installsystemd is ignored. – Alexis Wilke Aug 12 '23 at 15:47