Patchwork [bitbake-devel,RFC] build.py: create symlink for run.do_xxx scripts

login
register
mail settings
Submitter Nicolas Dechesne
Date Aug. 16, 2013, 9:20 a.m.
Message ID <1376644859-11034-1-git-send-email-nicolas.dechesne@linaro.org>
Download mbox | patch
Permalink /patch/55921/
State Accepted
Commit a672b39c5d529ba85d72eee8fef4c4273eaa5397
Headers show

Comments

Nicolas Dechesne - Aug. 16, 2013, 9:20 a.m.
The 'courtesy' symlink for log.do_xxx are quite useful when debugging, so
with this commit, we now get similar 'courtesy' symlink for run.do_xxx
scripts.

We only create symlink for tasks, not individual functions.

The symlink is create right before the actual runfile is created, indeed
we cannot create the symlink right after running the task since a failure
or execption can happen, in which case the symlink wouldn't be created,
and symlink are particularely useful when the task failed!

Another option would be create the symlink after the runfile is created,
and before the script is executed, but that means we need to duplicate the
code in case of Shell vs Python task.

Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
---
 lib/bb/build.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Leon Woestenberg - Aug. 22, 2013, 2:47 p.m.
Hello Nicolas,

On Fri, Aug 16, 2013 at 11:20 AM, Nicolas Dechesne <
nicolas.dechesne@linaro.org> wrote:

> The 'courtesy' symlink for log.do_xxx are quite useful when debugging, so
> with this commit, we now get similar 'courtesy' symlink for run.do_xxx
> scripts.
>
> Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
> ---
>

At least I can +1 on the debugging helpfulness, I would like this feature
to be in bitbake.

As it's a courtesy link only, the chosen approach seems good to me.

Regards,

Leon.
Khem Raj - Aug. 23, 2013, 6:51 a.m.
On Thu, Aug 22, 2013 at 7:47 AM, Leon Woestenberg
<sidebranch.openembedded@gmail.com> wrote:
> Hello Nicolas,
>
> On Fri, Aug 16, 2013 at 11:20 AM, Nicolas Dechesne
> <nicolas.dechesne@linaro.org> wrote:
>>
>> The 'courtesy' symlink for log.do_xxx are quite useful when debugging, so
>> with this commit, we now get similar 'courtesy' symlink for run.do_xxx
>> scripts.
>>
>> Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
>> ---
>
>
> At least I can +1 on the debugging helpfulness, I would like this feature to
> be in bitbake.
>
> As it's a courtesy link only, the chosen approach seems good to me.
>

yeah its useful. Many times you just want to execute the latest run.doXXX
and it will help there.

> Regards,
>
> Leon.
>
> _______________________________________________
> bitbake-devel mailing list
> bitbake-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/bitbake-devel
>
Nicolas Dechesne - Aug. 23, 2013, 2:52 p.m.
On Fri, Aug 23, 2013 at 8:51 AM, Khem Raj <raj.khem@gmail.com> wrote:

> yeah its useful. Many times you just want to execute the latest run.doXXX
> and it will help there.
>

since we are quite close to the freeze for 1.5, any chance this patch can
make it into 1.5?
thx!

Patch

diff --git a/lib/bb/build.py b/lib/bb/build.py
index d91ff53..0977ea7 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -190,6 +190,20 @@  def exec_func(func, d, dirs = None):
     runfile = os.path.join(tempdir, runfn)
     bb.utils.mkdirhier(os.path.dirname(runfile))
 
+    # Setup the courtesy link to the runfn, only for tasks
+    # we create the link 'just' before the run script is created
+    # if we create it after, and if the run script fails, then the
+    # link won't be created as an exception would be fired.
+    if task == func:
+        runlink = os.path.join(tempdir, 'run.{0}'.format(task))
+        if runlink:
+            bb.utils.remove(runlink)
+
+            try:
+                os.symlink(runfn, runlink)
+            except OSError:
+                pass
+
     with bb.utils.fileslocked(lockfiles):
         if ispython:
             exec_func_python(func, d, runfile, cwd=adir)