[bitbake-devel] [PATCH 1/1] perforce.py: fix the perforce fetcher

Chris Larson clarson at kergoth.com
Mon Feb 4 15:46:38 UTC 2013


On Mon, Feb 4, 2013 at 2:27 AM, Robert Yang <liezhi.yang at windriver.com>wrote:

> The bb.process.run() will return one tuple, e.g:
>
> p4file = ('strA\nStrB\nstrC\n'), then there will be an iteration on p4file:
>
> for i in p4file:
>         [snip]
>
> The i will be 's t r A ...', this is incorrect. use:
>
> p4file = p4file.splitlines()
>
> will fix the problem.
>
> [YOCTO #3619]
>
> Signed-off-by: Robert Yang <liezhi.yang at windriver.com>
> ---
>  bitbake/lib/bb/fetch2/perforce.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/bitbake/lib/bb/fetch2/perforce.py
> b/bitbake/lib/bb/fetch2/perforce.py
> index df3a3a3..86ec9ba 100644
> --- a/bitbake/lib/bb/fetch2/perforce.py
> +++ b/bitbake/lib/bb/fetch2/perforce.py
> @@ -170,7 +170,7 @@ class Perforce(FetchMethod):
>          logger.info("Fetch " + loc)
>          logger.info("%s%s files %s", p4cmd, p4opt, depot)
>          p4file, errors = bb.process.run("%s%s files %s" % (p4cmd, p4opt,
> depot))
> -        p4file = p4file.strip()
> +        p4file = p4file.splitlines()
>

Note that splitlines doesn't chop off the trailing newlines from the
individual strings. It *probably* wont cause an issue in this case due to
how it's passed to the shell in the subsequent subprocess call, but from a
correctness standpoint, I'd suggest changing this to something like p4files
= [f.rstrip() for f in p4file.splitlines], or doing an rstrip on the
individual files in the later iteration.
-- 
Christopher Larson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/bitbake-devel/attachments/20130204/8f48c017/attachment-0001.html>


More information about the bitbake-devel mailing list