Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] git-r3.eclass: Add checkout dirs as "safe" directories
Date: Sun, 06 Nov 2022 15:52:44
Message-Id: 74edeb903543cfccdd0ae00ceb948dee11d00ede.camel@gentoo.org
In Reply to: Re: [gentoo-dev] [PATCH] git-r3.eclass: Add checkout dirs as "safe" directories by Florian Schmaus
1 On Sun, 2022-11-06 at 16:08 +0100, Florian Schmaus wrote:
2 > On 06.11.22 12:38, Michał Górny wrote:
3 > > On Sun, 2022-11-06 at 12:19 +0100, Florian Schmaus wrote:
4 > > > On 06.11.22 12:03, Michał Górny wrote:
5 > > > > Mark all checkout directories as "safe" to avoid dubious ownership
6 > > > > errors with newer git versions when the checkout directory is accessed
7 > > > > from src_install().
8 > > > >
9 > > > > Bug: https://bugs.gentoo.org/879353
10 > > > > Signed-off-by: Michał Górny <mgorny@g.o>
11 > > > > ---
12 > > > > eclass/git-r3.eclass | 5 +++++
13 > > > > 1 file changed, 5 insertions(+)
14 > > > >
15 > > > > diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
16 > > > > index 59d4f9a0038f..bdb28565e2f9 100644
17 > > > > --- a/eclass/git-r3.eclass
18 > > > > +++ b/eclass/git-r3.eclass
19 > > > > @@ -887,6 +887,11 @@ git-r3_checkout() {
20 > > > > cp "${orig_repo}"/packed-refs "${GIT_DIR}"/packed-refs || die
21 > > > > fi
22 > > > >
23 > > > > + # mark this directory as "safe" so that src_install() can access it
24 > > > > + # https://bugs.gentoo.org/879353
25 > > > > + git config --global --add safe.directory \
26 > > > > + "$(cd "${out_dir}" && echo "${PWD}")" || die
27 > > >
28 > > > I guess there is no way we can avoid the --global and use --local instead?
29 > > >
30 > >
31 > > safe.directory works only in protected scoeps, i.e. system, global and
32 > > command. See git-config(1).
33 > >
34 > > That said, the check wouldn't really make sense if the repository were
35 > > able to declare itself safe.
36 >
37 >
38 > Fair point, and I suspected as much.
39 >
40 > Am I right that this does modify ~portage/.gitconfig (so usually
41 > /var/lib/portage/home/.gitconfig)? If so, I wonder if this could be
42 > avoided, e.g., by setting XDG_CONFIG_HOME to $T/.config. But I guess
43 > that has the potential to break other things. And having some eclass
44 > modifying the home directory of the portage user is not probably
45 > something we could live with. It would just we be nice if the
46 > save.directory setting would be just temporary during the emerge, e.g.,
47 > set somewhere under T.
48 >
49
50 HOME
51 All
52 Ditto
53 The full path to an appropriate temporary directory for use by any
54 programs invoked by the ebuild that may read or modify the home
55 directory. [1]
56
57 [1] https://projects.gentoo.org/pms/8/pms.html#x1-10900011.1
58
59 --
60 Best regards,
61 Michał Górny

Replies