public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] debianize: Use dh_installsystemd
@ 2024-02-01 13:07 Quirin Gylstorff
  2024-02-01 13:07 ` [RFC PATCH 1/2] debianize: use dh_installsystemd to automatically add systemd service Quirin Gylstorff
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Quirin Gylstorff @ 2024-02-01 13:07 UTC (permalink / raw)
  To: isar-users

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

This series adds the variable DEBIAN_SYSTEMD_SERVICE which defines
a systemd file to automatically be added to the debian folder and
automatically installed by using `dh_installsystemd`.

Quirin Gylstorff (2):
  debianize: use dh_installsystemd to automatically add systemd service
  meta/recipe-support: Use DEBIAN_SYSTEMD_SERVICE variable

 meta/classes/debianize.bbclass                    | 15 +++++++++++++++
 meta/recipes-support/enable-fsck/enable-fsck.bb   |  6 ++----
 meta/recipes-support/enable-fsck/files/postinst   |  3 ---
 .../expand-on-first-boot_1.4.bb                   |  7 ++-----
 .../expand-on-first-boot/files/postinst           |  3 ---
 .../sshd-regen-keys/sshd-regen-keys_0.4.bb        |  1 +
 6 files changed, 20 insertions(+), 15 deletions(-)
 delete mode 100644 meta/recipes-support/enable-fsck/files/postinst
 delete mode 100644 meta/recipes-support/expand-on-first-boot/files/postinst

-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFC PATCH 1/2] debianize: use dh_installsystemd to automatically add systemd service
  2024-02-01 13:07 [RFC PATCH 0/2] debianize: Use dh_installsystemd Quirin Gylstorff
@ 2024-02-01 13:07 ` Quirin Gylstorff
  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
  2 siblings, 0 replies; 7+ messages in thread
From: Quirin Gylstorff @ 2024-02-01 13:07 UTC (permalink / raw)
  To: isar-users

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFC PATCH 2/2] meta/recipe-support: Use DEBIAN_SYSTEMD_SERVICE variable
  2024-02-01 13:07 [RFC PATCH 0/2] debianize: Use dh_installsystemd Quirin Gylstorff
  2024-02-01 13:07 ` [RFC PATCH 1/2] debianize: use dh_installsystemd to automatically add systemd service Quirin Gylstorff
@ 2024-02-01 13:07 ` Quirin Gylstorff
  2024-02-01 15:16 ` [RFC PATCH 0/2] debianize: Use dh_installsystemd MOESSBAUER, Felix
  2 siblings, 0 replies; 7+ messages in thread
From: Quirin Gylstorff @ 2024-02-01 13:07 UTC (permalink / raw)
  To: isar-users

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

Change recipes to use the new DEBIAN_SYSTEMD_SERVICE variable.

Also add comment to sshd-regen-keys to explain usage of the
old mechanism.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 meta/recipes-support/enable-fsck/enable-fsck.bb            | 6 ++----
 meta/recipes-support/enable-fsck/files/postinst            | 3 ---
 .../expand-on-first-boot/expand-on-first-boot_1.4.bb       | 7 ++-----
 meta/recipes-support/expand-on-first-boot/files/postinst   | 3 ---
 .../recipes-support/sshd-regen-keys/sshd-regen-keys_0.4.bb | 1 +
 5 files changed, 5 insertions(+), 15 deletions(-)
 delete mode 100644 meta/recipes-support/enable-fsck/files/postinst
 delete mode 100644 meta/recipes-support/expand-on-first-boot/files/postinst

diff --git a/meta/recipes-support/enable-fsck/enable-fsck.bb b/meta/recipes-support/enable-fsck/enable-fsck.bb
index 0413f79d..b68d8f76 100644
--- a/meta/recipes-support/enable-fsck/enable-fsck.bb
+++ b/meta/recipes-support/enable-fsck/enable-fsck.bb
@@ -10,16 +10,14 @@ inherit dpkg-raw
 DESCRIPTION = "This service enables fsck on first boot"
 
 DEBIAN_DEPENDS = "systemd, sed, mount, initramfs-tools"
+DEBIAN_SYSTEMD_SERVICE = "enable-fsck.service"
 
 SRC_URI = " \
     file://enable-fsck.service \
     file://enable-fsck.sh \
-    file://postinst"
+    "
 
 do_install() {
-    install -d -m 755 ${D}/lib/systemd/system
-    install -m 644 ${WORKDIR}/enable-fsck.service ${D}/lib/systemd/system/
-
     install -d -m 755 ${D}/usr/share/enable-fsck
     install -m 755 ${WORKDIR}/enable-fsck.sh ${D}/usr/share/enable-fsck/
 }
diff --git a/meta/recipes-support/enable-fsck/files/postinst b/meta/recipes-support/enable-fsck/files/postinst
deleted file mode 100644
index 1c4c3bdb..00000000
--- a/meta/recipes-support/enable-fsck/files/postinst
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-systemctl enable enable-fsck.service
diff --git a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.4.bb b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.4.bb
index 0996000c..a24d1e9c 100644
--- a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.4.bb
+++ b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.4.bb
@@ -11,16 +11,13 @@ DESCRIPTION = "This service grows the last partition to the full medium during f
 MAINTAINER = "isar-users <isar-users@googlegroups.com>"
 
 DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux"
+DEBIAN_SYSTEMD_SERVICE = "expand-on-first-boot.service"
 
 SRC_URI = " \
     file://expand-on-first-boot.service \
     file://expand-last-partition.sh \
-    file://postinst"
-
+    "
 do_install() {
-    install -d -m 755 ${D}/lib/systemd/system
-    install -m 644 ${WORKDIR}/expand-on-first-boot.service ${D}/lib/systemd/system/
-
     install -d -m 755 ${D}/usr/share/expand-on-first-boot
     install -m 755 ${WORKDIR}/expand-last-partition.sh ${D}/usr/share/expand-on-first-boot/
 }
diff --git a/meta/recipes-support/expand-on-first-boot/files/postinst b/meta/recipes-support/expand-on-first-boot/files/postinst
deleted file mode 100644
index a190b01a..00000000
--- a/meta/recipes-support/expand-on-first-boot/files/postinst
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-systemctl enable expand-on-first-boot.service
diff --git a/meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.4.bb b/meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.4.bb
index 9ce1d8d8..b6d60814 100644
--- a/meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.4.bb
+++ b/meta/recipes-support/sshd-regen-keys/sshd-regen-keys_0.4.bb
@@ -5,6 +5,7 @@ DESCRIPTION = "Systemd service to regenerate sshd keys"
 MAINTAINER = "isar-users <isar-users@googlegroups.com>"
 DEBIAN_DEPENDS = "openssh-server, systemd"
 
+# postinst also removes exiting ssh keys
 SRC_URI = "file://postinst \
            file://sshd-regen-keys.service"
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 0/2] debianize: Use dh_installsystemd
  2024-02-01 13:07 [RFC PATCH 0/2] debianize: Use dh_installsystemd Quirin Gylstorff
  2024-02-01 13:07 ` [RFC PATCH 1/2] debianize: use dh_installsystemd to automatically add systemd service Quirin Gylstorff
  2024-02-01 13:07 ` [RFC PATCH 2/2] meta/recipe-support: Use DEBIAN_SYSTEMD_SERVICE variable Quirin Gylstorff
@ 2024-02-01 15:16 ` MOESSBAUER, Felix
  2024-02-01 15:48   ` Gylstorff Quirin
  2 siblings, 1 reply; 7+ messages in thread
From: MOESSBAUER, Felix @ 2024-02-01 15:16 UTC (permalink / raw)
  To: quirin.gylstorff, isar-users

On Thu, 2024-02-01 at 14:07 +0100, 'Quirin Gylstorff' via isar-users
wrote:
> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> 
> This series adds the variable DEBIAN_SYSTEMD_SERVICE which defines
> a systemd file to automatically be added to the debian folder and
> automatically installed by using `dh_installsystemd`.

Hi, do we really need that interface?

Usually you just copy these files into the debian folder in
do_prepare_build. That's it.

There are also more files which get picked up by the debhelpers.

Best regards,
Felix

> 
> Quirin Gylstorff (2):
>   debianize: use dh_installsystemd to automatically add systemd
> service
>   meta/recipe-support: Use DEBIAN_SYSTEMD_SERVICE variable
> 
>  meta/classes/debianize.bbclass                    | 15
> +++++++++++++++
>  meta/recipes-support/enable-fsck/enable-fsck.bb   |  6 ++----
>  meta/recipes-support/enable-fsck/files/postinst   |  3 ---
>  .../expand-on-first-boot_1.4.bb                   |  7 ++-----
>  .../expand-on-first-boot/files/postinst           |  3 ---
>  .../sshd-regen-keys/sshd-regen-keys_0.4.bb        |  1 +
>  6 files changed, 20 insertions(+), 15 deletions(-)
>  delete mode 100644 meta/recipes-support/enable-fsck/files/postinst
>  delete mode 100644 meta/recipes-support/expand-on-first-
> boot/files/postinst
> 
> -- 
> 2.43.0
> 

-- 
Siemens AG, Technology
Linux Expert Center



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 0/2] debianize: Use dh_installsystemd
  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
  0 siblings, 2 replies; 7+ messages in thread
From: Gylstorff Quirin @ 2024-02-01 15:48 UTC (permalink / raw)
  To: Moessbauer, Felix (T CED OES-DE), isar-users



On 2/1/24 16:16, Moessbauer, Felix (T CED OES-DE) wrote:
> On Thu, 2024-02-01 at 14:07 +0100, 'Quirin Gylstorff' via isar-users
> wrote:
>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>>
>> This series adds the variable DEBIAN_SYSTEMD_SERVICE which defines
>> a systemd file to automatically be added to the debian folder and
>> automatically installed by using `dh_installsystemd`.
> 
> Hi, do we really need that interface?
> 
> Usually you just copy these files into the debian folder in
> do_prepare_build. That's it.
> 
> There are also more files which get picked up by the debhelpers.

We have multiple location and files where the do_install pattern is
used:
```
     file://postinst"
     "

  do_install() {
     install -d -m 755 ${D}/lib/systemd/system
     install -m 644 ${WORKDIR}/enable-fsck.service ${D}/lib/systemd/system/
```

If the the do_prepare_build pattern is sufficient we can also change all 
service:

```
do_prepare_build:append() {
     install -m 644 ${WORKDIR}/enable-fsck.service ${S}/debian

}
```

Quirin
> 
> Best regards,
> Felix
> 
>>
>> Quirin Gylstorff (2):
>>    debianize: use dh_installsystemd to automatically add systemd
>> service
>>    meta/recipe-support: Use DEBIAN_SYSTEMD_SERVICE variable
>>
>>   meta/classes/debianize.bbclass                    | 15
>> +++++++++++++++
>>   meta/recipes-support/enable-fsck/enable-fsck.bb   |  6 ++----
>>   meta/recipes-support/enable-fsck/files/postinst   |  3 ---
>>   .../expand-on-first-boot_1.4.bb                   |  7 ++-----
>>   .../expand-on-first-boot/files/postinst           |  3 ---
>>   .../sshd-regen-keys/sshd-regen-keys_0.4.bb        |  1 +
>>   6 files changed, 20 insertions(+), 15 deletions(-)
>>   delete mode 100644 meta/recipes-support/enable-fsck/files/postinst
>>   delete mode 100644 meta/recipes-support/expand-on-first-
>> boot/files/postinst
>>
>> -- 
>> 2.43.0
>>
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 0/2] debianize: Use dh_installsystemd
  2024-02-01 15:48   ` Gylstorff Quirin
@ 2024-02-01 15:52     ` Anton Mikanovich
  2024-02-15  8:42     ` MOESSBAUER, Felix
  1 sibling, 0 replies; 7+ messages in thread
From: Anton Mikanovich @ 2024-02-01 15:52 UTC (permalink / raw)
  To: Gylstorff Quirin, Moessbauer, Felix (T CED OES-DE), isar-users

01/02/2024 17:48, 'Gylstorff Quirin' via isar-users wrote:
>
> We have multiple location and files where the do_install pattern is
> used:
> ```
>     file://postinst"
>     "
>
>  do_install() {
>     install -d -m 755 ${D}/lib/systemd/system
>     install -m 644 ${WORKDIR}/enable-fsck.service 
> ${D}/lib/systemd/system/
> ```
>
> If the the do_prepare_build pattern is sufficient we can also change 
> all service:
>
> ```
> do_prepare_build:append() {
>     install -m 644 ${WORKDIR}/enable-fsck.service ${S}/debian
>
> }
> ```
>
> Quirin
>
I hope the same can be done by subdir=debian in SRC_URI, not sure about
dpkg-raw recipes.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 0/2] debianize: Use dh_installsystemd
  2024-02-01 15:48   ` Gylstorff Quirin
  2024-02-01 15:52     ` Anton Mikanovich
@ 2024-02-15  8:42     ` MOESSBAUER, Felix
  1 sibling, 0 replies; 7+ messages in thread
From: MOESSBAUER, Felix @ 2024-02-15  8:42 UTC (permalink / raw)
  To: quirin.gylstorff, isar-users

On Thu, 2024-02-01 at 16:48 +0100, Gylstorff Quirin wrote:
> 
> 
> On 2/1/24 16:16, Moessbauer, Felix (T CED OES-DE) wrote:
> > On Thu, 2024-02-01 at 14:07 +0100, 'Quirin Gylstorff' via isar-
> > users
> > wrote:
> > > From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> > > 
> > > This series adds the variable DEBIAN_SYSTEMD_SERVICE which
> > > defines
> > > a systemd file to automatically be added to the debian folder and
> > > automatically installed by using `dh_installsystemd`.
> > 
> > Hi, do we really need that interface?
> > 
> > Usually you just copy these files into the debian folder in
> > do_prepare_build. That's it.
> > 
> > There are also more files which get picked up by the debhelpers.
> 
> We have multiple location and files where the do_install pattern is
> used:
> ```
>      file://postinst"
>      "
> 
>   do_install() {
>      install -d -m 755 ${D}/lib/systemd/system
>      install -m 644 ${WORKDIR}/enable-fsck.service
> ${D}/lib/systemd/system/
> ```
> 
> If the the do_prepare_build pattern is sufficient we can also change
> all 
> service:
> 
> ```
> do_prepare_build:append() {
>      install -m 644 ${WORKDIR}/enable-fsck.service ${S}/debian
> 
> }

This in principle is a good pattern, but is prone to rebuild errors as
${S}/debian is not cleaned beforehand. Unfortunately we cannot always
add do_prepare_build[cleandirs] += "${S}/debian", as this runs after
the do_unpack which might already place files there.

Maybe just add this line to the respective recipes?

Felix

> ```
> 
> Quirin
> > 
> > Best regards,
> > Felix
> > 
> > > 
> > > Quirin Gylstorff (2):
> > >    debianize: use dh_installsystemd to automatically add systemd
> > > service
> > >    meta/recipe-support: Use DEBIAN_SYSTEMD_SERVICE variable
> > > 
> > >   meta/classes/debianize.bbclass                    | 15
> > > +++++++++++++++
> > >   meta/recipes-support/enable-fsck/enable-fsck.bb   |  6 ++----
> > >   meta/recipes-support/enable-fsck/files/postinst   |  3 ---
> > >   .../expand-on-first-boot_1.4.bb                   |  7 ++-----
> > >   .../expand-on-first-boot/files/postinst           |  3 ---
> > >   .../sshd-regen-keys/sshd-regen-keys_0.4.bb        |  1 +
> > >   6 files changed, 20 insertions(+), 15 deletions(-)
> > >   delete mode 100644 meta/recipes-support/enable-
> > > fsck/files/postinst
> > >   delete mode 100644 meta/recipes-support/expand-on-first-
> > > boot/files/postinst
> > > 
> > > -- 
> > > 2.43.0
> > > 
> > 

-- 
Siemens AG, Technology
Linux Expert Center



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-15  8:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01 13:07 [RFC PATCH 0/2] debianize: Use dh_installsystemd Quirin Gylstorff
2024-02-01 13:07 ` [RFC PATCH 1/2] debianize: use dh_installsystemd to automatically add systemd service Quirin Gylstorff
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox