Patchwork [6/6] patch.bbclass: do_patch: unset TMPDIR from environment

login
register
mail settings
Submitter Robert Yang
Date March 11, 2014, 5:08 p.m.
Message ID <5a1dbe79b2581b458e5c43a262c9b9c8a809d081.1394555880.git.liezhi.yang@windriver.com>
Download mbox | patch
Permalink /patch/68433/
State New
Headers show

Comments

Robert Yang - March 11, 2014, 5:08 p.m.
The do_patch set TMPDIR via:
os.environ['TMPDIR'] = process_tmpdir

We need unset it after we use it, otherwise it would affect the env
after we run "bb.build.exec_func('do_patch', d)", and will cause
unexpected errors.

[YOCTO #5113]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta/classes/patch.bbclass | 1 +
 1 file changed, 1 insertion(+)
Ross Burton - March 13, 2014, 4:46 p.m.
On 11 March 2014 17:08, Robert Yang <liezhi.yang@windriver.com> wrote:
> We need unset it after we use it, otherwise it would affect the env
> after we run "bb.build.exec_func('do_patch', d)", and will cause
> unexpected errors.

This assignment has been there since October 2012, so what are the
problems that this causes?

Ross
Ross Burton - March 13, 2014, 4:54 p.m.
On 13 March 2014 16:46, Burton, Ross <ross.burton@intel.com> wrote:
> On 11 March 2014 17:08, Robert Yang <liezhi.yang@windriver.com> wrote:
>> We need unset it after we use it, otherwise it would affect the env
>> after we run "bb.build.exec_func('do_patch', d)", and will cause
>> unexpected errors.
>
> This assignment has been there since October 2012, so what are the
> problems that this causes?

So what bothers me about this (and the original patch) is that TMPDIR
has special meaning to bitbake and the conflict with patch's temporary
directory is unfortunate.  Maybe a better solution is to change
meta/lib/oe/patch.py to set TMPDIR when invoking patch so the changed
TMPDIR is constrained to the patch process and nothing else.

Ross
Christopher Larson - March 13, 2014, 6:11 p.m.
On Thu, Mar 13, 2014 at 9:54 AM, Burton, Ross <ross.burton@intel.com> wrote:

> On 13 March 2014 16:46, Burton, Ross <ross.burton@intel.com> wrote:
> > On 11 March 2014 17:08, Robert Yang <liezhi.yang@windriver.com> wrote:
> >> We need unset it after we use it, otherwise it would affect the env
> >> after we run "bb.build.exec_func('do_patch', d)", and will cause
> >> unexpected errors.
> >
> > This assignment has been there since October 2012, so what are the
> > problems that this causes?
>
> So what bothers me about this (and the original patch) is that TMPDIR
> has special meaning to bitbake and the conflict with patch's temporary
> directory is unfortunate.  Maybe a better solution is to change
> meta/lib/oe/patch.py to set TMPDIR when invoking patch so the changed
> TMPDIR is constrained to the patch process and nothing else.


That sounds like a clean approach to me.
Robert Yang - March 14, 2014, 10:17 a.m.
On 03/14/2014 12:54 AM, Burton, Ross wrote:
> On 13 March 2014 16:46, Burton, Ross <ross.burton@intel.com> wrote:
>> On 11 March 2014 17:08, Robert Yang <liezhi.yang@windriver.com> wrote:
>>> We need unset it after we use it, otherwise it would affect the env
>>> after we run "bb.build.exec_func('do_patch', d)", and will cause
>>> unexpected errors.
>>
>> This assignment has been there since October 2012, so what are the
>> problems that this causes?
>
> So what bothers me about this (and the original patch) is that TMPDIR
> has special meaning to bitbake and the conflict with patch's temporary
> directory is unfortunate.  Maybe a better solution is to change
> meta/lib/oe/patch.py to set TMPDIR when invoking patch so the changed
> TMPDIR is constrained to the patch process and nothing else.
>

Hi Ross,

The problem is that:
1) do_patch set "TMPDIR" in env, it would remove the directory but didn't
    unset the "TMPDIR".

2) autoconf will use the "TMPDIR" from the env:
autoconf/Autom4te/General.pm:  my $TMPDIR = $ENV{'TMPDIR'} || '/tmp';

And if the dir doesn't exist, there would be errors.

I had met this problem because I used the do_patch and do_configure
in one task:

bb.build.exec_func('do_patch', d)
bb.build.exec_func('do_configure', d)

I had split them into 2 tasks, so the "TMPDIR" doesn't affact the
archiver.bbclass any more.

I've tried to set the TMPDIR in meta/lib/oe/patch.py, but met more
problems, the PATCHTOOL = "patch" doesn't work (Seems only on
OpenSuse 12.2), I've filed a bug for it:

https://bugzilla.yoctoproject.org/show_bug.cgi?id=5968

I think that we can fix it in another thread since it doesn't affect
the archiver.bbclass, as we have talked, we may drop the
PATCHTOOL = "patch"

// Robert

> Ross
>
>

Patch

diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index 86c65b3..2c92463 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -177,6 +177,7 @@  python patch_do_patch() {
             bb.fatal(str(e))
 
     bb.utils.remove(process_tmpdir, True)
+    os.unsetenv('TMPDIR')
 }
 patch_do_patch[vardepsexclude] = "PATCHRESOLVE"