Update the criterion whether command systemctl available in systemd.bbclass
v3 cover Update the criterion whether command systemctl available in systemd.bbclass
From: Kai Kang <[email protected]>
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(-)
Signature · 1 line
2.17.1
PATCH v3 1/2 systemd-systemctl-native: capable to call without argument
From: Kai Kang <[email protected]>
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.
--- meta/recipes-core/systemd/systemd-systemctl/systemctl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
meta/recipes-core/systemd/systemd-systemctl/systemctl +6 -2
@@ -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 v3 2/2 systemd.bbclass: update command to check systemctl available
In reply to kaiFrom: Kai Kang <[email protected]>
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.
--- 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