public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Update the criterion whether command systemctl available in systemd.bbclass
@ 2020-12-02  2:21 kai
  2020-12-02  2:21 ` [PATCH v3 1/2] systemd-systemctl-native: capable to call without argument kai
  2020-12-02  2:21 ` [PATCH v3 2/2] systemd.bbclass: update command to check systemctl available kai
  0 siblings, 2 replies; 3+ messages in thread
From: kai @ 2020-12-02  2:21 UTC (permalink / raw)
  To: openembedded-core

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

v3:
* update commit messages to make more clearer

Kai Kang (2):
  systemd-systemctl-native: capable to call without argument
  systemd.bbclass: update command to check systemctl available

 meta/classes/systemd.bbclass                          | 4 ++--
 meta/recipes-core/systemd/systemd-systemctl/systemctl | 8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

-- 
2.17.1


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

* [PATCH v3 1/2] systemd-systemctl-native: capable to call without argument
  2020-12-02  2:21 [PATCH v3 0/2] Update the criterion whether command systemctl available in systemd.bbclass kai
@ 2020-12-02  2:21 ` kai
  2020-12-02  2:21 ` [PATCH v3 2/2] systemd.bbclass: update command to check systemctl available kai
  1 sibling, 0 replies; 3+ messages in thread
From: kai @ 2020-12-02  2:21 UTC (permalink / raw)
  To: openembedded-core

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

In systemd.bbclass, it will replace criterion command 'type systemctl'
with 'systemctl' without any argument to judge whether command systemctl
is available. The change is to fix install/remove package error in
container when command systemctl exists but not callable.

Make native systemctl wrapper prints help mesages if called without any
argument to follow the update.

Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 meta/recipes-core/systemd/systemd-systemctl/systemctl | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index 990de1ab39..de733e255b 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -282,7 +282,7 @@ def main():
         sys.exit("Python 3.4 or greater is required")
 
     parser = argparse.ArgumentParser()
-    parser.add_argument('command', nargs=1, choices=['enable', 'mask',
+    parser.add_argument('command', nargs='?', choices=['enable', 'mask',
                                                      'preset-all'])
     parser.add_argument('service', nargs=argparse.REMAINDER)
     parser.add_argument('--root')
@@ -300,7 +300,11 @@ def main():
         locations.append(BASE_LIBDIR / "systemd")
     locations.append(LIBDIR / "systemd")
 
-    command = args.command[0]
+    command = args.command
+    if not command:
+        parser.print_help()
+        return 0
+
     if command == "mask":
         for service in args.service:
             SystemdUnit(root, service).mask()
-- 
2.17.1


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

* [PATCH v3 2/2] systemd.bbclass: update command to check systemctl available
  2020-12-02  2:21 [PATCH v3 0/2] Update the criterion whether command systemctl available in systemd.bbclass kai
  2020-12-02  2:21 ` [PATCH v3 1/2] systemd-systemctl-native: capable to call without argument kai
@ 2020-12-02  2:21 ` kai
  1 sibling, 0 replies; 3+ messages in thread
From: kai @ 2020-12-02  2:21 UTC (permalink / raw)
  To: openembedded-core

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

When use a core image with systemd as docker image, it fails to
install/remove package which calls systemctl in post scripts.
It fails 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

So replace the criterion command 'type systemctl' with 'systemctl' in
package post scripts to check whether systemctl available.

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..9ec465c759 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 >/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 >/dev/null 2>/dev/null; then
 	if [ -z "$D" ]; then
 		systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
 
-- 
2.17.1


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

end of thread, other threads:[~2020-12-02  2:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-02  2:21 [PATCH v3 0/2] Update the criterion whether command systemctl available in systemd.bbclass kai
2020-12-02  2:21 ` [PATCH v3 1/2] systemd-systemctl-native: capable to call without argument kai
2020-12-02  2:21 ` [PATCH v3 2/2] systemd.bbclass: update command to check systemctl available kai

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