Patchwork useradd changes to dbus, base-passwd

login
register
mail settings
Submitter Eric BENARD
Date Nov. 6, 2011, 8:31 p.m.
Message ID <4EB6EE8E.4000401@eukrea.com>
Download mbox | patch
Permalink /patch/14385/
State New
Headers show

Comments

Eric BENARD - Nov. 6, 2011, 8:31 p.m.
Hi Scott,

Le 26/10/2011 18:52, Scott Garman a écrit :
> Grepping through our classes, it looks like I can detect the nativesdk within
> useradd.bbclass by checking for bb.data.inherits_class('nativesdk', d).
>
> I've filed a bug for this and will develop a patch to ensure useradd is
> becomes a no-op for nativesdk builds:
>
> http://bugzilla.pokylinux.org/show_bug.cgi?id=1702
>
here is a patch tentative which allowed me to compile meta-toolchain-qte.
Is that the right way to solve the problem (in which case I'll submit the 
patch with comment & sob)?

Thanks
Eric
Eric BENARD - Nov. 7, 2011, 8:36 a.m.
Hi Scott,

Le 07/11/2011 00:16, Scott Garman a écrit :
> This looks good, thank you! Two questions though:
>
> When I was testing my own variation of this fix out, I found that testing
> bb.data.inherits_class('nativesdk', d) did not work as I expected. It returned
> false for a recipe I was testing with that used BBCLASSEXTEND = "native
> nativesdk". So instead I was checking if PN ended with -nativesdk. Are you
> certain the inherits_class test works?
>
this seems to work as expected in the present case :

$ grep BBCLASSEXTEND sources/openembedded-core/meta/recipes-core/dbus/dbus.inc
BBCLASSEXTEND = "native nativesdk"

$ bitbake dbus -e |grep ^DEPENDS=
DEPENDS="pkgconfig-native autoconf-native automake-native libtool-native 
libtool-cross gnu-config-native virtual/gettext gettext-native 
virtual/arm-angstrom-linux-gnueabi-gcc 
virtual/arm-angstrom-linux-gnueabi-compilerlibs virtual/libc  expat 
virtual/libintl virtual/libx11 libsm shadow-native shadow-sysroot base-passwd 
update-rc.d-native"

$ bitbake dbus-native -e |grep ^DEPENDS=
DEPENDS="pkgconfig-native autoconf-native automake-native libtool-native 
gnu-config-native gettext-minimal-native  expat-native virtual/libintl-native 
shadow-native shadow-sysroot base-passwd update-rc.d-native"

$ bitbake dbus-nativesdk -e |grep ^DEPENDS=
DEPENDS="pkgconfig-native autoconf-native automake-native libtool-native 
libtool-cross gnu-config-native virtual/gettext-nativesdk gettext-native 
virtual/i686-angstromsdk-linux-gcc-crosssdk 
virtual/i686-angstromsdk-linux-compilerlibs-nativesdk virtual/libc-nativesdk 
expat-nativesdk virtual/libintl-nativesdk virtual/libx11-nativesdk 
update-rc.d-native"

$ bitbake dbus-nativesdk -e |grep ^SSTATEPOSTIN
$ bitbake dbus-native -e |grep ^SSTATEPOSTIN
SSTATEPOSTINSTFUNCS="useradd_sysroot_sstate"
$ bitbake dbus -e |grep ^SSTATEPOSTIN
SSTATEPOSTINSTFUNCS="useradd_sysroot_sstate"


> My second question is why the autotools_do_install is needed for the nativesdk
> case?
>
because without the do_install_virtclass-nativesdk() , that's the standard 
do_install which is used which tries to setup some rigths using chown on the 
files and that fails (and is not very useful for a nativesdk).
Maybe we could use a similar do_install as the one used for native.

Eric
Scott Garman - Nov. 7, 2011, 6:24 p.m.
On 11/07/2011 12:36 AM, Eric Bénard wrote:
> Hi Scott,
>
> Le 07/11/2011 00:16, Scott Garman a écrit :
>> This looks good, thank you! Two questions though:
>>
>> When I was testing my own variation of this fix out, I found that testing
>> bb.data.inherits_class('nativesdk', d) did not work as I expected. It
>> returned
>> false for a recipe I was testing with that used BBCLASSEXTEND = "native
>> nativesdk". So instead I was checking if PN ended with -nativesdk. Are
>> you
>> certain the inherits_class test works?
>>
> this seems to work as expected in the present case :
>
> $ grep BBCLASSEXTEND
> sources/openembedded-core/meta/recipes-core/dbus/dbus.inc
> BBCLASSEXTEND = "native nativesdk"
>
> $ bitbake dbus -e |grep ^DEPENDS=
> DEPENDS="pkgconfig-native autoconf-native automake-native libtool-native
> libtool-cross gnu-config-native virtual/gettext gettext-native
> virtual/arm-angstrom-linux-gnueabi-gcc
> virtual/arm-angstrom-linux-gnueabi-compilerlibs virtual/libc expat
> virtual/libintl virtual/libx11 libsm shadow-native shadow-sysroot
> base-passwd update-rc.d-native"
>
> $ bitbake dbus-native -e |grep ^DEPENDS=
> DEPENDS="pkgconfig-native autoconf-native automake-native libtool-native
> gnu-config-native gettext-minimal-native expat-native
> virtual/libintl-native shadow-native shadow-sysroot base-passwd
> update-rc.d-native"
>
> $ bitbake dbus-nativesdk -e |grep ^DEPENDS=
> DEPENDS="pkgconfig-native autoconf-native automake-native libtool-native
> libtool-cross gnu-config-native virtual/gettext-nativesdk gettext-native
> virtual/i686-angstromsdk-linux-gcc-crosssdk
> virtual/i686-angstromsdk-linux-compilerlibs-nativesdk
> virtual/libc-nativesdk expat-nativesdk virtual/libintl-nativesdk
> virtual/libx11-nativesdk update-rc.d-native"
>
> $ bitbake dbus-nativesdk -e |grep ^SSTATEPOSTIN
> $ bitbake dbus-native -e |grep ^SSTATEPOSTIN
> SSTATEPOSTINSTFUNCS="useradd_sysroot_sstate"
> $ bitbake dbus -e |grep ^SSTATEPOSTIN
> SSTATEPOSTINSTFUNCS="useradd_sysroot_sstate"
>
>
>> My second question is why the autotools_do_install is needed for the
>> nativesdk
>> case?
>>
> because without the do_install_virtclass-nativesdk() , that's the
> standard do_install which is used which tries to setup some rigths using
> chown on the files and that fails (and is not very useful for a nativesdk).
> Maybe we could use a similar do_install as the one used for native.

Thanks for the explanation and verifying the inherit_class call.

I'm happy to ack a patch for this, please submit it.

Thanks!

Scott

Patch

diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index fb70b3e..cbcc9e9 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,17 @@  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):
diff --git a/meta/recipes-core/dbus/dbus.inc b/meta/recipes-core/dbus/dbus.inc
index caa781c..99b2fc7 100644
--- a/meta/recipes-core/dbus/dbus.inc
+++ b/meta/recipes-core/dbus/dbus.inc
@@ -105,4 +105,8 @@  do_install_virtclass-native() {
 	# dbus-glib-native and dbus-glib need this xml file
 	./bus/dbus-daemon --introspect > ${STAGING_DATADIR_NATIVE}/dbus/dbus-bus-introspect.xml
 }
+
+do_install_virtclass-nativesdk() {
+	autotools_do_install
+}
 BBCLASSEXTEND = "native nativesdk"