summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorAlex Kiernan <alex.kiernan@gmail.com>2019-05-08 16:57:28 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-05-09 16:31:56 +0100
commit2a2f74a27dc7005e5130871e084965ff89885a78 (patch)
tree3ddb67c0ada0a6899beac942a5a40294754c0b5b /meta/classes
parent534731e7a7956c3d82c09c9aa01080b19aa818d1 (diff)
downloadpoky-2a2f74a27dc7005e5130871e084965ff89885a78.tar.gz
systemd: Restore mask and preset targets, fix instance creation
Ensure that anyone who sets SYSTEMD_AUTO_ENABLE_${PN} = "mask" (or "preset") retains the previous behaviour. In addition fix "enable" so it can (again) create instance units out of templates. Remove over-zealous quoting of SYSTEMD_SERVICE_ESCAPED as it's already safely escaped (and can be multiple arguments). Reported-by: Paul Barker <paul@betafive.co.uk> (From OE-Core rev: e9444649f49431a8e203e6e2009a1de05e505007) Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/systemd.bbclass37
1 files changed, 28 insertions, 9 deletions
diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index 3935685c18..d1cb17dc8d 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -16,18 +16,36 @@ python __anonymous() {
16 # from doing any work so that pure-systemd images don't have redundant init 16 # from doing any work so that pure-systemd images don't have redundant init
17 # files. 17 # files.
18 if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d): 18 if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d):
19 d.appendVar("DEPENDS", " systemd-systemctl-native")
20 d.appendVar("PACKAGE_WRITE_DEPS", " systemd-systemctl-native")
19 if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d): 21 if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d):
20 d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") 22 d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
21} 23}
22 24
23systemd_postinst() { 25systemd_postinst() {
24if type systemctl >/dev/null 2>/dev/null; then 26if type systemctl >/dev/null 2>/dev/null; then
27 OPTS=""
28
29 if [ -n "$D" ]; then
30 OPTS="--root=$D"
31 fi
32
33 if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
34 for service in ${SYSTEMD_SERVICE_ESCAPED}; do
35 case "${service}" in
36 *@*)
37 systemctl ${OPTS} enable "${service}"
38 ;;
39 esac
40 done
41 fi
42
25 if [ -z "$D" ]; then 43 if [ -z "$D" ]; then
26 systemctl daemon-reload 44 systemctl daemon-reload
27 systemctl preset "${SYSTEMD_SERVICE_ESCAPED}" 45 systemctl preset ${SYSTEMD_SERVICE_ESCAPED}
28 46
29 if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then 47 if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
30 systemctl --no-block restart "${SYSTEMD_SERVICE_ESCAPED}" 48 systemctl --no-block restart ${SYSTEMD_SERVICE_ESCAPED}
31 fi 49 fi
32 fi 50 fi
33fi 51fi
@@ -36,9 +54,9 @@ fi
36systemd_prerm() { 54systemd_prerm() {
37if type systemctl >/dev/null 2>/dev/null; then 55if type systemctl >/dev/null 2>/dev/null; then
38 if [ -z "$D" ]; then 56 if [ -z "$D" ]; then
39 systemctl stop "${SYSTEMD_SERVICE_ESCAPED}" 57 systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
40 58
41 systemctl disable "${SYSTEMD_SERVICE_ESCAPED}" 59 systemctl disable ${SYSTEMD_SERVICE_ESCAPED}
42 fi 60 fi
43fi 61fi
44} 62}
@@ -162,10 +180,7 @@ python systemd_populate_packages() {
162 else: 180 else:
163 bb.fatal("SYSTEMD_SERVICE_%s value %s does not exist" % (pkg_systemd, service)) 181 bb.fatal("SYSTEMD_SERVICE_%s value %s does not exist" % (pkg_systemd, service))
164 182
165 def systemd_create_presets(pkg): 183 def systemd_create_presets(pkg, action):
166 action = get_package_var(d, 'SYSTEMD_AUTO_ENABLE', pkg)
167 if action not in ("enable", "disable"):
168 bb.fatal("SYSTEMD_AUTO_ENABLE_%s '%s' is not 'enable' or 'disable'" % (pkg, action))
169 presetf = oe.path.join(d.getVar("PKGD"), d.getVar("systemd_unitdir"), "system-preset/98-%s.preset" % pkg) 184 presetf = oe.path.join(d.getVar("PKGD"), d.getVar("systemd_unitdir"), "system-preset/98-%s.preset" % pkg)
170 bb.utils.mkdirhier(os.path.dirname(presetf)) 185 bb.utils.mkdirhier(os.path.dirname(presetf))
171 with open(presetf, 'a') as fd: 186 with open(presetf, 'a') as fd:
@@ -179,7 +194,11 @@ python systemd_populate_packages() {
179 systemd_check_package(pkg) 194 systemd_check_package(pkg)
180 if d.getVar('SYSTEMD_SERVICE_' + pkg): 195 if d.getVar('SYSTEMD_SERVICE_' + pkg):
181 systemd_generate_package_scripts(pkg) 196 systemd_generate_package_scripts(pkg)
182 systemd_create_presets(pkg) 197 action = get_package_var(d, 'SYSTEMD_AUTO_ENABLE', pkg)
198 if action in ("enable", "disable"):
199 systemd_create_presets(pkg, action)
200 elif action not in ("mask", "preset"):
201 bb.fatal("SYSTEMD_AUTO_ENABLE_%s '%s' is not 'enable', 'disable', 'mask' or 'preset'" % (pkg, action))
183 systemd_check_services() 202 systemd_check_services()
184} 203}
185 204