public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: "kai" <kai.kang@windriver.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 1/1] systemd.bbclass: check whether systemctl works in post scripts
Date: Thu, 29 Oct 2020 17:26:50 +0800	[thread overview]
Message-ID: <20201029092650.34868-2-kai.kang@windriver.com> (raw)
In-Reply-To: <20201029092650.34868-1-kai.kang@windriver.com>

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


  reply	other threads:[~2020-10-29  9:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29  9:26 [PATCH 0/1] systemd.bbclass: check whether systemctl works in kai
2020-10-29  9:26 ` kai [this message]
2020-10-29  9:48   ` [OE-core] [PATCH 1/1] systemd.bbclass: check whether systemctl works in post scripts Andreas Oberritter
2020-10-30  5:44   ` 回复: " kai

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=20201029092650.34868-2-kai.kang@windriver.com \
    --to=kai.kang@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /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