public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Update check for systemctl
@ 2020-11-02  2:17 kai
  2020-11-02  2:17 ` [PATCH 1/2] systemd-systemctl: capable to call without argument kai
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: kai @ 2020-11-02  2:17 UTC (permalink / raw)
  To: obi; +Cc: openembedded-core

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

v2:
* update systemd-systemctl that could call systemctl without argument
* check with excute 'systemctl' directly

Kai Kang (2):
  systemd-systemctl: capable to call without argument
  systemd.bbclass: check whether systemctl works in post scripts

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

-- 
2.17.1


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

* [PATCH 1/2] systemd-systemctl: capable to call without argument
  2020-11-02  2:17 [PATCH 0/2] Update check for systemctl kai
@ 2020-11-02  2:17 ` kai
  2020-11-02  2:17 ` [PATCH 2/2] systemd.bbclass: check whether systemctl works in post scripts kai
       [not found] ` <16438F587D21D644.10137@lists.openembedded.org>
  2 siblings, 0 replies; 6+ messages in thread
From: kai @ 2020-11-02  2:17 UTC (permalink / raw)
  To: obi; +Cc: openembedded-core

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

Make systemctl prints help mesages if run without any argument. It helps
to judge whether systemctl works in postscripts in systemd.bbclass.

Remove trailing white spaces as well.

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

diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index 990de1ab39..c692b65920 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -30,7 +30,7 @@ class SystemdFile():
         self._parse(root, path)
         dirname = os.path.basename(path.name) + ".d"
         for location in locations:
-            for path2 in sorted((root / location / "system" / dirname).glob("*.conf")):                
+            for path2 in sorted((root / location / "system" / dirname).glob("*.conf")):
                 self._parse(root, path2)
 
     def _parse(self, root, path):
@@ -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] 6+ messages in thread

* [PATCH 2/2] systemd.bbclass: check whether systemctl works in post scripts
  2020-11-02  2:17 [PATCH 0/2] Update check for systemctl kai
  2020-11-02  2:17 ` [PATCH 1/2] systemd-systemctl: capable to call without argument kai
@ 2020-11-02  2:17 ` kai
       [not found] ` <16438F587D21D644.10137@lists.openembedded.org>
  2 siblings, 0 replies; 6+ messages in thread
From: kai @ 2020-11-02  2:17 UTC (permalink / raw)
  To: obi; +Cc: 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
that 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

Replace 'type systemctl' with call 'systemctl' directly in package post
scripts to check whether systemctl works 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..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] 6+ messages in thread

* Re: [OE-core] [PATCH 1/2] systemd-systemctl: capable to call without argument
       [not found] ` <16438F587D21D644.10137@lists.openembedded.org>
@ 2020-11-17  2:14   ` kai
  2020-11-23 10:59     ` kai
  2020-11-20  2:03   ` kai
  1 sibling, 1 reply; 6+ messages in thread
From: kai @ 2020-11-17  2:14 UTC (permalink / raw)
  To: obi; +Cc: openembedded-core

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

Ping.

On 11/2/20 10:17 AM, kai wrote:
> From: Kai Kang <kai.kang@windriver.com>
>
> Make systemctl prints help mesages if run without any argument. It helps
> to judge whether systemctl works in postscripts in systemd.bbclass.
>
> Remove trailing white spaces as well.
>
> Signed-off-by: Kai Kang <kai.kang@windriver.com>
> ---
>   meta/recipes-core/systemd/systemd-systemctl/systemctl | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl
> index 990de1ab39..c692b65920 100755
> --- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
> +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
> @@ -30,7 +30,7 @@ class SystemdFile():
>           self._parse(root, path)
>           dirname = os.path.basename(path.name) + ".d"
>           for location in locations:
> -            for path2 in sorted((root / location / "system" / dirname).glob("*.conf")):
> +            for path2 in sorted((root / location / "system" / dirname).glob("*.conf")):
>                   self._parse(root, path2)
>   
>       def _parse(self, root, path):
> @@ -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()
>
> 
>


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

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

* Re: [OE-core] [PATCH 1/2] systemd-systemctl: capable to call without argument
       [not found] ` <16438F587D21D644.10137@lists.openembedded.org>
  2020-11-17  2:14   ` [OE-core] [PATCH 1/2] systemd-systemctl: capable to call without argument kai
@ 2020-11-20  2:03   ` kai
  1 sibling, 0 replies; 6+ messages in thread
From: kai @ 2020-11-20  2:03 UTC (permalink / raw)
  To: obi; +Cc: openembedded-core

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

Any comment, please?

Thanks,
Kai


On 11/2/20 10:17 AM, kai wrote:
> From: Kai Kang <kai.kang@windriver.com>
>
> Make systemctl prints help mesages if run without any argument. It helps
> to judge whether systemctl works in postscripts in systemd.bbclass.
>
> Remove trailing white spaces as well.
>
> Signed-off-by: Kai Kang <kai.kang@windriver.com>
> ---
>   meta/recipes-core/systemd/systemd-systemctl/systemctl | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl
> index 990de1ab39..c692b65920 100755
> --- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
> +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
> @@ -30,7 +30,7 @@ class SystemdFile():
>           self._parse(root, path)
>           dirname = os.path.basename(path.name) + ".d"
>           for location in locations:
> -            for path2 in sorted((root / location / "system" / dirname).glob("*.conf")):
> +            for path2 in sorted((root / location / "system" / dirname).glob("*.conf")):
>                   self._parse(root, path2)
>   
>       def _parse(self, root, path):
> @@ -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()
>
> 
>


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

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

* Re: [OE-core] [PATCH 1/2] systemd-systemctl: capable to call without argument
  2020-11-17  2:14   ` [OE-core] [PATCH 1/2] systemd-systemctl: capable to call without argument kai
@ 2020-11-23 10:59     ` kai
  0 siblings, 0 replies; 6+ messages in thread
From: kai @ 2020-11-23 10:59 UTC (permalink / raw)
  To: openembedded-core

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

On 11/17/20 10:14 AM, Kai wrote:
> Ping.

Ping...


>
> On 11/2/20 10:17 AM, kai wrote:
>> From: Kai Kang<kai.kang@windriver.com>
>>
>> Make systemctl prints help mesages if run without any argument. It helps
>> to judge whether systemctl works in postscripts in systemd.bbclass.
>>
>> Remove trailing white spaces as well.
>>
>> Signed-off-by: Kai Kang<kai.kang@windriver.com>
>> ---
>>   meta/recipes-core/systemd/systemd-systemctl/systemctl | 10 +++++++---
>>   1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl
>> index 990de1ab39..c692b65920 100755
>> --- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
>> +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
>> @@ -30,7 +30,7 @@ class SystemdFile():
>>           self._parse(root, path)
>>           dirname = os.path.basename(path.name) + ".d"
>>           for location in locations:
>> -            for path2 in sorted((root / location / "system" / dirname).glob("*.conf")):
>> +            for path2 in sorted((root / location / "system" / dirname).glob("*.conf")):
>>                   self._parse(root, path2)
>>   
>>       def _parse(self, root, path):
>> @@ -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()
>>
>> 
>>
>


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

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

end of thread, other threads:[~2020-11-23 11:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-02  2:17 [PATCH 0/2] Update check for systemctl kai
2020-11-02  2:17 ` [PATCH 1/2] systemd-systemctl: capable to call without argument kai
2020-11-02  2:17 ` [PATCH 2/2] systemd.bbclass: check whether systemctl works in post scripts kai
     [not found] ` <16438F587D21D644.10137@lists.openembedded.org>
2020-11-17  2:14   ` [OE-core] [PATCH 1/2] systemd-systemctl: capable to call without argument kai
2020-11-23 10:59     ` kai
2020-11-20  2:03   ` kai

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