Score:1

Build a debian package which includes a template [email protected]

ht flag

I need to build a package for a program that should be deployed as a service. I have added a debian/helloworld.service and my package is built, installed and works correctly, i have a /lib/systemd/system/helloworld.service on the target host.

However, users may be able to run several instance of the service, each one with their own config files and i have seen here that i need a template service file in the form [email protected].

But when i try to build the package using debian/[email protected], i don't have the templated service file in the package anymore (dpkg -c shows that there is no [email protected] in the .deb)

Note that i am building a binary package using fakeroot debian/rules binary.

What is the best way to do that ? Should i use postinst scripts (but https://www.debian.org/doc/manuals/maint-guide/dother.en.html#maintscripts seems to discourage their use) ?

Thank you.

Score:0
ht flag

After having looked at apache2 which is installed with a templated service, it seems that one need to add a debian/helloworld.service along with the template debian/[email protected] to see the templated file in the .deb file.

Now i can see the [email protected] with dpkg -c.

Score:-1
ye flag

You can add a script in the postinst that would create the template service file on the target host. However, it is discouraged as it goes against the principle of declarative packaging.

A better approach would be to provide a script along with your package, which can be run by the user to create the required instance of the service with the desired configuration. The script can be run on demand and can generate the required service file and start the service instance.

Fryz avatar
ht flag
Thank you but is there any declarative way for a template service file ?
Fryz avatar
ht flag
and what about adding a [email protected] in debian/install ? any drawbacks ?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.