2

I have following issue:

I have access only to binary file. From a binary file I am trying to make a full automated .deb package. I packaged it and works except the service file.

I created service file under debian folder

hello
-- hello
-- debian/hello.service

my rules file looks as below

$ cat debian/rules

    #!/usr/bin/make -f

    %:  
             dh $@
    override_dh:install:
            dh_install hello usr/bin

package is creating but it doesn't started service as well as not create service file under /etc/systemd/system/.

postinst file as below #!/bin/bash set -e

if [ $1 = configure] || [$1 = abort-upgrade]; then
    if [ -x /etc/init.d/hello ]; then
        update-rc.d hello defaults >/dev/null
3

You need to invoke the appropriate systemd service helpers (dh_installsystemd in compatibility level 12).

The simplest way to go about all this is to rely on dh sequences; it will do the right thing, even when there’s nothing to build:

#!/usr/bin/make -f

%:
        dh $@

override_dh_install:
        dh_install hello usr/bin

This will ensure that all the other helpers are run as appropriate in the sequence, including the systemd helpers.

With debhelper compatibility levels less than 10, you’ll need to enable the systemd sequence explicitly:

%:
        dh $@ --with systemd

(The service file will end up in /lib/systemd/system, not /etc/systemd/system.)

You could even drop the override altogether, if you write

hello usr/bin

into debian/install (or debian/hello.install, assuming your package is named hello).

  • my package is called hello and my binary also called hello. Yes hello.service file is created by the system under the path you said, but the app doesn't start still automatically, – pulp_fiction Dec 12 '19 at 10:26
  • I didnot set any version of -dh, what you mean exactly ? – pulp_fiction Dec 12 '19 at 10:49
  • What I mean is, did you replace your debian/rules with the short version in my answer, or did you keep your existing debian/rules and add dh_installsystemd to it? – Stephen Kitt Dec 12 '19 at 11:01
  • I tested again, no success. see rule file ^ added to question – pulp_fiction Dec 12 '19 at 11:50
  • What version of Debian are you building on? What debhelper compatibility level are you using? – Stephen Kitt Dec 12 '19 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.