override HOME to isolate sbuild configuration

Message ID 20220920092654.1314022-1-felix.moessbauer@siemens.com
State Under Review
Headers show
Series override HOME to isolate sbuild configuration | expand

Commit Message

MOESSBAUER, Felix Sept. 20, 2022, 9:26 a.m. UTC
This patch sets the HOME env var to the package build path
to avoid conflicts with an existing .sbuildrc configuration
in the users homedir.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes/dpkg.bbclass | 2 ++
 1 file changed, 2 insertions(+)

Comments

Henning Schild Sept. 20, 2022, 10:58 a.m. UTC | #1
Am Tue, 20 Sep 2022 11:26:54 +0200
schrieb Felix Moessbauer <felix.moessbauer@siemens.com>:

> This patch sets the HOME env var to the package build path
> to avoid conflicts with an existing .sbuildrc configuration
> in the users homedir.
> 
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
>  meta/classes/dpkg.bbclass | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
> index c92ea7db..70f8e772 100644
> --- a/meta/classes/dpkg.bbclass
> +++ b/meta/classes/dpkg.bbclass
> @@ -17,6 +17,8 @@ dpkg_runbuild() {
>      E="${@ isar_export_ccache(d)}"
>      export DEB_BUILD_OPTIONS="${@ isar_deb_build_options(d)}"
>      export PARALLEL_MAKE="${PARALLEL_MAKE}"
> +    # override HOME to not interfer with users .sbuildrc
> +    export HOME="${PP}"

This is not kas, maybe people want that from isar. And if they do not
want it they can use kas.

I would bbwarn on -f ~/.sbuildrc, setting HOME to something else is
pretty heavy and can have all sorts of fun side-effects.

Henning
 
>      rm -f ${SBUILD_CONFIG}
>
MOESSBAUER, Felix Sept. 20, 2022, 11:22 a.m. UTC | #2
> -----Original Message-----
> From: Schild, Henning (T CED SES-DE) <henning.schild@siemens.com>
> Sent: Tuesday, September 20, 2022 12:59 PM
> To: Moessbauer, Felix (T CED SES-DE) <felix.moessbauer@siemens.com>
> Cc: isar-users@googlegroups.com; Bezdeka, Florian (T CED SES-DE)
> <florian.bezdeka@siemens.com>
> Subject: Re: [PATCH] override HOME to isolate sbuild configuration
> 
> Am Tue, 20 Sep 2022 11:26:54 +0200
> schrieb Felix Moessbauer <felix.moessbauer@siemens.com>:
> 
> > This patch sets the HOME env var to the package build path to avoid
> > conflicts with an existing .sbuildrc configuration in the users
> > homedir.
> >
> > Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> > ---
> >  meta/classes/dpkg.bbclass | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
> > index c92ea7db..70f8e772 100644
> > --- a/meta/classes/dpkg.bbclass
> > +++ b/meta/classes/dpkg.bbclass
> > @@ -17,6 +17,8 @@ dpkg_runbuild() {
> >      E="${@ isar_export_ccache(d)}"
> >      export DEB_BUILD_OPTIONS="${@ isar_deb_build_options(d)}"
> >      export PARALLEL_MAKE="${PARALLEL_MAKE}"
> > +    # override HOME to not interfer with users .sbuildrc
> > +    export HOME="${PP}"
> 
> This is not kas, maybe people want that from isar. And if they do not want it they
> can use kas.
> 
> I would bbwarn on -f ~/.sbuildrc, setting HOME to something else is pretty heavy
> and can have all sorts of fun side-effects.

I had the funny side effect that I could not build with ISAR on my sbuild + unshare enabled host.
Had a hard time to figure out why this did not work, especially as the sbuild man page is not very precise on the effect of the SBUILD_CONFIG env var.

Setting HOME there is only relevant for the sbuild invocation and also there, the HOME variable is set but quite pointless as everything happens inside the schroot.
AFAIK there is no statement in the user_manual.md regarding the configuration of host tools.

Let's put Anton in CC to get a statement from an maintainer of ISAR.

Felix

> 
> Henning
> 
> >      rm -f ${SBUILD_CONFIG}
> >
Anton Mikanovich Sept. 23, 2022, 9:17 a.m. UTC | #3
20.09.2022 14:22, Moessbauer, Felix wrote:
> I had the funny side effect that I could not build with ISAR on my sbuild + unshare enabled host.
> Had a hard time to figure out why this did not work, especially as the sbuild man page is not very precise on the effect of the SBUILD_CONFIG env var.
>
> Setting HOME there is only relevant for the sbuild invocation and also there, the HOME variable is set but quite pointless as everything happens inside the schroot.
> AFAIK there is no statement in the user_manual.md regarding the configuration of host tools.
>
> Let's put Anton in CC to get a statement from an maintainer of ISAR.
>
> Felix

Hello, Felix.

Thanks for pinging, I was sick a little bit this week, so unable to 
answer fast.

I think we can try to enable HOME override in the way like:

ISAR_BUILD_HOME ?= "${HOME}"
...
export HOME="${ISAR_BUILD_HOME}"

This will allow user to override the value if needed, but still use the 
old one by default.
And this should be also documented.
MOESSBAUER, Felix Sept. 25, 2022, 8:13 a.m. UTC | #4
> -----Original Message-----
> From: Anton Mikanovich <amikan@ilbers.de>
> Sent: Friday, September 23, 2022 5:18 PM
> To: Moessbauer, Felix (T CED SES-DE) <felix.moessbauer@siemens.com>; Schild,
> Henning (T CED SES-DE) <henning.schild@siemens.com>
> Cc: isar-users@googlegroups.com; Bezdeka, Florian (T CED SES-DE)
> <florian.bezdeka@siemens.com>; ubely@ilbers.de
> Subject: Re: [PATCH] override HOME to isolate sbuild configuration
> 
> 20.09.2022 14:22, Moessbauer, Felix wrote:
> > I had the funny side effect that I could not build with ISAR on my sbuild +
> unshare enabled host.
> > Had a hard time to figure out why this did not work, especially as the sbuild
> man page is not very precise on the effect of the SBUILD_CONFIG env var.
> >
> > Setting HOME there is only relevant for the sbuild invocation and also there,
> the HOME variable is set but quite pointless as everything happens inside the
> schroot.
> > AFAIK there is no statement in the user_manual.md regarding the
> configuration of host tools.
> >
> > Let's put Anton in CC to get a statement from an maintainer of ISAR.
> >
> > Felix
> 
> Hello, Felix.
> 
> Thanks for pinging, I was sick a little bit this week, so unable to answer fast.
> 
> I think we can try to enable HOME override in the way like:
> 
> ISAR_BUILD_HOME ?= "${HOME}"
> ...
> export HOME="${ISAR_BUILD_HOME}"
> 
> This will allow user to override the value if needed, but still use the old one by
> default.

Hi Anton,

We could do it this way, but then the ISAR_BUILD_HOME would have to be injected from the users environment.
This would require an additional variable to be passed through various layers of shell-scripts and bitbake (and excluded from caching, etc...).
I already see people checking in the "ISAR_BUILD_HOME" variable in downstream layers' VCS.

Apart from that, I discovered that setting HOME itself is not sufficient to isolate the sbuildrc:
Still, /etc/sbuild/sbuild.conf is considered (but there are usually no breaking changes in it).

I personally use KAS anyways, there we don't have this issue.
But esp. Debian people who regularly use sbuild and want to try out ISAR will likely run into it.

Don't know how to proceed.
If nobody is interested in fixing this inconvenience, then let's keep it as it is.

Felix

> And this should be also documented.

Patch

diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
index c92ea7db..70f8e772 100644
--- a/meta/classes/dpkg.bbclass
+++ b/meta/classes/dpkg.bbclass
@@ -17,6 +17,8 @@  dpkg_runbuild() {
     E="${@ isar_export_ccache(d)}"
     export DEB_BUILD_OPTIONS="${@ isar_deb_build_options(d)}"
     export PARALLEL_MAKE="${PARALLEL_MAKE}"
+    # override HOME to not interfer with users .sbuildrc
+    export HOME="${PP}"
 
     rm -f ${SBUILD_CONFIG}