public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Quirin Gylstorff <Quirin.Gylstorff@siemens.com>
To: isar-users@googlegroups.com
Subject: [RFC PATCH 1/2] debianize: use dh_installsystemd to automatically add systemd service
Date: Thu,  1 Feb 2024 14:07:41 +0100	[thread overview]
Message-ID: <20240201130752.3734292-2-Quirin.Gylstorff@siemens.com> (raw)
In-Reply-To: <20240201130752.3734292-1-Quirin.Gylstorff@siemens.com>

From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

Copy the file in `DEBIAN_SYSTEMD_SERVICE` to the folder if it has the
same name as the debian package. This will use dh_installsystemd.

Debian detects any of the following files in the debian folder
they are installed into usr/lib/systemd/system/ in the package build directory:
 - package.mount
 - package.path
 - package@.path
 - package.service
 - package@.service
 - package.socket
 - package@.socket
 - package.target
 - package@.target
 - package.timer
 - package@.timer

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 meta/classes/debianize.bbclass | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/meta/classes/debianize.bbclass b/meta/classes/debianize.bbclass
index 7de98673..5015d52c 100644
--- a/meta/classes/debianize.bbclass
+++ b/meta/classes/debianize.bbclass
@@ -11,6 +11,7 @@ DEBIAN_DEPENDS ??= ""
 DEBIAN_CONFLICTS ??= ""
 DEBIAN_MULTI_ARCH ??= "no"
 DEBIAN_COMPAT ??= "10"
+DEBIAN_SYSTEMD_SERVICE ??= ""
 DESCRIPTION ??= "must not be empty"
 MAINTAINER ??= "Unknown maintainer <unknown@example.com>"
 
@@ -116,12 +117,26 @@ deb_debianize() {
 	# contains an entry with CHANGELOG_V
 	deb_add_changelog
 
+	# copy service files to debian folder
+	# this will automatically enable the service
+	service_installed=""
+	if [ -n "${DEBIAN_SYSTEMD_SERVICE}" ]; then
+		service_name=$(echo ${DEBIAN_SYSTEMD_SERVICE} | awk -F. '{print $1}')
+		if [ "$service_name" = "${BPN}" ] && [ -f ${WORKDIR}/${DEBIAN_SYSTEMD_SERVICE} ]; then
+			install -v -m 644 ${WORKDIR}/${DEBIAN_SYSTEMD_SERVICE} ${S}/debian/
+		fi
+		service_installed="true"
+	fi
+
 	# copy all hooks from WORKDIR into debian/, hooks are not generated
 	for t in pre post
 	do
 		for a in inst rm
 		do
 			if [ -f ${WORKDIR}/${t}${a} ]; then
+				if [ "$service_installed" = "true" ]; then
+					bbwarn "systemd service '${BPN}.service' exists and is added automacially to the debian folder."
+				fi
 				install -v -m 755 ${WORKDIR}/${t}${a} \
 					${S}/debian/${t}${a}
 			fi
-- 
2.43.0


  reply	other threads:[~2024-02-01 13:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 13:07 [RFC PATCH 0/2] debianize: Use dh_installsystemd Quirin Gylstorff
2024-02-01 13:07 ` Quirin Gylstorff [this message]
2024-02-01 13:07 ` [RFC PATCH 2/2] meta/recipe-support: Use DEBIAN_SYSTEMD_SERVICE variable Quirin Gylstorff
2024-02-01 15:16 ` [RFC PATCH 0/2] debianize: Use dh_installsystemd MOESSBAUER, Felix
2024-02-01 15:48   ` Gylstorff Quirin
2024-02-01 15:52     ` Anton Mikanovich
2024-02-15  8:42     ` MOESSBAUER, Felix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240201130752.3734292-2-Quirin.Gylstorff@siemens.com \
    --to=quirin.gylstorff@siemens.com \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox