All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
To: Andre McCurdy <armccurdy@gmail.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: OE Core mailing list <openembedded-core@lists.openembedded.org>,
	"Richard Purdie" <richard.purdie@linuxfoundation.org>
Subject: RE: [OE-core] [PATCH] devshell: introduce intercepts as per native / nativesdk
Date: Thu, 21 Apr 2022 10:10:54 +0000	[thread overview]
Message-ID: <5646a875c3e54ad7a4b0c92f64ec45f9@axis.com> (raw)
In-Reply-To: <CAJ86T=VPsbzm3uUDupi9EchuVJPfywLONj+AvWk+eK-tB2Xaaw@mail.gmail.com>

> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-
> core@lists.openembedded.org> On Behalf Of Andre McCurdy
> Sent: den 21 april 2022 01:25
> To: Paul Gortmaker <paul.gortmaker@windriver.com>
> Cc: OE Core mailing list <openembedded-core@lists.openembedded.org>;
> Richard Purdie <richard.purdie@linuxfoundation.org>
> Subject: Re: [OE-core] [PATCH] devshell: introduce intercepts as per
> native / nativesdk
> 
> On Wed, Apr 20, 2022 at 8:12 AM Paul Gortmaker
> <paul.gortmaker@windriver.com> wrote:
> >
> > In a devshell, recent versions of git will complain if the repo is owned
> > by someone other than the current UID - consider this example:
> >
> >  ------
> >   bitbake -c devshell linux-yocto
> >
> >   [...]
> >
> >   kernel-source#git branch
> >   fatal: unsafe repository ('/home/paul/poky/build-qemuarm64/tmp/work-
> shared/qemuarm64/kernel-source' is owned by someone else)
> >   To add an exception for this directory, call:
> >
> >         git config --global --add safe.directory /home/paul/poky/build-
> qemuarm64/tmp/work-shared/qemuarm64/kernel-source
> >   kernel-source#
> >  ------
> >
> > Of course the devshell has UID zero and the "real" UID is for "paul" in
> > this case.  And so recent git versions complain.
> >
> > As the whole purpose of the devshell is to invoke a shell where
> development
> > can take place, having a non-functional git is clearly unacceptable.
> >
> > Richard suggested we could use PSEUDO_UNLOAD=1 to evade this issue, and
> I
> > suggested we probably will see other similar instances like this and
> should
> > make use of PATH to intercept via devshell wrappers - conveniently we
> already
> > have examples of this.
> >
> > Here, we copy the existing "ar" example and tune it to the needs of git
> to
> > combine Richard's suggestion and mine.
> >
> > As such we now also can store commit logs and use send-email with our
> user
> > specific settings, instead of "root", so in additon to fixing basic
> > commands like "git branch" it should also increase general usefulness.
> 
> It looks like this will address the performance issues of using git
> from a devshell too. Trying to run git log, git blame, etc for
> largeish repos in a devshell is annoyingly slow due to the overhead of
> pseudo.
> 
> I always wondered what people do in a devshell which actually _does_
> need to run under pseudo...

To look at the output from, e.g., do_install to see it the way bitbakes 
sees it when it comes to users/groups of the files.

//Peter

> 
> > Cc: Richard Purdie <richard.purdie@linuxfoundation.org>
> > Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> >
> > diff --git a/meta/classes/devshell.bbclass
> b/meta/classes/devshell.bbclass
> > index 62dc958d9a4a..7ac134e0950f 100644
> > --- a/meta/classes/devshell.bbclass
> > +++ b/meta/classes/devshell.bbclass
> > @@ -2,6 +2,8 @@ inherit terminal
> >
> >  DEVSHELL = "${SHELL}"
> >
> > +PATH:prepend = "${COREBASE}/scripts/devshell-intercept:"
> > +
> >  python do_devshell () {
> >      if d.getVarFlag("do_devshell", "manualfakeroot"):
> >         d.prependVar("DEVSHELL", "pseudo ")
> > diff --git a/scripts/devshell-intercept/git b/scripts/devshell-
> intercept/git
> > new file mode 100755
> > index 000000000000..8adf5c9ecb71
> > --- /dev/null
> > +++ b/scripts/devshell-intercept/git
> > @@ -0,0 +1,19 @@
> > +#!/usr/bin/env python3
> > +#
> > +# Wrapper around 'git' that doesn't think we are root
> > +
> > +import os
> > +import shutil
> > +import sys
> > +
> > +os.environ['PSEUDO_UNLOAD'] = '1'
> > +
> > +# calculate path to the real 'git'
> > +path = os.environ['PATH']
> > +path = path.replace(os.path.dirname(sys.argv[0]), '')
> > +real_git = shutil.which('git', path=path)
> > +
> > +if len(sys.argv) == 1:
> > +    os.execl(real_git, 'git')
> > +
> > +os.execv(real_git, sys.argv)
> > --
> > 2.17.1
> >
> >
> >
> >

  reply	other threads:[~2022-04-21 16:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 15:11 [PATCH] devshell: introduce intercepts as per native / nativesdk Paul Gortmaker
2022-04-20 23:24 ` [OE-core] " Andre McCurdy
2022-04-21 10:10   ` Peter Kjellerstedt [this message]
2022-04-21  9:53 ` Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5646a875c3e54ad7a4b0c92f64ec45f9@axis.com \
    --to=peter.kjellerstedt@axis.com \
    --cc=armccurdy@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=richard.purdie@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.