Patchwork [bitbake-devel] bb.utils.which is intend to locate regular file only as it is written in comment

login
register
mail settings
Submitter Vitaliy Kharin
Date July 8, 2014, 3:09 p.m.
Message ID <1404832184-16471-1-git-send-email-vitaliy.kharin@lge.com>
Download mbox | patch
Permalink /patch/75195/
State New
Headers show

Comments

Vitaliy Kharin - July 8, 2014, 3:09 p.m.
Signed-off-by: Vitaliy Kharin <vitaliy.kharin@lge.com>
---
 bitbake/lib/bb/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Chris Larson - July 8, 2014, 6:54 p.m.
On Tue, Jul 8, 2014 at 8:09 AM, Vitaliy Kharin <kvserr@gmail.com> wrote:

> Signed-off-by: Vitaliy Kharin <vitaliy.kharin@lge.com>
> ---
>  bitbake/lib/bb/utils.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
> index 0be45e1..c48b237 100644
> --- a/bitbake/lib/bb/utils.py
> +++ b/bitbake/lib/bb/utils.py
> @@ -809,7 +809,7 @@ def which(path, item, direction = 0, history = False):
>      for p in paths:
>          next = os.path.join(p, item)
>          hist.append(next)
> -        if os.path.exists(next):
> +        if os.path.isfile(next):
>              if not os.path.isabs(next):
>                  next = os.path.abspath(next)
>              if history:
>

This seems questionable to me. With this, it wouldn't find symlinks, no?
Vitaliy Kharin - July 9, 2014, 10:43 a.m.
Actually it would return true if path will be a symlink. I checked it.
Also please look at
https://docs.python.org/2/library/os.path.html#os.path.isfile
"...This follows symbolic links, so both islink()
<https://docs.python.org/2/library/os.path.html#os.path.islink> and isfile()
<https://docs.python.org/2/library/os.path.html#os.path.isfile> can be true
for the same path."


2014-07-08 22:54 GMT+04:00 Christopher Larson <clarson@kergoth.com>:

>
> On Tue, Jul 8, 2014 at 8:09 AM, Vitaliy Kharin <kvserr@gmail.com> wrote:
>
>> Signed-off-by: Vitaliy Kharin <vitaliy.kharin@lge.com>
>> ---
>>  bitbake/lib/bb/utils.py | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
>> index 0be45e1..c48b237 100644
>> --- a/bitbake/lib/bb/utils.py
>> +++ b/bitbake/lib/bb/utils.py
>> @@ -809,7 +809,7 @@ def which(path, item, direction = 0, history = False):
>>      for p in paths:
>>          next = os.path.join(p, item)
>>          hist.append(next)
>> -        if os.path.exists(next):
>> +        if os.path.isfile(next):
>>              if not os.path.isabs(next):
>>                  next = os.path.abspath(next)
>>              if history:
>>
>
> This seems questionable to me. With this, it wouldn't find symlinks, no?
> --
> Christopher Larson
> clarson at kergoth dot com
> Founder - BitBake, OpenEmbedded, OpenZaurus
> Maintainer - Tslib
> Senior Software Engineer, Mentor Graphics
>
Chris Larson - July 9, 2014, 2:59 p.m.
On Wed, Jul 9, 2014 at 3:43 AM, Vitaliy Kharin <kvserr@gmail.com> wrote:

> Actually it would return true if path will be a symlink. I checked it.
> Also please look at
> https://docs.python.org/2/library/os.path.html#os.path.isfile
> "...This follows symbolic links, so both islink()
> <https://docs.python.org/2/library/os.path.html#os.path.islink> and
> isfile() <https://docs.python.org/2/library/os.path.html#os.path.isfile> can
> be true for the same path."
>

Ah, good, I stand corrected. Thanks for the clarification.

Patch

diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 0be45e1..c48b237 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -809,7 +809,7 @@  def which(path, item, direction = 0, history = False):
     for p in paths:
         next = os.path.join(p, item)
         hist.append(next)
-        if os.path.exists(next):
+        if os.path.isfile(next):
             if not os.path.isabs(next):
                 next = os.path.abspath(next)
             if history: