简体   繁体   中英

Should I override debhelper usage of the init system?

I am trying to build a debian package with systemd scripts and I don't really understand the best way to do it.

My first question is, should I use the --with=systemd option (and override dh_systemd_enable and dh_systemd_start ) or is using dh_installinit with the --name option enough? Because both seem to do the same thing.

You definitely need --with=systemd in your dh invocation.

As for which combination of overrides you need, it depends.

It sounds like you just need systemd units included, so you don't need to override anything.

Since your question doesn't have much context, I will list some of the use cases for when to override each systemd debhelpder.

When to use override_dh_systemd_enable:

  • If you want to override your service to be enabled on a system that typically disables services on install (typically this is any linux flavor that is not derived from Debian)
  • If you want to override your service to be disabled on a system that typically enables services on install (typically this is Debian or any linux flavor that is derived from Debian)
  • If you have multiple systemd units in your Debian package, and you need to enable them
  • If the main systemdunit in your debian package is named something other than package-name.service and it needs to be enabled/disabled

Manual page for dh_systemd_enable

When to use override_dh_systemd_start:

  • If you want to override your service to NOT start on install or boot on a system that typically starts services on install (typically this is Debian or any linux flavor that is derived from Debian)
  • If you want the systemd unit to not stop or restart on debian package upgrade
  • If you want the systemd unit to not stop until debian package upgrade is completed ( This is useful for daemons that should not have a possibly long downtime during upgrade )
  • If you want to undo a don't stop until debian package upgrade is completed action
  • If the main systemd unit in your debian package is named something other than package-name.service and any of the aforementioned actions above need to happen
  • If you have multiple systemd units in your Debian package, and any of the aforementioned actions above need to happen

Manual page for dh_systemd_start

When to use override_dh_installinit:

  • If the main systemd unit in your debian package is named something other than package-name.service
  • If you have multiple systemd units in your Debian package, and you need to install them
  • There are also many repeat functionalities that depend on what version of debhelper you are using that are similar to the ones listed in the dh_systemd_start and dh_systemd_enable section above. There are also many things that involve upstart, which is not relevant to this question. Please see the man page, linked below.

Manual page for dh_installinit

Also note all these overrides go into your debian control file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM