Patchwork [1/2] useradd.bbclass: handle nativesdk case

login
register
mail settings
Submitter Eric BENARD
Date Nov. 7, 2011, 9:11 p.m.
Message ID <1320700315-11952-1-git-send-email-eric@eukrea.com>
Download mbox | patch
Permalink /patch/14447/
State New
Headers show

Comments

Eric BENARD - Nov. 7, 2011, 9:11 p.m.
* without this patch, building dbus-nativesdk leads to a missing
dependency on 'base-passwd-nativesdk'
This was added by commit 46e6c3fa8034b12d178d605f3f5d7efe69671a13
* this patch handle the nativesdk case in the class useradd
* close bug 1702 http://bugzilla.pokylinux.org/show_bug.cgi?id=1702

Signed-off-by: Eric Bénard <eric@eukrea.com>
---
 meta/classes/useradd.bbclass |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)
Scott Garman - Nov. 7, 2011, 9:32 p.m.
On 11/07/2011 01:11 PM, Eric Bénard wrote:
> * without this patch, building dbus-nativesdk leads to a missing
> dependency on 'base-passwd-nativesdk'
> This was added by commit 46e6c3fa8034b12d178d605f3f5d7efe69671a13
> * this patch handle the nativesdk case in the class useradd
> * close bug 1702 http://bugzilla.pokylinux.org/show_bug.cgi?id=1702
>
> Signed-off-by: Eric Bénard<eric@eukrea.com>

Acked-by: Scott Garman <scott.a.garman@intel.com>

> ---
>   meta/classes/useradd.bbclass |   18 +++++++++++++++---
>   1 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
> index fb70b3e..b935d01 100644
> --- a/meta/classes/useradd.bbclass
> +++ b/meta/classes/useradd.bbclass
> @@ -3,9 +3,16 @@ USERADDPN ?= "${PN}"
>   # base-passwd-cross provides the default passwd and group files in the
>   # target sysroot, and shadow -native and -sysroot provide the utilities
>   # and support files needed to add and modify user and group accounts
> -DEPENDS_append = " base-passwd shadow-native shadow-sysroot"
>   RDEPENDS_${USERADDPN}_append = " base-passwd shadow"
>
> +def useradd_dep_append(d):
> +	deps = ' '
> +	if not bb.data.inherits_class('nativesdk', d):
> +		deps = ' shadow-native shadow-sysroot base-passwd'
> +	return deps
> +
> +DEPENDS_append = "${@useradd_dep_append(d)}"
> +
>   # This preinstall function will be run in two contexts: once for the
>   # native sysroot (as invoked by the useradd_sysroot() wrapper), and
>   # also as the preinst script in the target package.
> @@ -96,8 +103,13 @@ useradd_sysroot_sstate () {
>   	fi
>   }
>
> -do_install[prefuncs] += "useradd_sysroot"
> -SSTATEPOSTINSTFUNCS += "useradd_sysroot_sstate"
> +python () {
> +	if not bb.data.inherits_class('nativesdk', d):
> +		funcs = bb.data.getVarFlag('do_install', 'prefuncs', d) or ""
> +		funcs += 'useradd_sysroot'
> +		bb.data.setVarFlag('do_install', 'prefuncs', funcs, d)
> +		d.setVar('SSTATEPOSTINSTFUNCS', (bb.data.getVar('SSTATEPOSTINSTFUNCS', d, True) or "").join("useradd_sysroot_sstate"))
> +}
>
>   # Recipe parse-time sanity checks
>   def update_useradd_after_parse(d):
Scott Garman - Nov. 7, 2011, 11:47 p.m.
Hi Eric,

Sorry to throw more churn into this, but can I ask you to submit a new 
pull request for this?

In discussions with Richard today, he pointed out a few tricks that 
would improve the patchset:

DEPENDS_append = "${USERADDDEPENDS}"
USERADDDEPENDS = " base-passwd shadow-native shadow-sysroot"
USERADDDEPENDS_virtclass-nativesdk = ""

do_install[prefuncs] += "${SYSROOTFUNC}"
SYSROOTFUNC = "useradd_sysroot"
SYSROOTFUNC_virtclass-nativesdk = ""

I didn't want to take away credit for your patch, so if you'd be willing 
to make these changes and respin your patch set, we'll take that.

The second thing is to avoid merge conflicts, can you rebase you 
patchset on top of this branch:

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=sgarman/useradd-rdepends-final

...and Saul has been warned to apply these patches in the correct order.

Thanks,

Scott

PS - if this is a hassle, just let me know and I'm happy to take care of it.
Eric BENARD - Nov. 8, 2011, 8:45 a.m.
Hi Scott,

Le 08/11/2011 00:47, Scott Garman a écrit :
> Sorry to throw more churn into this, but can I ask you to submit a new pull
> request for this?
>
> In discussions with Richard today, he pointed out a few tricks that would
> improve the patchset:
>
> DEPENDS_append = "${USERADDDEPENDS}"
> USERADDDEPENDS = " base-passwd shadow-native shadow-sysroot"
> USERADDDEPENDS_virtclass-nativesdk = ""
>
> do_install[prefuncs] += "${SYSROOTFUNC}"
> SYSROOTFUNC = "useradd_sysroot"
> SYSROOTFUNC_virtclass-nativesdk = ""
>
that's clean it removes all the python code and ... that works !

> I didn't want to take away credit for your patch, so if you'd be willing to
> make these changes and respin your patch set, we'll take that.
>
well now you have written v2 of the patch so you also get the credits but the 
most important thing beyond the credits is to have this bug fixed ;-)

> The second thing is to avoid merge conflicts, can you rebase you patchset on
> top of this branch:
>
> http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=sgarman/useradd-rdepends-final
>
>
I just applied this patch and resent the 2 others on top of this one.

Thanks,
Eric

Patch

diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index fb70b3e..b935d01 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -3,9 +3,16 @@  USERADDPN ?= "${PN}"
 # base-passwd-cross provides the default passwd and group files in the
 # target sysroot, and shadow -native and -sysroot provide the utilities
 # and support files needed to add and modify user and group accounts
-DEPENDS_append = " base-passwd shadow-native shadow-sysroot"
 RDEPENDS_${USERADDPN}_append = " base-passwd shadow"
 
+def useradd_dep_append(d):
+	deps = ' '
+	if not bb.data.inherits_class('nativesdk', d):
+		deps = ' shadow-native shadow-sysroot base-passwd'
+	return deps
+
+DEPENDS_append = "${@useradd_dep_append(d)}"
+
 # This preinstall function will be run in two contexts: once for the
 # native sysroot (as invoked by the useradd_sysroot() wrapper), and
 # also as the preinst script in the target package.
@@ -96,8 +103,13 @@  useradd_sysroot_sstate () {
 	fi
 }
 
-do_install[prefuncs] += "useradd_sysroot"
-SSTATEPOSTINSTFUNCS += "useradd_sysroot_sstate"
+python () {
+	if not bb.data.inherits_class('nativesdk', d):
+		funcs = bb.data.getVarFlag('do_install', 'prefuncs', d) or ""
+		funcs += 'useradd_sysroot'
+		bb.data.setVarFlag('do_install', 'prefuncs', funcs, d)
+		d.setVar('SSTATEPOSTINSTFUNCS', (bb.data.getVar('SSTATEPOSTINSTFUNCS', d, True) or "").join("useradd_sysroot_sstate"))
+}
 
 # Recipe parse-time sanity checks
 def update_useradd_after_parse(d):