summaryrefslogtreecommitdiffstats
path: root/meta/classes/systemd.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/systemd.bbclass')
-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