Patchwork [meta-oe,V3,03/23] systemd.bbclass: enhance checks for SYSTEMD_PACKAGES and SYSTEMD_SERVICE

login
register
mail settings
Submitter Andreas Müller
Date Feb. 23, 2012, 12:10 p.m.
Message ID <1329999054-23112-4-git-send-email-schnitzeltony@googlemail.com>
Download mbox | patch
Permalink /patch/21673/
State Accepted
Headers show

Comments

Andreas Müller - Feb. 23, 2012, 12:10 p.m.
after recipe parsing the following plausibilities are checked:
* ERROR if empty SYSTEMD_PACKAGES
* ERROR if SYSTEMD_PACKAGES entry does not contain '-systemd' AND
  package_name != ${PN}
* ERROR if SYSTEMD_PACKAGES entry contains '-systemd' but entry without
  '-systemd' (base pkg) does not exist
* WARNING if SYSTEMD_PACKAGES containing ${PN} to force package maintainers to
  split out systemd-specific files into *-systemd
* error if SYSTEMD_SERVICE(_<systemd-package>) is empty for one or more entries
  in SYSTEMD_PACKAGES

The code in populate_packages_prepend to set SYSTEMD_PACKAGES to ${PN} as
default was removed.

Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
Acked-by: Otavio Salvador <otavio@ossystems.com.br>
---
 meta-oe/classes/systemd.bbclass |   47 ++++++++++++++++++++++++++++++++------
 1 files changed, 39 insertions(+), 8 deletions(-)

Patch

diff --git a/meta-oe/classes/systemd.bbclass b/meta-oe/classes/systemd.bbclass
index 91faab9..a99036c 100644
--- a/meta-oe/classes/systemd.bbclass
+++ b/meta-oe/classes/systemd.bbclass
@@ -27,9 +27,45 @@  systemctl disable ${SYSTEMD_SERVICE}
 }
 
 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():
+		bpn = d.getVar('BPN', 1)
+		# not for native / only at parse time
+		if d.getVar('BB_WORKERCONTEXT', True) is None and \
+		bpn + "-native" != d.getVar('PN', 1) and \
+		bpn + "-cross" != d.getVar('PN', 1) and \
+		bpn + "-nativesdk" != d.getVar('PN', 1):
+			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 <existing-package>-systemd or ${PN} (deprecated)" % \
+							(bb_filename, pkg_systemd)
+					else:
+						bb.warn("%s: it is recommended to set SYSTEMD_PACKAGES as <existing-package>-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 <existing-package>-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)
+
+
+	systemd_check_vars()
+
 
 python __anonymous() {
     systemd_after_parse(d)
@@ -72,11 +108,6 @@  python populate_packages_prepend () {
 
 
 	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)
 }