Update check for systemctl
cover Update check for systemctl
From: Kai Kang <[email protected]>
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(-)
Signature · 1 line
2.17.1
PATCH 1/2 systemd-systemctl: capable to call without argument
From: Kai Kang <[email protected]>
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.
--- meta/recipes-core/systemd/systemd-systemctl/systemctl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
meta/recipes-core/systemd/systemd-systemctl/systemctl +7 -3
@@ -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()
Signature · 1 line
2.17.1
PATCH 2/2 systemd.bbclass: check whether systemctl works in post scripts
In reply to kaiFrom: Kai Kang <[email protected]>
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.
--- meta/classes/systemd.bbclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/systemd.bbclass +2 -2
@@ -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}
Signature · 1 line
2.17.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [OE-core] [PATCH 1/2] systemd-systemctl: capable to call without argument
Ping.
Quoted 50 lines · kai
From: Kai Kang <[email protected]>
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 <[email protected]>--- meta/recipes-core/systemd/systemd-systemctl/systemctl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)meta/recipes-core/systemd/systemd-systemctl/systemctl +7
-3@@ -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()
Re: [OE-core] [PATCH 1/2] systemd-systemctl: capable to call without argument
Quoted 1 line · Kai
Ping.
Ping...
Quoted 53 lines · kai
Quoted 50 lines
From: Kai Kang<[email protected]>
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<[email protected]>--- meta/recipes-core/systemd/systemd-systemctl/systemctl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)meta/recipes-core/systemd/systemd-systemctl/systemctl +7
-3@@ -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()
Re: [OE-core] [PATCH 1/2] systemd-systemctl: capable to call without argument
In reply to a message not in the archiveAny comment, please?
Thanks,
Kai
Quoted 50 lines · kai
From: Kai Kang <[email protected]>
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 <[email protected]>--- meta/recipes-core/systemd/systemd-systemctl/systemctl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)meta/recipes-core/systemd/systemd-systemctl/systemctl +7
-3@@ -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()