On 03/18/2017 02:16 PM, Michał Górny wrote:
> On sob, 2017-03-18 at 13:45 -0700, Zac Medico wrote:
>> On Sat, Mar 18, 2017 at 1:12 PM, Zac Medico <zmed...@gentoo.org> wrote:
>>> On Sat, Mar 18, 2017 at 12:57 PM, Zac Medico <zmed...@gentoo.org> wrote:
>>>> On Sat, Mar 18, 2017 at 12:04 PM, Michał Górny <mgo...@gentoo.org> wrote:
>>>>> Ensure that DISTDIR is always defined to the path to the shadow
>>>>> directory. This ensures that PMS rules for consistent value are
>>>>> followed, and that no global scope calls should be able to access
>>>>> the distfile directory. This also ensures that global-scope assignments
>>>>> (e.g. in PATCHES) do not work around the shadow directory.
>>>>> ---
>>>>>  pym/portage/package/ebuild/doebuild.py           | 9 +++++----
>>>>>  pym/portage/package/ebuild/prepare_build_dirs.py | 6 ++----
>>>>>  2 files changed, 7 insertions(+), 8 deletions(-)
>>>>>
>>>>> diff --git a/pym/portage/package/ebuild/doebuild.py 
>>>>> b/pym/portage/package/ebuild/doebuild.py
>>>>> index 15e4abb48..8efc08334 100644
>>>>> --- a/pym/portage/package/ebuild/doebuild.py
>>>>> +++ b/pym/portage/package/ebuild/doebuild.py
>>>>> @@ -348,7 +348,8 @@ def doebuild_environment(myebuild, mydo, myroot=None, 
>>>>> settings=None,
>>>>>
>>>>>         mysettings["PORTDIR"] = os.path.realpath(mysettings["PORTDIR"])
>>>>>         mysettings.pop("PORTDIR_OVERLAY", None)
>>>>> -       mysettings["DISTDIR"] = os.path.realpath(mysettings["DISTDIR"])
>>>>> +       if "PORTAGE_ACTUAL_DISTDIR" not in mysettings:
>>>>> +               mysettings["PORTAGE_ACTUAL_DISTDIR"] = 
>>>>> os.path.realpath(mysettings["DISTDIR"])
>>>>>         mysettings["RPMDIR"]  = os.path.realpath(mysettings["RPMDIR"])
>>>>>
>>>>>         mysettings["ECLASSDIR"]   = mysettings["PORTDIR"]+"/eclass"
>>>>> @@ -390,6 +391,7 @@ def doebuild_environment(myebuild, mydo, myroot=None, 
>>>>> settings=None,
>>>>>         mysettings["WORKDIR"] = 
>>>>> os.path.join(mysettings["PORTAGE_BUILDDIR"], "work")
>>>>>         mysettings["D"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], 
>>>>> "image") + os.sep
>>>>>         mysettings["T"] = os.path.join(mysettings["PORTAGE_BUILDDIR"], 
>>>>> "temp")
>>>>> +       mysettings["DISTDIR"] = 
>>>>> os.path.join(settings["PORTAGE_BUILDDIR"], "distdir")
>>>>>         mysettings["FILESDIR"] = 
>>>>> os.path.join(settings["PORTAGE_BUILDDIR"], "files")
>>>>
>>>> The EbuildFetcher already_fetched and _prefetch_size_ok methods use
>>>> DISTDIR after doebuild_environment has been called, so they need to be
>>>> updated to use PORTAGE_ACTUAL_DISTDIR.
>>>
>>> Also, this code in doebuild uses DISTDIR before _prepare_fake_distdir
>>> gets called called:
>>>
>>>     for x in alist:
>>>         writemsg_stdout(">>> Checking %s's mtime...\n" % x)
>>>         try:
>>>             x_st = os.stat(os.path.join(
>>>                 mysettings["DISTDIR"], x))
>>>
>>> Also, bin/ebuild calls doebuild_environment before doebuild, which
>>> means that this doebuild code also needs to use PORTAGE_ACTUAL_DISTDIR
>>> if it's in mysettings:
>>>
>>>     mf = repo_config.load_manifest(pkgdir, mysettings["DISTDIR"])
>>
>> We should probably implement the fake DISTDIR setting inside the
>> config environ method, so that we can eliminate all of this
>> error-prone DISTDIR/PORTAGE_ACTUAL_DISTDIR stuff.
> 
> You're the expert here. I'm just the person who hammers it till it seems
> to work semi-reliably, and curse on whoever designed it ;-P. Would you
> be able to take it from here? I barely understand what you're talking
> about.

Every ebuild phase gets its environment from the config environ method, so
adding this code to the end of the environ method will perform the
necessary translation for all ebuild phases:

diff --git a/pym/portage/package/ebuild/config.py 
b/pym/portage/package/ebuild/config.py
index ef29afe..4c642a7 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -2816,6 +2816,15 @@ class config(object):
                                else:
                                        raise AssertionError("C locale did not 
pass the test!")
 
+               try:
+                       builddir = mydict["PORTAGE_BUILDDIR"]
+                       distdir = mydict["DISTDIR"]
+               except KeyError:
+                       pass
+               else:
+                       mydict["PORTAGE_ACTUAL_DISTDIR"] = distdir
+                       mydict["DISTDIR"] = os.path.join(builddir, "distdir")
+
                return mydict
 
        def thirdpartymirrors(self):


-- 
Thanks,
Zac

Reply via email to