* [PATCH 1/2] classes/license.bbclass: don't set [dirs] and [cleandirs]
@ 2016-07-14 16:39 Ross Burton
2016-07-14 16:39 ` [PATCH 2/2] build: don't use $B as the default cwd for functions Ross Burton
0 siblings, 1 reply; 4+ messages in thread
From: Ross Burton @ 2016-07-14 16:39 UTC (permalink / raw)
To: openembedded-core
There's no need to set these as the restore from sstate will create the
directories as required.
Signed-off-by: Ross Burton <ross.burton@intel.com>
---
meta/classes/license.bbclass | 2 --
1 file changed, 2 deletions(-)
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index c543637..26c297d 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -668,8 +668,6 @@ do_rootfs[recrdeptask] += "do_populate_lic"
IMAGE_POSTPROCESS_COMMAND_prepend = "write_deploy_manifest; "
do_image[recrdeptask] += "do_populate_lic"
-do_populate_lic_setscene[dirs] = "${LICSSTATEDIR}/${PN}"
-do_populate_lic_setscene[cleandirs] = "${LICSSTATEDIR}"
python do_populate_lic_setscene () {
sstate_setscene(d)
}
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] build: don't use $B as the default cwd for functions
2016-07-14 16:39 [PATCH 1/2] classes/license.bbclass: don't set [dirs] and [cleandirs] Ross Burton
@ 2016-07-14 16:39 ` Ross Burton
2016-07-14 18:52 ` Leonardo Sandoval
0 siblings, 1 reply; 4+ messages in thread
From: Ross Burton @ 2016-07-14 16:39 UTC (permalink / raw)
To: openembedded-core
When bitbake executes a shell or Python function it can cd/chdir() into a
directory before executing the task. If no directory is specified then the
default of $B is used. However $B is an OpenEmbedded variable and BitBake
shouldn't be aware of it.
To solve this change the semantics slightly so that if no directory is
specified, the current working directory isn't changed. There's also a sanity
check that emits a warning if a Python task does os.chdir() without restoring
the old path, and the previous working directory is restored.
This does change semantics: whereas before a function in OE would have $B as the
working directory unless specified, now the working directory is the top of the
build tree. Any breakage this causes can be solved by either adding
do_some_task[dirs] = "${B}" or by using absolute paths in the task.
[ YOCTO #4634 ]
Signed-off-by: Ross Burton <ross.burton@intel.com>
---
bitbake/lib/bb/build.py | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 4fb2a77..4f01d66 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -188,6 +188,11 @@ class LogTee(object):
def exec_func(func, d, dirs = None, pythonexception=False):
"""Execute a BB 'function'"""
+ try:
+ oldcwd = os.getcwd()
+ except:
+ oldcwd = None
+
body = d.getVar(func, False)
if not body:
if body is None:
@@ -211,9 +216,7 @@ def exec_func(func, d, dirs = None, pythonexception=False):
bb.utils.mkdirhier(adir)
adir = dirs[-1]
else:
- adir = d.getVar('B', True)
- bb.utils.mkdirhier(adir)
-
+ adir = None
ispython = flags.get('python')
lockflag = flags.get('lockfiles')
@@ -257,6 +260,13 @@ def exec_func(func, d, dirs = None, pythonexception=False):
else:
exec_func_shell(func, d, runfile, cwd=adir)
+ if oldcwd and os.getcwd() != oldcwd:
+ try:
+ bb.warn("Task %s changed cwd to %s" % (func, os.getcwd()))
+ os.chdir(oldcwd)
+ except:
+ pass
+
_functionfmt = """
{function}(d)
"""
@@ -272,7 +282,8 @@ def exec_func_python(func, d, runfile, cwd=None, pythonexception=False):
if cwd:
try:
olddir = os.getcwd()
- except OSError:
+ except OSError as e:
+ bb.warn("%s: Cannot get cwd: %s" % (func, e))
olddir = None
os.chdir(cwd)
@@ -298,8 +309,8 @@ def exec_func_python(func, d, runfile, cwd=None, pythonexception=False):
if cwd and olddir:
try:
os.chdir(olddir)
- except OSError:
- pass
+ except OSError as e:
+ bb.warn("%s: Cannot restore cwd %s: %s" % (func, olddir, e))
def shell_trap_code():
return '''#!/bin/sh\n
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] build: don't use $B as the default cwd for functions
2016-07-14 16:39 ` [PATCH 2/2] build: don't use $B as the default cwd for functions Ross Burton
@ 2016-07-14 18:52 ` Leonardo Sandoval
2016-07-14 18:56 ` Burton, Ross
0 siblings, 1 reply; 4+ messages in thread
From: Leonardo Sandoval @ 2016-07-14 18:52 UTC (permalink / raw)
To: Ross Burton, openembedded-core
this is a bitbake change so it was sent to the wrong list.
On 07/14/2016 11:39 AM, Ross Burton wrote:
> When bitbake executes a shell or Python function it can cd/chdir() into a
> directory before executing the task. If no directory is specified then the
> default of $B is used. However $B is an OpenEmbedded variable and BitBake
> shouldn't be aware of it.
>
> To solve this change the semantics slightly so that if no directory is
> specified, the current working directory isn't changed. There's also a sanity
> check that emits a warning if a Python task does os.chdir() without restoring
> the old path, and the previous working directory is restored.
>
> This does change semantics: whereas before a function in OE would have $B as the
> working directory unless specified, now the working directory is the top of the
> build tree. Any breakage this causes can be solved by either adding
> do_some_task[dirs] = "${B}" or by using absolute paths in the task.
>
> [ YOCTO #4634 ]
>
> Signed-off-by: Ross Burton <ross.burton@intel.com>
> ---
> bitbake/lib/bb/build.py | 23 +++++++++++++++++------
> 1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
> index 4fb2a77..4f01d66 100644
> --- a/bitbake/lib/bb/build.py
> +++ b/bitbake/lib/bb/build.py
> @@ -188,6 +188,11 @@ class LogTee(object):
> def exec_func(func, d, dirs = None, pythonexception=False):
> """Execute a BB 'function'"""
>
> + try:
> + oldcwd = os.getcwd()
> + except:
> + oldcwd = None
> +
> body = d.getVar(func, False)
> if not body:
> if body is None:
> @@ -211,9 +216,7 @@ def exec_func(func, d, dirs = None, pythonexception=False):
> bb.utils.mkdirhier(adir)
> adir = dirs[-1]
> else:
> - adir = d.getVar('B', True)
> - bb.utils.mkdirhier(adir)
> -
> + adir = None
> ispython = flags.get('python')
>
> lockflag = flags.get('lockfiles')
> @@ -257,6 +260,13 @@ def exec_func(func, d, dirs = None, pythonexception=False):
> else:
> exec_func_shell(func, d, runfile, cwd=adir)
>
> + if oldcwd and os.getcwd() != oldcwd:
> + try:
> + bb.warn("Task %s changed cwd to %s" % (func, os.getcwd()))
> + os.chdir(oldcwd)
> + except:
> + pass
> +
> _functionfmt = """
> {function}(d)
> """
> @@ -272,7 +282,8 @@ def exec_func_python(func, d, runfile, cwd=None, pythonexception=False):
> if cwd:
> try:
> olddir = os.getcwd()
> - except OSError:
> + except OSError as e:
> + bb.warn("%s: Cannot get cwd: %s" % (func, e))
> olddir = None
> os.chdir(cwd)
>
> @@ -298,8 +309,8 @@ def exec_func_python(func, d, runfile, cwd=None, pythonexception=False):
> if cwd and olddir:
> try:
> os.chdir(olddir)
> - except OSError:
> - pass
> + except OSError as e:
> + bb.warn("%s: Cannot restore cwd %s: %s" % (func, olddir, e))
>
> def shell_trap_code():
> return '''#!/bin/sh\n
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] build: don't use $B as the default cwd for functions
2016-07-14 18:52 ` Leonardo Sandoval
@ 2016-07-14 18:56 ` Burton, Ross
0 siblings, 0 replies; 4+ messages in thread
From: Burton, Ross @ 2016-07-14 18:56 UTC (permalink / raw)
To: Leonardo Sandoval; +Cc: OE-core
[-- Attachment #1: Type: text/plain, Size: 238 bytes --]
On 14 July 2016 at 19:52, Leonardo Sandoval <
leonardo.sandoval.gonzalez@linux.intel.com> wrote:
> this is a bitbake change so it was sent to the wrong list.
>
Yes it was, I was in a rush to send patches before dinner :)
Ross
[-- Attachment #2: Type: text/html, Size: 736 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-14 18:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-14 16:39 [PATCH 1/2] classes/license.bbclass: don't set [dirs] and [cleandirs] Ross Burton
2016-07-14 16:39 ` [PATCH 2/2] build: don't use $B as the default cwd for functions Ross Burton
2016-07-14 18:52 ` Leonardo Sandoval
2016-07-14 18:56 ` Burton, Ross
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox