[bitbake-devel,OE-core,1/2] fetch2/__init__.py: Extend subdir unpack parameter to local folder

Submitted by Ming Liu on Nov. 13, 2015, 6:15 p.m. | Patch ID: 107673

Details

Message ID 1447438532-9595-1-git-send-email-liu.ming50@gmail.com
State New
Headers show

Commit Message

Ming Liu Nov. 13, 2015, 6:15 p.m.
From: Ming Liu <peter.x.liu@external.atlascopco.com>

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

Also tweaks the way to get subdir parameter, storing it into a variable
instead of calling urldata.parm.get() multiple times.

Signed-off-by: Ming Liu <peter.x.liu@external.atlascopco.com>
---
 lib/bb/fetch2/__init__.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index 288a1c8..d7439fa 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1412,6 +1412,7 @@  class FetchMethod(object):
             # If file == dest, then avoid any copies, as we already put the file into dest!
             dest = os.path.join(rootdir, os.path.basename(file))
             if (file != dest) and not (os.path.exists(dest) and os.path.samefile(file, dest)):
+                subdir = urldata.parm.get('subdir')
                 if os.path.isdir(file):
                     # If for example we're asked to copy file://foo/bar, we need to unpack the result into foo/bar
                     basepath = getattr(urldata, "basepath", None)
@@ -1423,6 +1424,8 @@  class FetchMethod(object):
                     if basepath and basepath.find("/") != -1:
                         destdir = basepath[:basepath.rfind('/')]
                         destdir = destdir.strip('/')
+                    if subdir:
+                        destdir = 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)
@@ -1432,11 +1435,11 @@  class FetchMethod(object):
                     # items.  So, only do so for file:// entries.
                     if urldata.type == "file" and urldata.path.find("/") != -1:
                        destdir = urldata.path.rsplit("/", 1)[0]
-                       if urldata.parm.get('subdir') != None:
-                          destdir = urldata.parm.get('subdir') + "/" + destdir
+                       if subdir:
+                          destdir = subdir + "/" + destdir
                     else:
-                       if urldata.parm.get('subdir') != None:
-                          destdir = urldata.parm.get('subdir')
+                       if subdir:
+                          destdir = subdir
                        else:
                           destdir = "."
                     bb.utils.mkdirhier("%s/%s" % (rootdir, destdir))