diff options
author | Andreas Müller <schnitzeltony@googlemail.com> | 2012-02-22 14:22:53 +0100 |
---|---|---|
committer | Koen Kooi <koen@dominion.thruhere.net> | 2012-02-23 16:46:31 +0100 |
commit | 4c66cea57941e0048c5635e5b0ef7ec430d2f828 (patch) | |
tree | 3b019ab1273ef0f5de6edbeb2131ed6cfee5199f /meta-oe/classes | |
parent | 916b26ef7d8c3779616763ceca144380bd6c058c (diff) | |
download | meta-openembedded-4c66cea57941e0048c5635e5b0ef7ec430d2f828.tar.gz |
systemd.bbclass: automatically extend FILES_* for systemd packages
* Add files found in SYSTEMD_SERVICE and add service files referenced by 'Also='
(and 'Conflicts=' in case of one service for links to /dev/null) recursively.
* For *.socket files the corresponding '*.service' and '*@.service are packed
* In case a file set in SYSTEMD_SERVICE does not exist, build is aborted with an
error message.
Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Diffstat (limited to 'meta-oe/classes')
-rw-r--r-- | meta-oe/classes/systemd.bbclass | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/meta-oe/classes/systemd.bbclass b/meta-oe/classes/systemd.bbclass index e13f09dc3e..c712e17c34 100644 --- a/meta-oe/classes/systemd.bbclass +++ b/meta-oe/classes/systemd.bbclass @@ -126,9 +126,69 @@ python populate_packages_prepend () { rdepends.append("systemd") bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d) + # add files to FILES_*-systemd if existent and not already done + def systemd_append_file(pkg_systemd, file_append): + appended = False + if os.path.exists('${D}' + file_append): + var_name = "FILES_" + pkg_systemd + files = d.getVar(var_name, 0) or "" + if file_append not in files.split(): + d.setVar(var_name, "%s %s" % (files, file_append)) + appended = True + return appended + + # add systemd files to FILES_*-systemd, parse for Also= and follow recursive + def systemd_add_files_and_parse(pkg_systemd, path, service, keys): + # avoid infinite recursion + if systemd_append_file(pkg_systemd, path + service): + fullpath = '${D}' + path + service + if service.find('.socket') != -1: + # for *.socket add *.service and *@.service + service_base = service.replace('.socket', '') + systemd_add_files_and_parse(pkg_systemd, path, service_base + '.service', keys) + systemd_add_files_and_parse(pkg_systemd, path, service_base + '@.service', keys) + for key in keys.split(): + # recurse all dependencies found in keys ('Also';'Conflicts';..) and add to files + cmd = "grep %s %s | sed 's,%s=,,g' | tr ',' '\\n'" % (key, fullpath, key) + pipe = os.popen(cmd, 'r') + line = pipe.readline() + while line: + line = line.replace('\n', '') + systemd_add_files_and_parse(pkg_systemd, path, line, keys) + line = pipe.readline() + pipe.close() + + # check service-files and call systemd_add_files_and_parse for each entry + def systemd_check_services(): + searchpaths = '/etc/systemd/system/ /lib/systemd/system/ /usr/lib/systemd/system/' + systemd_packages = d.getVar('SYSTEMD_PACKAGES', 1) + has_exactly_one_service = len(systemd_packages.split()) == 1 + if has_exactly_one_service: + systemd_services = d.getVar('SYSTEMD_SERVICE' + "_" + systemd_packages, 1) or d.getVar('SYSTEMD_SERVICE', 1) + has_exactly_one_service = len(systemd_services.split()) == 1 + + keys = 'Also' # Conflicts?? + if has_exactly_one_service: + # single service gets also the /dev/null dummies + keys = 'Also Conflicts' + # scan for all in SYSTEMD_SERVICE[] + for pkg_systemd in systemd_packages.split(): + systemd_services = d.getVar('SYSTEMD_SERVICE' + "_" + pkg_systemd, 1) or d.getVar('SYSTEMD_SERVICE', 1) + for service in systemd_services.split(): + path_found = '' + for path in searchpaths.split(): + if os.path.exists('${D}' + path + service): + path_found = path + if path_found != '': + systemd_add_files_and_parse(pkg_systemd, path_found, service, keys) + else: + raise bb.build.FuncFailed, "\n\nFor package %s SYSTEMD_SERVICE-entry %s does not exist" % \ + (pkg_systemd, service) + # run all modifications once when creating package if os.path.exists('${D}'): for pkg_systemd in d.getVar('SYSTEMD_PACKAGES', 1).split(): systemd_generate_package_scripts(pkg_systemd) + systemd_check_services() } |