[bitbake-devel] Add a variable to pass flags to fakeroot (pseudo)

Submitted by Joshua Watt on Dec. 6, 2018, 6:55 p.m. | Patch ID: 156959

Details

Message ID 20181206185535.12523-1-JPEWhacker@gmail.com
State New
Headers show

Commit Message

Joshua Watt Dec. 6, 2018, 6:55 p.m.
It is occasionally useful to pass additional flags to fakeroot (pseudo)
either for debugging or for behavioral system changes. Add a variable
called "FAKEROOTARGS" that can be used for this purpose.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 bitbake/lib/bb/build.py    | 2 +-
 bitbake/lib/bb/runqueue.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 4631abdde57..20350319bf0 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -371,7 +371,7 @@  exit $ret
     if d.getVarFlag(func, 'fakeroot', False):
         fakerootcmd = d.getVar('FAKEROOT')
         if fakerootcmd:
-            cmd = [fakerootcmd, runfile]
+            cmd = [fakerootcmd] + (d.getVar('FAKEROOTARGS') or '').split() + ['--', runfile]
 
     if bb.msg.loggerDefaultVerbose:
         logfile = LogTee(logger, sys.stdout)
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index f2e52cf758c..de04ccfcb91 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -1175,12 +1175,12 @@  class RunQueue:
         if fakeroot:
             magic = magic + "beef"
             mcdata = self.cooker.databuilder.mcdata[mc]
-            fakerootcmd = mcdata.getVar("FAKEROOTCMD")
+            fakerootcmd = [mcdata.getVar("FAKEROOTCMD")] + (mcdata.getVar("FAKEROOTARGS") or '').split() + ['--']
             fakerootenv = (mcdata.getVar("FAKEROOTBASEENV") or "").split()
             env = os.environ.copy()
             for key, value in (var.split('=') for var in fakerootenv):
                 env[key] = value
-            worker = subprocess.Popen([fakerootcmd, "bitbake-worker", magic], stdout=subprocess.PIPE, stdin=subprocess.PIPE, env=env)
+            worker = subprocess.Popen(fakerootcmd + ["bitbake-worker", magic], stdout=subprocess.PIPE, stdin=subprocess.PIPE, env=env)
         else:
             worker = subprocess.Popen(["bitbake-worker", magic], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
         bb.utils.nonblockingfd(worker.stdout)

Comments

Mark Hatle Dec. 6, 2018, 7:08 p.m.
(No objection to this patch......)

Would anyone be interested in a comment that changes aware from 'fakeroot' and
to 'pseudo'?

Just curious, as I don't actually think 'fakeroot' would work anymore.  (Ya, I
know there would be compatibility issues, but those could likely be addressed by
variables and/or 'or' statements.)

Just wondering if that kind of a change/cleanup makes sense or not just thinking
of bitbake.

--Mark

On 12/6/18 12:55 PM, Joshua Watt wrote:
> It is occasionally useful to pass additional flags to fakeroot (pseudo)
> either for debugging or for behavioral system changes. Add a variable
> called "FAKEROOTARGS" that can be used for this purpose.
> 
> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
> ---
>  bitbake/lib/bb/build.py    | 2 +-
>  bitbake/lib/bb/runqueue.py | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
> index 4631abdde57..20350319bf0 100644
> --- a/bitbake/lib/bb/build.py
> +++ b/bitbake/lib/bb/build.py
> @@ -371,7 +371,7 @@ exit $ret
>      if d.getVarFlag(func, 'fakeroot', False):
>          fakerootcmd = d.getVar('FAKEROOT')
>          if fakerootcmd:
> -            cmd = [fakerootcmd, runfile]
> +            cmd = [fakerootcmd] + (d.getVar('FAKEROOTARGS') or '').split() + ['--', runfile]
>  
>      if bb.msg.loggerDefaultVerbose:
>          logfile = LogTee(logger, sys.stdout)
> diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
> index f2e52cf758c..de04ccfcb91 100644
> --- a/bitbake/lib/bb/runqueue.py
> +++ b/bitbake/lib/bb/runqueue.py
> @@ -1175,12 +1175,12 @@ class RunQueue:
>          if fakeroot:
>              magic = magic + "beef"
>              mcdata = self.cooker.databuilder.mcdata[mc]
> -            fakerootcmd = mcdata.getVar("FAKEROOTCMD")
> +            fakerootcmd = [mcdata.getVar("FAKEROOTCMD")] + (mcdata.getVar("FAKEROOTARGS") or '').split() + ['--']
>              fakerootenv = (mcdata.getVar("FAKEROOTBASEENV") or "").split()
>              env = os.environ.copy()
>              for key, value in (var.split('=') for var in fakerootenv):
>                  env[key] = value
> -            worker = subprocess.Popen([fakerootcmd, "bitbake-worker", magic], stdout=subprocess.PIPE, stdin=subprocess.PIPE, env=env)
> +            worker = subprocess.Popen(fakerootcmd + ["bitbake-worker", magic], stdout=subprocess.PIPE, stdin=subprocess.PIPE, env=env)
>          else:
>              worker = subprocess.Popen(["bitbake-worker", magic], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
>          bb.utils.nonblockingfd(worker.stdout)
>
Richard Purdie Dec. 6, 2018, 10:05 p.m.
On Thu, 2018-12-06 at 12:55 -0600, Joshua Watt wrote:
> It is occasionally useful to pass additional flags to fakeroot
> (pseudo)
> either for debugging or for behavioral system changes. Add a variable
> called "FAKEROOTARGS" that can be used for this purpose.

Why wouldn't you just append to FAKEROOT/FAKEROOTCMD ?

Cheers,

Richard
Richard Purdie Dec. 6, 2018, 10:05 p.m.
On Thu, 2018-12-06 at 13:08 -0600, Mark Hatle wrote:
> (No objection to this patch......)
> 
> Would anyone be interested in a comment that changes aware from
> 'fakeroot' and
> to 'pseudo'?
> 
> Just curious, as I don't actually think 'fakeroot' would work
> anymore.  (Ya, I
> know there would be compatibility issues, but those could likely be
> addressed by
> variables and/or 'or' statements.)
> 
> Just wondering if that kind of a change/cleanup makes sense or not
> just thinking of bitbake.

I've wondered but I think it would cause churn for little gain...

Cheers,

Richard
Joshua Watt Dec. 7, 2018, 3:27 a.m.
On Thu, Dec 6, 2018 at 4:05 PM Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> On Thu, 2018-12-06 at 12:55 -0600, Joshua Watt wrote:
> > It is occasionally useful to pass additional flags to fakeroot
> > (pseudo)
> > either for debugging or for behavioral system changes. Add a variable
> > called "FAKEROOTARGS" that can be used for this purpose.
>
> Why wouldn't you just append to FAKEROOT/FAKEROOTCMD ?

You can't currently add arguments to FAKEROOTCMD because it is passed
as an array member to subprocess.Popen sort of like:

 subprocess.Popen([d.getVar('FAKEROOTCMD'), 'blah', 'blah', ...

In order to pass arguments, it would probably have to have split into
an array i.e. :

 subprocess.Popen(d.getVar('FAKEROOTCMD').split() + ['blah', 'blah', ...

I wasn't sure if that was desirable or if it would break anything, so
I went with the lower risk approach of adding a new variables. I can
certainly make a change to modify the usage of FAKEROOTCMD as
described above and simply append the flags to it if that is
preferred.

>
> Cheers,
>
> Richard
>
Richard Purdie Dec. 7, 2018, 1:04 p.m.
On Thu, 2018-12-06 at 21:27 -0600, Joshua Watt wrote:
> On Thu, Dec 6, 2018 at 4:05 PM Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> > On Thu, 2018-12-06 at 12:55 -0600, Joshua Watt wrote:
> > > It is occasionally useful to pass additional flags to fakeroot
> > > (pseudo)
> > > either for debugging or for behavioral system changes. Add a
> > > variable
> > > called "FAKEROOTARGS" that can be used for this purpose.
> > 
> > Why wouldn't you just append to FAKEROOT/FAKEROOTCMD ?
> 
> You can't currently add arguments to FAKEROOTCMD because it is passed
> as an array member to subprocess.Popen sort of like:
> 
>  subprocess.Popen([d.getVar('FAKEROOTCMD'), 'blah', 'blah', ...
> 
> In order to pass arguments, it would probably have to have split into
> an array i.e. :
> 
>  subprocess.Popen(d.getVar('FAKEROOTCMD').split() + ['blah', 'blah',
> ...
> 
> I wasn't sure if that was desirable or if it would break anything, so
> I went with the lower risk approach of adding a new variables. I can
> certainly make a change to modify the usage of FAKEROOTCMD as
> described above and simply append the flags to it if that is
> preferred.

I'd prefer to fix this to work than add more variables...

Cheers,

Richard
Aaron Cohen Dec. 7, 2018, 2:02 p.m.
Using split() will break if the path contains a space if that is a concern.

On Fri, Dec 7, 2018 at 8:04 AM <richard.purdie@linuxfoundation.org> wrote:

> On Thu, 2018-12-06 at 21:27 -0600, Joshua Watt wrote:
> > On Thu, Dec 6, 2018 at 4:05 PM Richard Purdie
> > <richard.purdie@linuxfoundation.org> wrote:
> > > On Thu, 2018-12-06 at 12:55 -0600, Joshua Watt wrote:
> > > > It is occasionally useful to pass additional flags to fakeroot
> > > > (pseudo)
> > > > either for debugging or for behavioral system changes. Add a
> > > > variable
> > > > called "FAKEROOTARGS" that can be used for this purpose.
> > >
> > > Why wouldn't you just append to FAKEROOT/FAKEROOTCMD ?
> >
> > You can't currently add arguments to FAKEROOTCMD because it is passed
> > as an array member to subprocess.Popen sort of like:
> >
> >  subprocess.Popen([d.getVar('FAKEROOTCMD'), 'blah', 'blah', ...
> >
> > In order to pass arguments, it would probably have to have split into
> > an array i.e. :
> >
> >  subprocess.Popen(d.getVar('FAKEROOTCMD').split() + ['blah', 'blah',
> > ...
> >
> > I wasn't sure if that was desirable or if it would break anything, so
> > I went with the lower risk approach of adding a new variables. I can
> > certainly make a change to modify the usage of FAKEROOTCMD as
> > described above and simply append the flags to it if that is
> > preferred.
>
> I'd prefer to fix this to work than add more variables...
>
> Cheers,
>
> Richard
>
> --
> _______________________________________________
> bitbake-devel mailing list
> bitbake-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/bitbake-devel
>