Patchwork [meta-oe,v3,3/4] systemd.bbclass: extract SYSTEMD_SERVICE properly

login
register
mail settings
Submitter Andreas Müller
Date June 1, 2012, 9:20 a.m.
Message ID <1338542426-29985-3-git-send-email-schnitzeltony@googlemail.com>
Download mbox | patch
Permalink /patch/29073/
State Accepted
Commit b52a74b7a245a28dcdd91c3336e1cd86604befac
Headers show

Comments

Andreas Müller - June 1, 2012, 9:20 a.m.
To set service files the following syntax is allowed:

SYSTEMD_SERVICE = <service_file>
or
SYSTEMD_SERVICE_{<systemd_package_name>} = <service_file>

A function get_package_var was introduced to handle all use-cases [1]
properly.

Build tested / buildhistory checks

[1] http://lists.linuxtogo.org/pipermail/openembedded-devel/2012-May/039870.html

Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
---
 meta-oe/classes/systemd.bbclass |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
Martin Jansa - June 4, 2012, 12:50 p.m.
On Fri, Jun 01, 2012 at 11:20:25AM +0200, Andreas Müller wrote:
> To set service files the following syntax is allowed:
> 
> SYSTEMD_SERVICE = <service_file>
> or
> SYSTEMD_SERVICE_{<systemd_package_name>} = <service_file>
> 
> A function get_package_var was introduced to handle all use-cases [1]
> properly.
> 
> Build tested / buildhistory checks
> 
> [1] http://lists.linuxtogo.org/pipermail/openembedded-devel/2012-May/039870.html

whole patchset looks good:

Acked-by: Martin Jansa <Martin.Jansa@gmail.com>

> 
> Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
> ---
>  meta-oe/classes/systemd.bbclass |   14 +++++++++-----
>  1 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/meta-oe/classes/systemd.bbclass b/meta-oe/classes/systemd.bbclass
> index 2881abf..2e585c3 100644
> --- a/meta-oe/classes/systemd.bbclass
> +++ b/meta-oe/classes/systemd.bbclass
> @@ -24,6 +24,12 @@ systemd_postrm() {
>  systemctl disable ${SYSTEMD_SERVICE}
>  }
>  
> +def get_package_var(d, var, pkg):
> +	val = (d.getVar('%s_%s' % (var, pkg), d, 1) or "").strip()
> +	if val == "":
> +		val = (d.getVar(var, d, 1) or "").strip()
> +	return val
> +
>  def systemd_after_parse(d):
>  	def systemd_check_vars():
>  		if d.getVar('BB_WORKERCONTEXT', True) is not None:
> @@ -155,8 +161,7 @@ python populate_packages_prepend () {
>  		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
> +			has_exactly_one_service = len(get_package_var(d, 'SYSTEMD_SERVICE', systemd_packages).split()) == 1
>  
>  		keys = 'Also' # Conflicts??
>  		if has_exactly_one_service:
> @@ -164,8 +169,7 @@ python populate_packages_prepend () {
>  			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():
> +			for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split():
>  				path_found = ''
>  				for path in searchpaths.split():
>  					if os.path.exists('${D}' + path + service):
> @@ -196,7 +200,7 @@ python populate_packages_prepend () {
>  	# run all modifications once when creating package
>  	if os.path.exists('${D}'):
>  		for pkg_systemd in d.getVar('SYSTEMD_PACKAGES', 1).split():
> -			if d.getVar('SYSTEMD_SERVICE' + "_" + pkg_systemd, 1) and d.getVar('SYSTEMD_SERVICE' + "_" + pkg_systemd, 1).strip():
> +			if get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd) != "":
>  				systemd_generate_package_scripts(pkg_systemd)
>  				systemd_add_rdepends(pkg_systemd)
>  		systemd_check_services()
> -- 
> 1.7.6.5
> 
> 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

Patch

diff --git a/meta-oe/classes/systemd.bbclass b/meta-oe/classes/systemd.bbclass
index 2881abf..2e585c3 100644
--- a/meta-oe/classes/systemd.bbclass
+++ b/meta-oe/classes/systemd.bbclass
@@ -24,6 +24,12 @@  systemd_postrm() {
 systemctl disable ${SYSTEMD_SERVICE}
 }
 
+def get_package_var(d, var, pkg):
+	val = (d.getVar('%s_%s' % (var, pkg), d, 1) or "").strip()
+	if val == "":
+		val = (d.getVar(var, d, 1) or "").strip()
+	return val
+
 def systemd_after_parse(d):
 	def systemd_check_vars():
 		if d.getVar('BB_WORKERCONTEXT', True) is not None:
@@ -155,8 +161,7 @@  python populate_packages_prepend () {
 		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
+			has_exactly_one_service = len(get_package_var(d, 'SYSTEMD_SERVICE', systemd_packages).split()) == 1
 
 		keys = 'Also' # Conflicts??
 		if has_exactly_one_service:
@@ -164,8 +169,7 @@  python populate_packages_prepend () {
 			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():
+			for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split():
 				path_found = ''
 				for path in searchpaths.split():
 					if os.path.exists('${D}' + path + service):
@@ -196,7 +200,7 @@  python populate_packages_prepend () {
 	# run all modifications once when creating package
 	if os.path.exists('${D}'):
 		for pkg_systemd in d.getVar('SYSTEMD_PACKAGES', 1).split():
-			if d.getVar('SYSTEMD_SERVICE' + "_" + pkg_systemd, 1) and d.getVar('SYSTEMD_SERVICE' + "_" + pkg_systemd, 1).strip():
+			if get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd) != "":
 				systemd_generate_package_scripts(pkg_systemd)
 				systemd_add_rdepends(pkg_systemd)
 		systemd_check_services()