1 |
On 03/18/2017 02:16 PM, Michał Górny wrote: |
2 |
> On sob, 2017-03-18 at 13:45 -0700, Zac Medico wrote: |
3 |
>> On Sat, Mar 18, 2017 at 1:12 PM, Zac Medico <zmedico@g.o> wrote: |
4 |
>>> On Sat, Mar 18, 2017 at 12:57 PM, Zac Medico <zmedico@g.o> wrote: |
5 |
>>>> On Sat, Mar 18, 2017 at 12:04 PM, Michał Górny <mgorny@g.o> wrote: |
6 |
>>>>> Ensure that DISTDIR is always defined to the path to the shadow |
7 |
>>>>> directory. This ensures that PMS rules for consistent value are |
8 |
>>>>> followed, and that no global scope calls should be able to access |
9 |
>>>>> the distfile directory. This also ensures that global-scope assignments |
10 |
>>>>> (e.g. in PATCHES) do not work around the shadow directory. |
11 |
>>>>> --- |
12 |
>>>>> pym/portage/package/ebuild/doebuild.py | 9 +++++---- |
13 |
>>>>> pym/portage/package/ebuild/prepare_build_dirs.py | 6 ++---- |
14 |
>>>>> 2 files changed, 7 insertions(+), 8 deletions(-) |
15 |
>>>>> |
16 |
>>>>> diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py |
17 |
>>>>> index 15e4abb48..8efc08334 100644 |
18 |
>>>>> --- a/pym/portage/package/ebuild/doebuild.py |
19 |
>>>>> +++ b/pym/portage/package/ebuild/doebuild.py |
20 |
>>>>> @@ -348,7 +348,8 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None, |
21 |
>>>>> |
22 |
>>>>> mysettings["PORTDIR"] = os.path.realpath(mysettings["PORTDIR"]) |
23 |
>>>>> mysettings.pop("PORTDIR_OVERLAY", None) |
24 |
>>>>> - mysettings["DISTDIR"] = os.path.realpath(mysettings["DISTDIR"]) |
25 |
>>>>> + if "PORTAGE_ACTUAL_DISTDIR" not in mysettings: |
26 |
>>>>> + mysettings["PORTAGE_ACTUAL_DISTDIR"] = os.path.realpath(mysettings["DISTDIR"]) |
27 |
>>>>> mysettings["RPMDIR"] = os.path.realpath(mysettings["RPMDIR"]) |
28 |
>>>>> |
29 |
>>>>> mysettings["ECLASSDIR"] = mysettings["PORTDIR"]+"/eclass" |
30 |
>>>>> @@ -390,6 +391,7 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None, |
31 |
>>>>> mysettings["WORKDIR"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "work") |
32 |
>>>>> mysettings["D"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "image") + os.sep |
33 |
>>>>> mysettings["T"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], "temp") |
34 |
>>>>> + mysettings["DISTDIR"] = os.path.join(settings["PORTAGE_BUILDDIR"], "distdir") |
35 |
>>>>> mysettings["FILESDIR"] = os.path.join(settings["PORTAGE_BUILDDIR"], "files") |
36 |
>>>> |
37 |
>>>> The EbuildFetcher already_fetched and _prefetch_size_ok methods use |
38 |
>>>> DISTDIR after doebuild_environment has been called, so they need to be |
39 |
>>>> updated to use PORTAGE_ACTUAL_DISTDIR. |
40 |
>>> |
41 |
>>> Also, this code in doebuild uses DISTDIR before _prepare_fake_distdir |
42 |
>>> gets called called: |
43 |
>>> |
44 |
>>> for x in alist: |
45 |
>>> writemsg_stdout(">>> Checking %s's mtime...\n" % x) |
46 |
>>> try: |
47 |
>>> x_st = os.stat(os.path.join( |
48 |
>>> mysettings["DISTDIR"], x)) |
49 |
>>> |
50 |
>>> Also, bin/ebuild calls doebuild_environment before doebuild, which |
51 |
>>> means that this doebuild code also needs to use PORTAGE_ACTUAL_DISTDIR |
52 |
>>> if it's in mysettings: |
53 |
>>> |
54 |
>>> mf = repo_config.load_manifest(pkgdir, mysettings["DISTDIR"]) |
55 |
>> |
56 |
>> We should probably implement the fake DISTDIR setting inside the |
57 |
>> config environ method, so that we can eliminate all of this |
58 |
>> error-prone DISTDIR/PORTAGE_ACTUAL_DISTDIR stuff. |
59 |
> |
60 |
> You're the expert here. I'm just the person who hammers it till it seems |
61 |
> to work semi-reliably, and curse on whoever designed it ;-P. Would you |
62 |
> be able to take it from here? I barely understand what you're talking |
63 |
> about. |
64 |
|
65 |
Every ebuild phase gets its environment from the config environ method, so |
66 |
adding this code to the end of the environ method will perform the |
67 |
necessary translation for all ebuild phases: |
68 |
|
69 |
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py |
70 |
index ef29afe..4c642a7 100644 |
71 |
--- a/pym/portage/package/ebuild/config.py |
72 |
+++ b/pym/portage/package/ebuild/config.py |
73 |
@@ -2816,6 +2816,15 @@ class config(object): |
74 |
else: |
75 |
raise AssertionError("C locale did not pass the test!") |
76 |
|
77 |
+ try: |
78 |
+ builddir = mydict["PORTAGE_BUILDDIR"] |
79 |
+ distdir = mydict["DISTDIR"] |
80 |
+ except KeyError: |
81 |
+ pass |
82 |
+ else: |
83 |
+ mydict["PORTAGE_ACTUAL_DISTDIR"] = distdir |
84 |
+ mydict["DISTDIR"] = os.path.join(builddir, "distdir") |
85 |
+ |
86 |
return mydict |
87 |
|
88 |
def thirdpartymirrors(self): |
89 |
|
90 |
|
91 |
-- |
92 |
Thanks, |
93 |
Zac |