All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] systemd.bbclass: check whether systemctl works in
@ 2020-10-29  9:26 kai
  2020-10-29  9:26 ` [PATCH 1/1] systemd.bbclass: check whether systemctl works in post scripts kai
  0 siblings, 1 reply; 4+ messages in thread
From: kai @ 2020-10-29  9:26 UTC (permalink / raw)
  To: openembedded-core

From: Kai Kang <kai.kang@windriver.com>

It fails to run systemctl in a container even though it exists. Check
with 'systemctl list-machines' to make sure systemctl works.

And there is another issue that /var/tmp is a dead link to volatile/tmp
which doesn't exists. Changqing has sent a patch to fix it. My concern
is in FHS, /var/tmp should not volatile. Could we make /var/tmp as a
common directory rather than a link without extra config?

Ref:
https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.html

Kai Kang (1):
  systemd.bbclass: check whether systemctl works in post scripts

 meta/classes/systemd.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.17.1


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

* [PATCH 1/1] systemd.bbclass: check whether systemctl works in post scripts
  2020-10-29  9:26 [PATCH 0/1] systemd.bbclass: check whether systemctl works in kai
@ 2020-10-29  9:26 ` kai
  2020-10-29  9:48   ` [OE-core] " Andreas Oberritter
  2020-10-30  5:44   ` 回复: " kai
  0 siblings, 2 replies; 4+ messages in thread
From: kai @ 2020-10-29  9:26 UTC (permalink / raw)
  To: openembedded-core

From: Kai Kang <kai.kang@windriver.com>

When use a core image tarball as a docker image with 'docker import', it
fails to install/remove package which calls systemctl in post scripts.
Because it fais to run systemctl in a container:

bash-5.0# systemctl
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

Replace 'type systemctl' with 'systemctl list-machines' in package post
scripts to check whether systemctl work rather than existence.

Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 meta/classes/systemd.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index 9e8a82c9f1..9938425e2d 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -23,7 +23,7 @@ python __anonymous() {
 }
 
 systemd_postinst() {
-if type systemctl >/dev/null 2>/dev/null; then
+if systemctl list-machines >/dev/null 2>/dev/null; then
 	OPTS=""
 
 	if [ -n "$D" ]; then
@@ -48,7 +48,7 @@ fi
 }
 
 systemd_prerm() {
-if type systemctl >/dev/null 2>/dev/null; then
+if systemctl list-machines >/dev/null 2>/dev/null; then
 	if [ -z "$D" ]; then
 		systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
 
-- 
2.17.1


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

* Re: [OE-core] [PATCH 1/1] systemd.bbclass: check whether systemctl works in post scripts
  2020-10-29  9:26 ` [PATCH 1/1] systemd.bbclass: check whether systemctl works in post scripts kai
@ 2020-10-29  9:48   ` Andreas Oberritter
  2020-10-30  5:44   ` 回复: " kai
  1 sibling, 0 replies; 4+ messages in thread
From: Andreas Oberritter @ 2020-10-29  9:48 UTC (permalink / raw)
  To: kai; +Cc: openembedded-core

Hello Kai,

On Thu, 29 Oct 2020 17:26:50 +0800
"kai" <kai.kang@windriver.com> wrote:

> From: Kai Kang <kai.kang@windriver.com>
> 
> When use a core image tarball as a docker image with 'docker import', it
> fails to install/remove package which calls systemctl in post scripts.
> Because it fais to run systemctl in a container:
> 
> bash-5.0# systemctl
> System has not been booted with systemd as init system (PID 1). Can't operate.
> Failed to connect to bus: Host is down
> 
> Replace 'type systemctl' with 'systemctl list-machines' in package post
> scripts to check whether systemctl work rather than existence.
> 
> Signed-off-by: Kai Kang <kai.kang@windriver.com>
> ---
>  meta/classes/systemd.bbclass | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
> index 9e8a82c9f1..9938425e2d 100644
> --- a/meta/classes/systemd.bbclass
> +++ b/meta/classes/systemd.bbclass
> @@ -23,7 +23,7 @@ python __anonymous() {
>  }
>  
>  systemd_postinst() {
> -if type systemctl >/dev/null 2>/dev/null; then
> +if systemctl list-machines >/dev/null 2>/dev/null; then
>  	OPTS=""
>  
>  	if [ -n "$D" ]; then

Shouldn't this already have been run during image construction?

Doesn't this break our systemctl emulation (meta/recipes-core/systemd/systemd-systemctl/systemctl)?

> @@ -48,7 +48,7 @@ fi
>  }
>  
>  systemd_prerm() {
> -if type systemctl >/dev/null 2>/dev/null; then
> +if systemctl list-machines >/dev/null 2>/dev/null; then
>  	if [ -z "$D" ]; then
>  		systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
>  

You're running the prerm hook inside a docker container?

Wouldn't it be more appropriate to remove the systemd DISTRO_FEATURE for a use-case like this?

Best regards,
Andreas

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

* 回复: [PATCH 1/1] systemd.bbclass: check whether systemctl works in post scripts
  2020-10-29  9:26 ` [PATCH 1/1] systemd.bbclass: check whether systemctl works in post scripts kai
  2020-10-29  9:48   ` [OE-core] " Andreas Oberritter
@ 2020-10-30  5:44   ` kai
  1 sibling, 0 replies; 4+ messages in thread
From: kai @ 2020-10-30  5:44 UTC (permalink / raw)
  To: openembedded-core, obi

[-- Attachment #1: Type: text/plain, Size: 3162 bytes --]

Hi Andreas,

I am sorry that my email client goes wrong. So I have to reply this way.

>>  systemd_postinst() {
>> -if type systemctl >/dev/null 2>/dev/null; then
>> +if systemctl list-machines >/dev/null 2>/dev/null; then
>>      OPTS=""
>>
>>      if [ -n "$D" ]; then
>
> Shouldn't this already have been run during image construction?
>
> Doesn't this break our systemctl emulation (meta/recipes-core/systemd/systemd-systemctl/systemctl)?

The use case is similar with Fedora or Debian that modify image with
command dnf, both on the real bsp or container.

It breaks the systemd-systemctl-native indeed. The reason to run
systemctl to check whether it really works because it fails in container.
And I suppose 'systemctl list-machines' is the most quick subcommand of
systemctl. How about add a stub function to provide sub-common
list-machines for systemd-systemctl-native?

>
>
>> @@ -48,7 +48,7 @@ fi
>>  }
>>
>>  systemd_prerm() {
>> -if type systemctl >/dev/null 2>/dev/null; then
>> +if systemctl list-machines >/dev/null 2>/dev/null; then
>>      if [ -z "$D" ]; then
>>          systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
>>
>
> You're running the prerm hook inside a docker container?
>
> Wouldn't it be more appropriate to remove the systemd DISTRO_FEATURE for a use-case like this?

There will  always has an init manager there for oe-core. It should work
for both sysvinit and systemd without extra configure to use as a docker
image.

Thanks for your comment.

Kai

________________________________
发件人: Kang, Kai <kai.kang@windriver.com>
发送时间: 2020年10月29日 17:27
收件人: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org>
主题: [PATCH 1/1] systemd.bbclass: check whether systemctl works in post scripts

From: Kai Kang <kai.kang@windriver.com>

When use a core image tarball as a docker image with 'docker import', it
fails to install/remove package which calls systemctl in post scripts.
Because it fais to run systemctl in a container:

bash-5.0# systemctl
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

Replace 'type systemctl' with 'systemctl list-machines' in package post
scripts to check whether systemctl work rather than existence.

Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 meta/classes/systemd.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index 9e8a82c9f1..9938425e2d 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -23,7 +23,7 @@ python __anonymous() {
 }

 systemd_postinst() {
-if type systemctl >/dev/null 2>/dev/null; then
+if systemctl list-machines >/dev/null 2>/dev/null; then
         OPTS=""

         if [ -n "$D" ]; then
@@ -48,7 +48,7 @@ fi
 }

 systemd_prerm() {
-if type systemctl >/dev/null 2>/dev/null; then
+if systemctl list-machines >/dev/null 2>/dev/null; then
         if [ -z "$D" ]; then
                 systemctl stop ${SYSTEMD_SERVICE_ESCAPED}

--
2.17.1


[-- Attachment #2: Type: text/html, Size: 5699 bytes --]

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

end of thread, other threads:[~2020-10-30  5:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29  9:26 [PATCH 0/1] systemd.bbclass: check whether systemctl works in kai
2020-10-29  9:26 ` [PATCH 1/1] systemd.bbclass: check whether systemctl works in post scripts kai
2020-10-29  9:48   ` [OE-core] " Andreas Oberritter
2020-10-30  5:44   ` 回复: " kai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.