summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/systemd.bbclass41
1 files changed, 19 insertions, 22 deletions
diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index c8f4fdec88..3935685c18 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -16,45 +16,30 @@ 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")
21 if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d): 19 if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d):
22 d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") 20 d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
23} 21}
24 22
25systemd_postinst() { 23systemd_postinst() {
26OPTS=""
27
28if [ -n "$D" ]; then
29 OPTS="--root=$D"
30fi
31
32if type systemctl >/dev/null 2>/dev/null; then 24if type systemctl >/dev/null 2>/dev/null; then
33 if [ -z "$D" ]; then 25 if [ -z "$D" ]; then
34 systemctl daemon-reload 26 systemctl daemon-reload
35 fi 27 systemctl preset "${SYSTEMD_SERVICE_ESCAPED}"
36
37 systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE_ESCAPED}
38 28
39 if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then 29 if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
40 systemctl --no-block restart ${SYSTEMD_SERVICE_ESCAPED} 30 systemctl --no-block restart "${SYSTEMD_SERVICE_ESCAPED}"
31 fi
41 fi 32 fi
42fi 33fi
43} 34}
44 35
45systemd_prerm() { 36systemd_prerm() {
46OPTS=""
47
48if [ -n "$D" ]; then
49 OPTS="--root=$D"
50fi
51
52if type systemctl >/dev/null 2>/dev/null; then 37if type systemctl >/dev/null 2>/dev/null; then
53 if [ -z "$D" ]; then 38 if [ -z "$D" ]; then
54 systemctl stop ${SYSTEMD_SERVICE_ESCAPED} 39 systemctl stop "${SYSTEMD_SERVICE_ESCAPED}"
55 fi
56 40
57 systemctl $OPTS disable ${SYSTEMD_SERVICE_ESCAPED} 41 systemctl disable "${SYSTEMD_SERVICE_ESCAPED}"
42 fi
58fi 43fi
59} 44}
60 45
@@ -177,12 +162,24 @@ python systemd_populate_packages() {
177 else: 162 else:
178 bb.fatal("SYSTEMD_SERVICE_%s value %s does not exist" % (pkg_systemd, service)) 163 bb.fatal("SYSTEMD_SERVICE_%s value %s does not exist" % (pkg_systemd, service))
179 164
165 def systemd_create_presets(pkg):
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)
170 bb.utils.mkdirhier(os.path.dirname(presetf))
171 with open(presetf, 'a') as fd:
172 for service in d.getVar('SYSTEMD_SERVICE_%s' % pkg).split():
173 fd.write("%s %s\n" % (action,service))
174 d.appendVar("FILES_%s" % pkg, ' ' + oe.path.join(d.getVar("systemd_unitdir"), "system-preset/98-%s.preset" % pkg))
175
180 # Run all modifications once when creating package 176 # Run all modifications once when creating package
181 if os.path.exists(d.getVar("D")): 177 if os.path.exists(d.getVar("D")):
182 for pkg in d.getVar('SYSTEMD_PACKAGES').split(): 178 for pkg in d.getVar('SYSTEMD_PACKAGES').split():
183 systemd_check_package(pkg) 179 systemd_check_package(pkg)
184 if d.getVar('SYSTEMD_SERVICE_' + pkg): 180 if d.getVar('SYSTEMD_SERVICE_' + pkg):
185 systemd_generate_package_scripts(pkg) 181 systemd_generate_package_scripts(pkg)
182 systemd_create_presets(pkg)
186 systemd_check_services() 183 systemd_check_services()
187} 184}
188 185