From a672b39c5d529ba85d72eee8fef4c4273eaa5397 Mon Sep 17 00:00:00 2001 From: Nicolas Dechesne Date: Fri, 16 Aug 2013 11:20:59 +0200 Subject: [PATCH] build.py: create symlink for run.do_xxx scripts 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 Signed-off-by: Richard Purdie --- lib/bb/build.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/bb/build.py b/lib/bb/build.py index 6fffbc5da3d..91c3a42db67 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) -- 2.47.3