Skip to contentSkip to conversation

bitbake: fetch: Extend subdir unpack parameter to local folder

PATCH In review Ming Liu 3 participants 4 messages Sep 28, 2015 – Nov 13, 2015

lore
Share & tools
lore

Ming Liu

author
#0 lore raw

PATCH 1/1 bitbake: fetch: Extend subdir unpack parameter to local folder

From: Peter Liu <[email protected]>

This fixes urls of the form file://some/path/file;subdir=b. When the file is a folder.

---
 lib/bb/fetch2/__init__.py | 2 ++
 1 file changed, 2 insertions(+)
lib/bb/fetch2/__init__.py +2 -0
index 288a1c8..3a425aa 100644
@@ -1423,6 +1423,8 @@ class FetchMethod(object):
                     if basepath and basepath.find("/") != -1:
                         destdir = basepath[:basepath.rfind('/')]
                         destdir = destdir.strip('/')
+                    if urldata.parm.get('subdir') != None:
+                        destdir = urldata.parm.get('subdir') + "/" + destdir
                     if destdir != "." and not os.access("%s/%s" % (rootdir, destdir), os.F_OK):
                         os.makedirs("%s/%s" % (rootdir, destdir))
                     cmd = 'cp -fpPR %s %s/%s/' % (file, rootdir, destdir)
Signature · 1 line
1.9.1
#1 lore raw
Quoted 4 lines · Ming Liu
(quoted diff) +2 -0
+                    if urldata.parm.get('subdir') != None:
+                        destdir = urldata.parm.get('subdir') + "/" +

destdir

If you really care about the difference between None and the empty string, then this should be 'is not None', not '!= None', but most likely you don't, in which case 'if urldata.parm.get('subdir')' is sufficient, and cleaner. Also you do the parm.get() twice, it may be better to store that in a variable.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#2 lore raw
Quoted 7 lines · Christopher Larson

On Mon, Sep 28, 2015 at 6:11 AM, Ming Liu <[email protected]> wrote:
+ if urldata.parm.get('subdir') != None:
+ destdir = urldata.parm.get('subdir')
+ "/" + destdir

Quoted 5 lines

If you really care about the difference between None and the empty string, then this should be 'is not None', not '!= None', but most likely you don't, in which case 'if urldata.parm.get('subdir')' is sufficient, and cleaner. Also you do the parm.get() twice, it may be better to store that in a variable.

Chris is correct, this patch needs tweaking. This area of the code also keeps seeing various issues so I'd like to ask that we add a test case for this in lib/bb/tests/ so we can ensure this doesn't regress in the future please.

Cheers,

Richard

author
#3 lore raw

Hi, Christopher, Richard:

Thanks for the reviewing! And sorry to this delayed feedback, I was on a vacation.
I had send another patch set which tweaked the code like Christopher suggested, and added a test case for it.

the best,
thank you

2015-10-05 10:07 GMT+02:00 Richard Purdie <
[email protected]>:

Quoted 25 lines · Christopher Larson
Quoted 7 lines

On Mon, Sep 28, 2015 at 6:11 AM, Ming Liu <[email protected]> wrote:
+ if urldata.parm.get('subdir') != None:
+ destdir = urldata.parm.get('subdir')
+ "/" + destdir

Quoted 5 lines

If you really care about the difference between None and the empty string, then this should be 'is not None', not '!= None', but most likely you don't, in which case 'if urldata.parm.get('subdir')' is sufficient, and cleaner. Also you do the parm.get() twice, it may be better to store that in a variable.

Chris is correct, this patch needs tweaking. This area of the code also keeps seeing various issues so I'd like to ask that we add a test case for this in lib/bb/tests/ so we can ensure this doesn't regress in the future please.

Cheers,

Richard