[bitbake-devel] [OE-core] [PATCH 1/2] fetch2/__init__.py: Extend subdir unpack parameter to local folder
Ming Liu
liu.ming50 at gmail.com
Fri Nov 13 18:15:31 UTC 2015
From: Ming Liu <peter.x.liu at 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 at external.atlascopco.com>
---
lib/bb/fetch2/__init__.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
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))
--
1.9.1
More information about the bitbake-devel
mailing list