[1/8] systemd: skip chown when building for nativesdk

Message ID 20211117123201.111905-2-luca.boccassi@gmail.com
State New
Headers show
Series systemd: allow building for nativesdk | expand

Commit Message

Luca Boccassi Nov. 17, 2021, 12:31 p.m. UTC
From: Luca Boccassi <luca.boccassi@microsoft.com>

The useradd class is a no-op in the nativesdk case, so chown will fail.
Skip them.

Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
---
 meta/recipes-core/systemd/systemd_249.5.bb | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Peter Kjellerstedt Nov. 17, 2021, 6:14 p.m. UTC | #1
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Luca Bocassi
> Sent: den 17 november 2021 13:32
> To: openembedded-core@lists.openembedded.org
> Cc: paul.eggleton@microsoft.com
> Subject: [OE-core] [PATCH 1/8] systemd: skip chown when building for nativesdk
> 
> From: Luca Boccassi <luca.boccassi@microsoft.com>
> 
> The useradd class is a no-op in the nativesdk case, so chown will fail.
> Skip them.
> 
> Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
> ---
>  meta/recipes-core/systemd/systemd_249.5.bb | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/recipes-core/systemd/systemd_249.5.bb b/meta/recipes-core/systemd/systemd_249.5.bb
> index 8bdc0ca028..2f019a4b1f 100644
> --- a/meta/recipes-core/systemd/systemd_249.5.bb
> +++ b/meta/recipes-core/systemd/systemd_249.5.bb
> @@ -275,7 +275,10 @@ do_install() {
>  		# which is expected to be empty.
>  		rm -rf ${D}${localstatedir}/log
>  	else
> -		chown root:systemd-journal ${D}${localstatedir}/log/journal
> +		# The useradd class is a no-op in the nativesdk case, so chown will fail
> +		if [ "${PN}" != "nativesdk-systemd" ]; then

If you change that if statement here and below to:

		if [ "${PN}" = "${BPN}" ]; then

then it will apply just as well if anyone introduces systemd-native.

> +			chown root:systemd-journal ${D}${localstatedir}/log/journal
> +		fi
> 
>  		# journal-remote creates this at start
>  		rm -rf ${D}${localstatedir}/log/journal/remote
> @@ -319,7 +322,10 @@ do_install() {
>  	if ${@bb.utils.contains('PACKAGECONFIG', 'polkit', 'true', 'false', d)}; then
>  		if [ -d ${D}${datadir}/polkit-1/rules.d ]; then
>  			chmod 700 ${D}${datadir}/polkit-1/rules.d
> -			chown polkitd:root ${D}${datadir}/polkit-1/rules.d
> +			# The useradd class is a no-op in the nativesdk case, so chown will fail
> +			if [ "${PN}" != "nativesdk-systemd" ]; then
> +				chown polkitd:root ${D}${datadir}/polkit-1/rules.d
> +			fi
>  		fi
>  	fi
> 
> --
> 2.30.2

//Peter
Luca Boccassi Nov. 17, 2021, 6:32 p.m. UTC | #2
On Wed, 2021-11-17 at 18:14 +0000, Peter Kjellerstedt wrote:
> > -----Original Message-----
> > From: openembedded-core@lists.openembedded.org
> > <openembedded-core@lists.openembedded.org> On Behalf Of Luca
> > Bocassi
> > Sent: den 17 november 2021 13:32
> > To: openembedded-core@lists.openembedded.org
> > Cc: paul.eggleton@microsoft.com
> > Subject: [OE-core] [PATCH 1/8] systemd: skip chown when building
> > for nativesdk
> > 
> > From: Luca Boccassi <luca.boccassi@microsoft.com>
> > 
> > The useradd class is a no-op in the nativesdk case, so chown will
> > fail.
> > Skip them.
> > 
> > Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
> > ---
> >  meta/recipes-core/systemd/systemd_249.5.bb | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/meta/recipes-core/systemd/systemd_249.5.bb
> > b/meta/recipes-core/systemd/systemd_249.5.bb
> > index 8bdc0ca028..2f019a4b1f 100644
> > --- a/meta/recipes-core/systemd/systemd_249.5.bb
> > +++ b/meta/recipes-core/systemd/systemd_249.5.bb
> > @@ -275,7 +275,10 @@ do_install() {
> >  		# which is expected to be empty.
> >  		rm -rf ${D}${localstatedir}/log
> >  	else
> > -		chown root:systemd-journal
> > ${D}${localstatedir}/log/journal
> > +		# The useradd class is a no-op in the nativesdk
> > case, so chown will fail
> > +		if [ "${PN}" != "nativesdk-systemd" ]; then
> 
> If you change that if statement here and below to:
> 
> 		if [ "${PN}" = "${BPN}" ]; then
> 
> then it will apply just as well if anyone introduces systemd-native.

Thanks, will test that and send a v2 tomorrow if it is all green.
Luca Boccassi Nov. 19, 2021, 11:35 a.m. UTC | #3
On Wed, 2021-11-17 at 18:32 +0000, Luca Boccassi wrote:
> On Wed, 2021-11-17 at 18:14 +0000, Peter Kjellerstedt wrote:
> > > -----Original Message-----
> > > From: openembedded-core@lists.openembedded.org
> > > <openembedded-core@lists.openembedded.org> On Behalf Of Luca
> > > Bocassi
> > > Sent: den 17 november 2021 13:32
> > > To: openembedded-core@lists.openembedded.org
> > > Cc: paul.eggleton@microsoft.com
> > > Subject: [OE-core] [PATCH 1/8] systemd: skip chown when building
> > > for nativesdk
> > > 
> > > From: Luca Boccassi <luca.boccassi@microsoft.com>
> > > 
> > > The useradd class is a no-op in the nativesdk case, so chown will
> > > fail.
> > > Skip them.
> > > 
> > > Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
> > > ---
> > >  meta/recipes-core/systemd/systemd_249.5.bb | 10 ++++++++--
> > >  1 file changed, 8 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/meta/recipes-core/systemd/systemd_249.5.bb
> > > b/meta/recipes-core/systemd/systemd_249.5.bb
> > > index 8bdc0ca028..2f019a4b1f 100644
> > > --- a/meta/recipes-core/systemd/systemd_249.5.bb
> > > +++ b/meta/recipes-core/systemd/systemd_249.5.bb
> > > @@ -275,7 +275,10 @@ do_install() {
> > >  		# which is expected to be empty.
> > >  		rm -rf ${D}${localstatedir}/log
> > >  	else
> > > -		chown root:systemd-journal
> > > ${D}${localstatedir}/log/journal
> > > +		# The useradd class is a no-op in the nativesdk
> > > case, so chown will fail
> > > +		if [ "${PN}" != "nativesdk-systemd" ]; then
> > 
> > If you change that if statement here and below to:
> > 
> > 		if [ "${PN}" = "${BPN}" ]; then
> > 
> > then it will apply just as well if anyone introduces systemd-native.
> 
> Thanks, will test that and send a v2 tomorrow if it is all green.

This works, thanks, applied in v2.

Patch

diff --git a/meta/recipes-core/systemd/systemd_249.5.bb b/meta/recipes-core/systemd/systemd_249.5.bb
index 8bdc0ca028..2f019a4b1f 100644
--- a/meta/recipes-core/systemd/systemd_249.5.bb
+++ b/meta/recipes-core/systemd/systemd_249.5.bb
@@ -275,7 +275,10 @@  do_install() {
 		# which is expected to be empty.
 		rm -rf ${D}${localstatedir}/log
 	else
-		chown root:systemd-journal ${D}${localstatedir}/log/journal
+		# The useradd class is a no-op in the nativesdk case, so chown will fail
+		if [ "${PN}" != "nativesdk-systemd" ]; then
+			chown root:systemd-journal ${D}${localstatedir}/log/journal
+		fi
 
 		# journal-remote creates this at start
 		rm -rf ${D}${localstatedir}/log/journal/remote
@@ -319,7 +322,10 @@  do_install() {
 	if ${@bb.utils.contains('PACKAGECONFIG', 'polkit', 'true', 'false', d)}; then
 		if [ -d ${D}${datadir}/polkit-1/rules.d ]; then
 			chmod 700 ${D}${datadir}/polkit-1/rules.d
-			chown polkitd:root ${D}${datadir}/polkit-1/rules.d
+			# The useradd class is a no-op in the nativesdk case, so chown will fail
+			if [ "${PN}" != "nativesdk-systemd" ]; then
+				chown polkitd:root ${D}${datadir}/polkit-1/rules.d
+			fi
 		fi
 	fi