From: "Andreas Müller" <schnitzeltony@googlemail.com>
To: openembedded-devel@lists.openembedded.org
Subject: [meta-oe][RFC 01/27] systemd.bbclass: rework
Date: Tue, 7 Feb 2012 16:12:27 +0100 [thread overview]
Message-ID: <1328627573-5217-2-git-send-email-schnitzeltony@googlemail.com> (raw)
In-Reply-To: <1328627573-5217-1-git-send-email-schnitzeltony@googlemail.com>
let systemd.bbclass do more for us and prepare support images without systemd
* introduce a global variable INIT_MANAGER. For images using systemd, this must
contain 'systemd'. This varibale can e.g be set to default in local.conf and
then overridden by distro.
* handle multiple entries in SYSTEMD_SERVICE. Currenly there are no use cases
but networkmanager has potential requirements
* handle multiple entries in SYSTEMD_PACKAGES. Possible use cases are
dhcp/dhcp-relay and ntp/ntpdate
* enhance the checks for SYSTEMD_PACKAGES and SYSTEMD_SERVICE. For package
names only <name-of-an-existing-package>-systemd or ${PN} are allowed. In
case of using ${PN} a warning is spitted. This was introduced to force recipe
maintainers to separate out systemd to own package.
* all systemd packages are automatically created based on SYSTEMD_PACKAGES
* for systemd packets and their base packages RDEPENDS/RRECOMMENDS are
automatically extended. Hereby it is ensured that all packets for proper
systemd operation find their way into the image. Nice side effect:
if in all tasks/images the base packets are include insted of *-systemd it is
only a matter of INIT_MANAGER if systemd-packets are imaged.
* all *.socket and *.service files included by SRC_URI are automatically
installed from WORKDIR.
* remove systemd from DEPENDS. Recipes requiring systemd at buildtime, should
take care themselves.
Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
---
meta-oe/classes/systemd.bbclass | 173 +++++++++++++++++++++++++++++++++-----
1 files changed, 150 insertions(+), 23 deletions(-)
diff --git a/meta-oe/classes/systemd.bbclass b/meta-oe/classes/systemd.bbclass
index 094a12c..c843e66 100644
--- a/meta-oe/classes/systemd.bbclass
+++ b/meta-oe/classes/systemd.bbclass
@@ -1,5 +1,6 @@
-DEPENDS_append = " systemd systemd-systemctl-native"
+DEPENDS_append = " systemd-systemctl-native"
+# pre/post-inst/rm for each entry in SYSTEMD_SERVICE
systemd_postinst() {
OPTS=""
@@ -7,34 +8,95 @@ if [ -n "$D" ]; then
OPTS="--root=$D"
fi
-systemctl $OPTS enable ${SYSTEMD_SERVICE}
+for service in ${SYSTEMD_SERVICE} ; do
+ systemctl $OPTS enable $service
+done
if [ -z "$D" ]; then
- systemctl start ${SYSTEMD_SERVICE}
+ for service in ${SYSTEMD_SERVICE} ; do
+ systemctl start $service
+ done
fi
}
systemd_prerm() {
if [ -z "$D" ]; then
- systemctl stop ${SYSTEMD_SERVICE}
+ for service in ${SYSTEMD_SERVICE} ; do
+ systemctl stop $service
+ done
fi
}
systemd_postrm() {
-systemctl disable ${SYSTEMD_SERVICE}
+for service in ${SYSTEMD_SERVICE} ; do
+ systemctl disable $service
+done
}
def systemd_after_parse(d):
- if bb.data.getVar('SYSTEMD_PACKAGES', d) == None:
- if bb.data.getVar('SYSTEMD_SERVICE', d) == None:
- raise bb.build.FuncFailed, "%s inherits systemd but doesn't set SYSTEMD_SERVICE" % bb.data.getVar('FILE', d)
+ def systemd_check_vars():
+ # not for native / only at parse time
+ if d.getVar('BPN', 1) + "-native" != d.getVar('PN', 1) and d.getVar('BB_WORKERCONTEXT', True) is None:
+ bb_filename = d.getVar('FILE')
+ packages = d.getVar('PACKAGES', 1)
+
+ # check SYSTEMD_PACKAGES
+ systemd_pkgs = d.getVar('SYSTEMD_PACKAGES', 1) or ""
+ if systemd_pkgs == "":
+ raise bb.build.FuncFailed, "\n\n%s inherits systemd but doesn't set SYSTEMD_PACKAGES" % bb_filename
+ for pkg_systemd in systemd_pkgs.split():
+ if pkg_systemd.find("-systemd") == -1:
+ if pkg_systemd != d.getVar('PN', 1):
+ raise (bb.build.FuncFailed,
+ "\n\n%s: %s in SYSTEMD_PACKAGES does not match <base-package-using-systemd>-systemd or ${PN} (deprecated)" %
+ (bb_filename, pkg_systemd))
+ else:
+ bb.warn("%s: it is recommended to set SYSTEMD_PACKAGES as <base-package-using-systemd>-systemd" % bb_filename)
+ else:
+ pkg_systemd_base = pkg_systemd.replace('-systemd', '')
+ if pkg_systemd_base not in packages:
+ raise (bb.build.FuncFailed,
+ "\n\n%s: %s in SYSTEMD_PACKAGES does not match <base-package-using-systemd>-systemd or ${PN} (deprecated)" %
+ ( bb_filename, pkg_systemd))
+
+ # check SYSTEMD_SERVICE
+ for pkg_systemd in systemd_pkgs.split():
+ service_pkg = 'SYSTEMD_SERVICE' + "_" + pkg_systemd
+ systemd_services = d.getVar(service_pkg, 1) or d.getVar('SYSTEMD_SERVICE', 1) or ""
+ if systemd_services == "":
+ raise bb.build.FuncFailed, "\n\n%s inherits systemd but doesn't set SYSTEMD_SERVICE / %s" % (bb_filename, service_pkg)
+
+ # prepend packages not already included
+ def systemd_create_package(pkg_systemd):
+ packages = d.getVar('PACKAGES', 1)
+ if not pkg_systemd in packages:
+ packages = "%s %s" % (pkg_systemd, packages)
+ d.setVar('PACKAGES', packages)
+
+
+ systemd_check_vars()
+ systemd_pkgs = d.getVar('SYSTEMD_PACKAGES', 1)
+ for pkg_systemd in systemd_pkgs.split():
+ systemd_create_package(pkg_systemd)
+
python __anonymous() {
- systemd_after_parse(d)
+ systemd_after_parse(d)
+}
+
+# automatically install all *.service and *.socket supplied in SRC_URI
+do_install_append() {
+ install -d ${D}${base_libdir}/systemd/system
+ for service in `find ${WORKDIR} -maxdepth 1 -name '*.service' -o -name '*.socket'` ; do
+ # ensure installing systemd-files only (e.g not avahi *.service)
+ if grep -q '\[Unit\]' $service ; then
+ install -m 644 $service ${D}${base_libdir}/systemd/system
+ fi
+ done
}
python populate_packages_prepend () {
- def systemd_package(pkg):
+ def systemd_prepost_instrm(pkg):
bb.debug(1, 'adding systemd calls to postinst/postrm for %s' % pkg)
localdata = bb.data.createCopy(d)
overrides = bb.data.getVar("OVERRIDES", localdata, 1)
@@ -45,7 +107,7 @@ python populate_packages_prepend () {
systemd postinst is appended here because pkg_postinst may require to
execute on the target. Not doing so may cause systemd postinst invoked
twice to cause unwanted warnings.
- """
+ """
postinst = bb.data.getVar('pkg_postinst', localdata, 1)
if not postinst:
postinst = '#!/bin/sh\n'
@@ -58,23 +120,88 @@ python populate_packages_prepend () {
prerm += bb.data.getVar('systemd_prerm', localdata, 1)
bb.data.setVar('pkg_prerm_%s' % pkg, prerm, d)
- postrm = bb.data.getVar('pkg_postrm', localdata, 1)
- if not postrm:
- postrm = '#!/bin/sh\n'
- postrm += bb.data.getVar('systemd_postrm', localdata, 1)
+ postrm = bb.data.getVar('pkg_postrm', localdata, 1)
+ if not postrm:
+ postrm = '#!/bin/sh\n'
+ postrm += bb.data.getVar('systemd_postrm', localdata, 1)
bb.data.setVar('pkg_postrm_%s' % pkg, postrm, d)
rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 0) or bb.data.getVar('RDEPENDS', d, 0) or "")
rdepends.append("systemd")
bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
+ """ Setup rdepends / rrecommmends as:
+
+ -----------------------------
+ | pkg_systemd_base: 'foo' |
+ -----------------------------
+ | ^
+ | | --------------
+ rrecommends | | rdepends | 'systemd' |
+ | | ->--------------
+ V | / rdepends
+ ------------------------------/
+ | pkg_systemd: 'foo-systemd' |
+ ------------------------------
+ """
+ def systemd_rdepend_rrecommends(pkg_systemd):
+ pn_pkg = d.getVar('PN', 1)
+ # RDEPENDS_${pkg_systemd} += pkg_systemd_base systemd
+ rdepends = explode_deps(d.getVar('RDEPENDS_' + pkg_systemd, 1) or "")
+ if not 'systemd' in rdepends:
+ rdepends.append('systemd')
+ pkg_systemd_base = pkg_systemd.replace('-systemd', '')
+ # not rdepending myself / avoid double entries
+ if pkg_systemd != pn_pkg and not pkg_systemd_base in rdepends:
+ rdepends.append(pkg_systemd_base)
+ d.setVar('RDEPENDS_' + pkg_systemd, " " + " ".join(rdepends))
+ # default: just a suggestion - to be discussed?
+ initmanager = d.getVar('INIT_MANAGER', 1) or 'systemd'
+ # RRECOMMENDS_${pkg_systemd_base} += pkg_systemd systemd
+ if initmanager == 'systemd':
+ rrecommends = explode_deps(d.getVar('RRECOMMENDS_' + pkg_systemd_base, 1) or "")
+ # not rrecommending myself / avoid double entries
+ if pkg_systemd != pn_pkg and not pkg_systemd in rrecommends:
+ rrecommends.append(pkg_systemd)
+ d.setVar('RRECOMMENDS_' + pkg_systemd_base, " " + " ".join(rrecommends))
+
+ # append systemd files to FILES_*-systemd
+ def systemd_files(pkg_systemd):
+ systemd_services = d.getVar('SYSTEMD_SERVICE' + "_" + pkg_systemd, 1) or d.getVar('SYSTEMD_SERVICE', 1)
+ files_append = ""
+ if len(systemd_pkgs.split()) == 1:
+ # distribute complete ${base_libdir}/systemd/system/ to ${SYSTEMD_PACKAGES}
+ files_append = '${base_libdir}/systemd/system/'
+ else:
+ # distribute files set in SYSTEMD_SERVICE to ${SYSTEMD_PACKAGES}
+ for service in systemd_services.split():
+ files_append += " ${base_libdir}/systemd/system/" + service
+
+ var_name = "FILES_" + pkg_systemd
+ files = d.getVar(var_name, 0) or ""
+ d.setVar(var_name, "%s %s" % (files, files_append))
+
+
+ systemd_pkgs = d.getVar('SYSTEMD_PACKAGES', 1)
+ for pkg_systemd in systemd_pkgs.split():
+ systemd_prepost_instrm(pkg_systemd)
+ systemd_rdepend_rrecommends(pkg_systemd)
+ systemd_files(pkg_systemd)
- pkgs = bb.data.getVar('SYSTEMD_PACKAGES', d, 1)
- if pkgs == None:
- pkgs = bb.data.getVar('PN', d, 1)
- packages = (bb.data.getVar('PACKAGES', d, 1) or "").split()
- if not pkgs in packages and packages != []:
- pkgs = packages[0]
- for pkg in pkgs.split():
- systemd_package(pkg)
+ # temporary debug output found in do_package.log
+ pn_pkg = d.getVar('PN', 1)
+ print 'base-package info:'
+ print 'DEPENDS: %s' % d.getVar('DEPENDS', 1)
+ print 'PACKAGES: %s' % d.getVar('PACKAGES', 1)
+ print 'RDEPENDS_%s: %s' % (pn_pkg, d.getVar('RDEPENDS_' + pn_pkg, 1))
+ print 'RRECOMMENDS_%s: %s' % (pn_pkg, d.getVar('RRECOMMENDS_' + pn_pkg, 1))
+ print 'systemd-(base-)-packages info:'
+ for pkg_systemd in systemd_pkgs.split():
+ pkg_systemd_base = pkg_systemd.replace('-systemd', '')
+ print 'RDEPENDS_%s: %s' % (pkg_systemd_base, d.getVar('RDEPENDS_' + pkg_systemd_base, 1))
+ print 'RDEPENDS_%s: %s' % (pkg_systemd, d.getVar('RDEPENDS_' + pkg_systemd, 1))
+ print 'RRECOMMENDS_%s: %s' % (pkg_systemd_base, d.getVar('RRECOMMENDS_' + pkg_systemd_base, 1))
+ print 'RRECOMMENDS_%s: %s' % (pkg_systemd, d.getVar('RRECOMMENDS_' + pkg_systemd, 1))
+ print 'FILES_%s: %s' % (pkg_systemd_base, d.getVar('FILES_' + pkg_systemd_base, 1))
+ print 'FILES_%s: %s' % (pkg_systemd, d.getVar('FILES_' + pkg_systemd, 1))
}
--
1.7.6.4
next prev parent reply other threads:[~2012-02-07 15:20 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-07 15:12 [meta-oe][RFC 00/27] systemd / initmanager rework Andreas Müller
2012-02-07 15:12 ` Andreas Müller [this message]
2012-02-09 8:14 ` [meta-oe][RFC 01/27] systemd.bbclass: rework Andreas Müller
2012-02-09 11:03 ` Otavio Salvador
2012-02-07 15:12 ` [meta-oe][RFC 02/27] initmanager.bbclass: inital add Andreas Müller
2012-02-07 15:39 ` Paul Eggleton
2012-02-07 15:57 ` Otavio Salvador
2012-02-07 22:53 ` Khem Raj
2012-02-07 15:12 ` [meta-oe][RFC 03/27] image.bbclass: inherit initmanager.bbclass and set default value for IMAGE_INIT_MANAGER Andreas Müller
2012-02-07 15:36 ` Paul Eggleton
2012-02-07 15:59 ` Otavio Salvador
2012-02-07 15:12 ` [meta-oe][RFC 04/27] elsa: remove unneeded systemd code Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 05/27] connman: " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 06/27] openssh: " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 07/27] gateone: " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 08/27] cronie: " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 09/27] xserver-nodm-init: " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 10/27] busybox: " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 11/27] atftp: " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 12/27] gpsd: " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 13/27] gdm: inherit systemd / " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 14/27] dropbear: " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 15/27] cloud9: pack systemd support in ${PN}-systemd / " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 16/27] slim: inherit systemd " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 17/27] udisks: conditional DEPENDS " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 18/27] rsyslog: " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 19/27] polkit: conditional DEPEND systemd Andreas Müller
2012-02-07 15:35 ` Martin Jansa
2012-02-07 15:40 ` Paul Eggleton
2012-02-07 15:12 ` [meta-oe][RFC 20/27] syslog-ng: conditional --enable-systemd --with-systemdsystemunitdir / remove unneeded systemd code Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 21/27] lighthttpd: inherit systemd / added systemd native support " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 22/27] cherokee: " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 23/27] networkmanager: inherit systemd / added NetworkManager-wait-online.service " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 24/27] ntp: add native systemd support for ntpdate " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 25/27] dhcp: add native support for dhcp-relay " Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 26/27] task-basic: replace systemd specific packets by common ones / conditionally RDEPENDS avahi(-systemd) systemd-compat-units Andreas Müller
2012-02-07 15:12 ` [meta-oe][RFC 27/27] task-x11: replace systemd specific packets by common ones Andreas Müller
2012-02-07 15:30 ` Martin Jansa
2012-02-07 15:52 ` [meta-oe][RFC 00/27] systemd / initmanager rework Koen Kooi
2012-02-07 16:24 ` Andreas Müller
2012-02-07 17:14 ` Koen Kooi
2012-02-07 17:58 ` Andreas Müller
2012-02-07 15:55 ` Otavio Salvador
2012-02-07 16:02 ` Koen Kooi
2012-02-07 16:18 ` Otavio Salvador
2012-02-08 0:39 ` Joshua Lock
2012-02-08 8:18 ` Koen Kooi
2012-02-08 11:00 ` Otavio Salvador
2012-02-08 11:07 ` Koen Kooi
2012-02-08 11:12 ` Otavio Salvador
2012-02-08 12:14 ` Koen Kooi
2012-02-08 12:18 ` Paul Eggleton
2012-02-08 12:21 ` Koen Kooi
2012-02-08 12:49 ` Koen Kooi
2012-02-08 12:28 ` Otavio Salvador
2012-02-08 12:43 ` Martin Jansa
2012-02-08 13:05 ` Koen Kooi
2012-02-08 12:51 ` Andreas Müller
2012-02-08 12:54 ` Koen Kooi
2012-02-08 12:56 ` Martin Jansa
2012-02-08 13:19 ` Khem Raj
2012-02-08 15:35 ` Otavio Salvador
2012-02-08 11:31 ` Andreas Müller
2012-02-08 10:57 ` Otavio Salvador
2012-02-07 16:35 ` Andreas Müller
2012-02-07 16:39 ` Otavio Salvador
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1328627573-5217-2-git-send-email-schnitzeltony@googlemail.com \
--to=schnitzeltony@googlemail.com \
--cc=openembedded-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox