[oe] [meta-oe][v2] 06/22] systemd.bbclass: automatically extend FILES_* for systemd packages
Andreas Müller
schnitzeltony at googlemail.com
Thu Feb 16 02:03:00 UTC 2012
Add files found in SYSTEMD_SERVICE and add service files found at 'Also='
recursively. In case a file set in SYSTEMD_SERVICE build is aborted with an
error message.
For recipes with one *-systemd package and one service additional files are
packed:
* all *@.service
* some recipes add links to /dev/null. These are found by parsing also for
'Conflicts='
Signed-off-by: Andreas Müller <schnitzeltony at googlemail.com>
---
meta-oe/classes/systemd.bbclass | 64 +++++++++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/meta-oe/classes/systemd.bbclass b/meta-oe/classes/systemd.bbclass
index b2cf775..1e0f3e0 100644
--- a/meta-oe/classes/systemd.bbclass
+++ b/meta-oe/classes/systemd.bbclass
@@ -124,7 +124,71 @@ python populate_packages_prepend () {
rdepends.append("systemd")
bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
+ # add files to FILES_*-systemd if not already done
+ def systemd_append_file(pkg_systemd, file_append):
+ if os.path.exists(d.getVar('D', 1) + file_append):
+ var_name = "FILES_" + pkg_systemd
+ files = d.getVar(var_name, 0) or ""
+ d.setVar(var_name, "%s %s" % (files, file_append))
+ else:
+ bb.debug(1, '%s is not appended to package %s' % (file_append, pkg_systemd))
+
+ # add systemd files to FILES_*-systemd, parse for Also= and follow recursive
+ def systemd_add_files_and_parse(pkg_systemd, path, service, keys):
+ systemd_append_file(pkg_systemd, path + service)
+ fullpath = d.getVar('D', 1) + path + service
+ for key in keys.split():
+ # recurse all 'also' dependencies 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():
+ root = d.getVar('D', 1)
+ 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??
+ # to match more cases, single service get's more
+ if has_exactly_one_service:
+ # single service gets also the /dev/null dummies
+ keys = 'Also Conflicts'
+ # parse *@.service files for recipes with one service
+ for path in searchpaths.split():
+ cmd = "find ${D}/%s -maxdepth 1 -name '*@.service'" % path
+ pipe = os.popen(cmd, 'r')
+ line = pipe.readline()
+ while line:
+ line = os.path.basename(line.replace('\n', ''))
+ systemd_add_files_and_parse(systemd_packages, path, line, keys)
+ line = pipe.readline()
+ pipe.close()
+ # 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(root + 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)
+
for pkg_systemd in d.getVar('SYSTEMD_PACKAGES', 1).split():
systemd_generate_package_scripts(pkg_systemd)
+ systemd_check_services()
}
--
1.7.4.4
More information about the Openembedded-devel
mailing list