1 |
On Sun, Jan 3, 2021 at 7:52 AM James Le Cuirot <chewi@g.o> wrote: |
2 |
> |
3 |
> On Sat, 2 Jan 2021 20:09:04 -0500 |
4 |
> Mike Gilbert <floppym@g.o> wrote: |
5 |
> |
6 |
> > When cross-compiling, users will typically have |
7 |
> > PKG_CONFIG_SYSROOT=${SYSROOT} defined via pkg-config wrapper. |
8 |
> > |
9 |
> > When PKG_CONFIG_SYSROOT is set, all paths included in pkg-config |
10 |
> > output get prefixed with this value. |
11 |
> > |
12 |
> > Signed-off-by: Mike Gilbert <floppym@g.o> |
13 |
> > --- |
14 |
> > |
15 |
> > This patch has already been pushed, but I figured I would send it for |
16 |
> > review in case someone else can think of a failure case, or has a better |
17 |
> > solution. |
18 |
> > |
19 |
> > eclass/systemd.eclass | 1 + |
20 |
> > 1 file changed, 1 insertion(+) |
21 |
> > |
22 |
> > diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass |
23 |
> > index 81065a0af79a..f6d1fa2d92d6 100644 |
24 |
> > --- a/eclass/systemd.eclass |
25 |
> > +++ b/eclass/systemd.eclass |
26 |
> > @@ -50,6 +50,7 @@ _systemd_get_dir() { |
27 |
> > |
28 |
> > if $(tc-getPKG_CONFIG) --exists systemd; then |
29 |
> > d=$($(tc-getPKG_CONFIG) --variable="${variable}" systemd) || die |
30 |
> > + d=${d#${SYSROOT}} |
31 |
> > d=${d#${EPREFIX}} |
32 |
> > else |
33 |
> > d=${fallback} |
34 |
> |
35 |
> I was going to say this is not the best approach as it would be better |
36 |
> to tell pkg-config to not add the SYSROOT in the first place. I now |
37 |
> realise we have shot ourselves in the foot with cross-pkg-config as it |
38 |
> uses SYSROOT to set both PKG_CONFIG_SYSROOT_DIR to control the output |
39 |
> and PKG_CONFIG_LIBDIR to find the .pc files in the first place. I have |
40 |
> had prefix-related fixes for cross-pkg-config lined up for over a year |
41 |
> but unfortunately they do not address this. Trying to accommodate this |
42 |
> use case would probably just make it more confusing though so maybe |
43 |
> your approach is best after all. |
44 |
|
45 |
It would be cleaner overall if we could prevent SYSROOT from being |
46 |
added to the paths in the first place. |
47 |
|
48 |
> The EPREFIX line is (sometimes) wrong in EAPI 7 though and the same goes |
49 |
> for udev.eclass. It took a while to get this agreed and corrected in |
50 |
> PMS but if SYSROOT points to / then the effective prefix is BROOT, not |
51 |
> EPREFIX; they may not be the same. |
52 |
|
53 |
Ugh, that "corrected" logic in PMS head is nasty. |
54 |
|
55 |
> If you just strip ESYSROOT then |
56 |
> it will always do the right thing but you'll need this fall back for |
57 |
> older EAPIs. I'm not sure why you didn't do it in one line? |
58 |
|
59 |
I was trying to accommodate older EAPIs that do not define ESYSROOT. |
60 |
This seemed like the simplest approach. It also allows for the case |
61 |
where someone is not using cross-pkg-config, and |
62 |
PKG_CONFIG_SYSROOT_DIR is unset. Since SYSROOT and EPREFIX are removed |
63 |
separately, if one of them is already missing, it will just be |
64 |
skipped. |
65 |
|
66 |
> I forget if EPREFIX is normalised to be / rather thank blank. |
67 |
> |
68 |
> d=${d#${SYSROOT%/}/${EPREFIX#/}} |
69 |
|
70 |
SYSROOT never ends with a / in modern versions of portage (regardless |
71 |
of EAPI), so there's currently no need to remove a trailing slash. |
72 |
|
73 |
https://gitweb.gentoo.org/proj/portage.git/commit/?id=1b5110557d1dd725f7c12bbed4b7ceaaec29f2a3 |
74 |
|
75 |
I have never seen EPREFIX equal to "/", or end with a trailing slash. |
76 |
Given it is most commonly used as "${EPREFIX}/usr", this would result |
77 |
in double-slashes everywhere. |