diff options
author | Khem Raj <raj.khem@gmail.com> | 2013-02-13 17:25:34 +0000 |
---|---|---|
committer | Martin Jansa <Martin.Jansa@gmail.com> | 2013-04-12 18:48:42 +0200 |
commit | 0afa2a51d2720ed1d6c06aaef17bd90248ef650e (patch) | |
tree | 7cd9308d58e8991c248cb8b10d81d3f008ea7ea6 | |
parent | ed4ef208ef4dccad79d68ad6ee43b63b606b6ea8 (diff) | |
download | meta-openembedded-0afa2a51d2720ed1d6c06aaef17bd90248ef650e.tar.gz |
Delete systemd class.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
-rw-r--r-- | meta-systemd/classes/systemd.bbclass | 233 |
1 files changed, 0 insertions, 233 deletions
diff --git a/meta-systemd/classes/systemd.bbclass b/meta-systemd/classes/systemd.bbclass deleted file mode 100644 index 406936742..000000000 --- a/meta-systemd/classes/systemd.bbclass +++ /dev/null | |||
@@ -1,233 +0,0 @@ | |||
1 | DEPENDS_append = " systemd-systemctl-native" | ||
2 | |||
3 | SYSTEMD_AUTO_ENABLE ??= "enable" | ||
4 | |||
5 | SYSTEMD_AUTO_RRECOMMENDS ??= "enable" | ||
6 | |||
7 | systemd_postinst() { | ||
8 | OPTS="" | ||
9 | |||
10 | if [ -n "$D" ]; then | ||
11 | OPTS="--root=$D" | ||
12 | fi | ||
13 | |||
14 | systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE} | ||
15 | |||
16 | if [ -z "$D" -a ${SYSTEMD_AUTO_ENABLE} = "enable" ]; then | ||
17 | systemctl start ${SYSTEMD_SERVICE} | ||
18 | fi | ||
19 | } | ||
20 | |||
21 | systemd_prerm() { | ||
22 | if [ -z "$D" ]; then | ||
23 | systemctl stop ${SYSTEMD_SERVICE} | ||
24 | fi | ||
25 | |||
26 | systemctl disable ${SYSTEMD_SERVICE} | ||
27 | } | ||
28 | |||
29 | def get_package_var(d, var, pkg): | ||
30 | val = (d.getVar('%s_%s' % (var, pkg), 1) or "").strip() | ||
31 | if val == "": | ||
32 | val = (d.getVar(var, 1) or "").strip() | ||
33 | return val | ||
34 | |||
35 | def systemd_after_parse(d): | ||
36 | features = d.getVar("DISTRO_FEATURES", True).split() | ||
37 | # If the distro features have systemd but not sysvinit, inhibit update-rcd | ||
38 | # from doing any work so that pure-systemd images don't have redundant init | ||
39 | # files. | ||
40 | if "systemd" in features: | ||
41 | if "sysvinit" not in features: | ||
42 | d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") | ||
43 | |||
44 | def systemd_check_vars(): | ||
45 | if d.getVar('BB_WORKERCONTEXT', True) is not None: | ||
46 | return | ||
47 | |||
48 | bb_filename = d.getVar('FILE') | ||
49 | packages = d.getVar('PACKAGES', 1) | ||
50 | |||
51 | # check SYSTEMD_PACKAGES | ||
52 | systemd_pkgs = d.getVar('SYSTEMD_PACKAGES', 1) or "" | ||
53 | if systemd_pkgs == "": | ||
54 | raise bb.build.FuncFailed, "\n\n%s inherits systemd but doesn't set SYSTEMD_PACKAGES" % bb_filename | ||
55 | for pkg_systemd in systemd_pkgs.split(): | ||
56 | if pkg_systemd.find("-systemd") == -1: | ||
57 | if pkg_systemd != d.getVar('PN', 1): | ||
58 | raise bb.build.FuncFailed, \ | ||
59 | "\n\n%s: %s in SYSTEMD_PACKAGES does not match <existing-package>-systemd or ${PN}" % \ | ||
60 | (bb_filename, pkg_systemd) | ||
61 | else: | ||
62 | pkg_systemd_base = pkg_systemd | ||
63 | if pkg_systemd_base.endswith('-systemd'): | ||
64 | pkg_systemd_base = pkg_systemd[:-8] | ||
65 | if pkg_systemd_base not in packages: | ||
66 | raise bb.build.FuncFailed, \ | ||
67 | "\n\n%s: %s in SYSTEMD_PACKAGES does not match <existing-package>-systemd or ${PN}" % \ | ||
68 | ( bb_filename, pkg_systemd) | ||
69 | |||
70 | # prepend systemd-packages not already included | ||
71 | def systemd_create_package(pkg_systemd): | ||
72 | packages = d.getVar('PACKAGES', 1) | ||
73 | if not pkg_systemd in packages: | ||
74 | packages = "%s %s" % (pkg_systemd, packages) | ||
75 | d.setVar('PACKAGES', packages) | ||
76 | |||
77 | |||
78 | bpn = d.getVar('BPN', 1) | ||
79 | ml = d.getVar('MLPREFIX', 1) or "" | ||
80 | if bpn + "-native" != d.getVar('PN', 1) and \ | ||
81 | bpn + "-cross" != d.getVar('PN', 1) and \ | ||
82 | ml + bpn == d.getVar('PN', 1) and \ | ||
83 | "nativesdk-" + bpn != d.getVar('PN', 1): | ||
84 | systemd_check_vars() | ||
85 | for pkg_systemd in d.getVar('SYSTEMD_PACKAGES', 1).split(): | ||
86 | systemd_create_package(pkg_systemd) | ||
87 | |||
88 | |||
89 | python __anonymous() { | ||
90 | systemd_after_parse(d) | ||
91 | } | ||
92 | |||
93 | # automatically install all *.service and *.socket supplied in recipe's SRC_URI | ||
94 | do_install_append() { | ||
95 | for service in `find ${WORKDIR} -maxdepth 1 -name '*.service' -o -name '*.socket'` ; do | ||
96 | # ensure installing systemd-files only (e.g not avahi *.service) | ||
97 | if grep -q '\[Unit\]' $service ; then | ||
98 | install -d ${D}${systemd_unitdir}/system | ||
99 | install -m 644 $service ${D}${systemd_unitdir}/system | ||
100 | fi | ||
101 | done | ||
102 | } | ||
103 | |||
104 | python populate_packages_prepend () { | ||
105 | def systemd_generate_package_scripts(pkg): | ||
106 | bb.debug(1, 'adding systemd calls to postinst/postrm for %s' % pkg) | ||
107 | localdata = d.createCopy() | ||
108 | overrides = localdata.getVar("OVERRIDES", 1) | ||
109 | localdata.setVar("OVERRIDES", "%s:%s" % (pkg, overrides)) | ||
110 | bb.data.update_data(localdata) | ||
111 | |||
112 | """ | ||
113 | systemd postinst is appended here because pkg_postinst may require to | ||
114 | execute on the target. Not doing so may cause systemd postinst invoked | ||
115 | twice to cause unwanted warnings. | ||
116 | """ | ||
117 | postinst = localdata.getVar('pkg_postinst', 1) | ||
118 | if not postinst: | ||
119 | postinst = '#!/bin/sh\n' | ||
120 | postinst += localdata.getVar('systemd_postinst', 1) | ||
121 | d.setVar('pkg_postinst_%s' % pkg, postinst) | ||
122 | |||
123 | prerm = localdata.getVar('pkg_prerm', 1) | ||
124 | if not prerm: | ||
125 | prerm = '#!/bin/sh\n' | ||
126 | prerm += localdata.getVar('systemd_prerm', 1) | ||
127 | d.setVar('pkg_prerm_%s' % pkg, prerm) | ||
128 | |||
129 | # add files to FILES_*-systemd if existent and not already done | ||
130 | def systemd_append_file(pkg_systemd, file_append): | ||
131 | appended = False | ||
132 | if os.path.exists('${D}' + file_append): | ||
133 | var_name = "FILES_" + pkg_systemd | ||
134 | files = d.getVar(var_name, 0) or "" | ||
135 | if file_append not in files.split(): | ||
136 | d.setVar(var_name, "%s %s" % (files, file_append)) | ||
137 | appended = True | ||
138 | return appended | ||
139 | |||
140 | # add systemd files to FILES_*-systemd, parse for Also= and follow recursive | ||
141 | def systemd_add_files_and_parse(pkg_systemd, path, service, keys): | ||
142 | # avoid infinite recursion | ||
143 | if systemd_append_file(pkg_systemd, path + service): | ||
144 | fullpath = '${D}' + path + service | ||
145 | if service.find('.socket') != -1: | ||
146 | # for *.socket add *.service and *@.service | ||
147 | service_base = service.replace('.socket', '') | ||
148 | systemd_add_files_and_parse(pkg_systemd, path, service_base + '.service', keys) | ||
149 | systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service', keys) | ||
150 | for key in keys.split(): | ||
151 | # recurse all dependencies found in keys ('Also';'Conflicts';..) and add to files | ||
152 | cmd = "grep %s %s | sed 's,%s=,,g' | tr ',' '\\n'" % (key, fullpath, key) | ||
153 | pipe = os.popen(cmd, 'r') | ||
154 | line = pipe.readline() | ||
155 | while line: | ||
156 | line = line.replace('\n', '') | ||
157 | systemd_add_files_and_parse(pkg_systemd, path, line, keys) | ||
158 | line = pipe.readline() | ||
159 | pipe.close() | ||
160 | |||
161 | # check service-files and call systemd_add_files_and_parse for each entry | ||
162 | def systemd_check_services(): | ||
163 | base_libdir = d.getVar('base_libdir', 1) | ||
164 | searchpaths = '/etc/systemd/system/' + ' ' | ||
165 | searchpaths += '/lib/systemd/system/' + ' ' | ||
166 | searchpaths += '/usr/lib/systemd/system/' + ' ' | ||
167 | systemd_packages = d.getVar('SYSTEMD_PACKAGES', 1) | ||
168 | has_exactly_one_service = len(systemd_packages.split()) == 1 | ||
169 | if has_exactly_one_service: | ||
170 | has_exactly_one_service = len(get_package_var(d, 'SYSTEMD_SERVICE', systemd_packages).split()) == 1 | ||
171 | |||
172 | keys = 'Also' # Conflicts?? | ||
173 | if has_exactly_one_service: | ||
174 | # single service gets also the /dev/null dummies | ||
175 | keys = 'Also Conflicts' | ||
176 | # scan for all in SYSTEMD_SERVICE[] | ||
177 | for pkg_systemd in systemd_packages.split(): | ||
178 | for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split(): | ||
179 | path_found = '' | ||
180 | for path in searchpaths.split(): | ||
181 | if os.path.exists('${D}' + path + service): | ||
182 | path_found = path | ||
183 | if path_found != '': | ||
184 | systemd_add_files_and_parse(pkg_systemd, path_found, service, keys) | ||
185 | else: | ||
186 | raise bb.build.FuncFailed, "\n\nFor package %s SYSTEMD_SERVICE-entry %s does not exist" % \ | ||
187 | (pkg_systemd, service) | ||
188 | |||
189 | """ Setup rdepends / rrecommmends as: | ||
190 | |||
191 | ----------------------------- | ||
192 | | pkg_systemd_base: 'foo' | | ||
193 | ----------------------------- | ||
194 | | ^ | ||
195 | | | -------------- | ||
196 | rrecommends | | rdepends | 'systemd' | | ||
197 | | | ->-------------- | ||
198 | V | / rdepends | ||
199 | ------------------------------/ | ||
200 | | pkg_systemd: 'foo-systemd' | | ||
201 | ------------------------------ | ||
202 | """ | ||
203 | def systemd_add_rdepends_rrecommends(pkg_systemd): | ||
204 | # RDEPENDS_${pkg_systemd} += pkg_systemd_base systemd | ||
205 | rdepends = d.getVar('RDEPENDS_' + pkg_systemd, 1) or "" | ||
206 | rdepends_arr = rdepends.split() | ||
207 | if not 'systemd' in rdepends_arr: | ||
208 | rdepends = '%s %s' % (rdepends, 'systemd') | ||
209 | pkg_systemd_base = pkg_systemd.replace('-systemd', '') | ||
210 | # no automatism for: | ||
211 | # recipes setting rdepends themselves AND | ||
212 | # not rdepending myself AND | ||
213 | # avoid double entries | ||
214 | if len(rdepends_arr) == 0 and pkg_systemd != '${PN}' and not pkg_systemd_base in rdepends: | ||
215 | rdepends = '%s %s' % (rdepends, pkg_systemd_base) | ||
216 | d.setVar('RDEPENDS_' + pkg_systemd, rdepends) | ||
217 | auto_rrecommends = d.getVar('SYSTEMD_AUTO_RRECOMMENDS', 1) or 'enable' | ||
218 | if auto_rrecommends == 'enable': | ||
219 | # RRECOMMENDS_${pkg_systemd_base} += pkg_systemd systemd | ||
220 | rrecommends = d.getVar('RRECOMMENDS_' + pkg_systemd_base, 1) or "" | ||
221 | # not rrecommending myself AND avoid double entries | ||
222 | if pkg_systemd != pkg_systemd_base and not pkg_systemd in rrecommends.split(): | ||
223 | rrecommends = '%s %s' % (rrecommends, pkg_systemd) | ||
224 | d.setVar('RRECOMMENDS_' + pkg_systemd_base, rrecommends) | ||
225 | |||
226 | # run all modifications once when creating package | ||
227 | if os.path.exists('${D}'): | ||
228 | for pkg_systemd in d.getVar('SYSTEMD_PACKAGES', 1).split(): | ||
229 | if get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd) != "": | ||
230 | systemd_generate_package_scripts(pkg_systemd) | ||
231 | systemd_add_rdepends_rrecommends(pkg_systemd) | ||
232 | systemd_check_services() | ||
233 | } | ||