summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2
diff options
context:
space:
mode:
authorAlexander Shashkevich <alex@stunpix.com>2016-02-25 18:32:31 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-02 22:41:22 +0000
commit865d2feff6178010a21a994e9ed8b155671dc160 (patch)
treed15766d28c93aab5ebcbe3dd1e83678f3a0ac789 /bitbake/lib/bb/fetch2
parentfb437d338a1ecf09ee800eecb9b2b06b1a73ee51 (diff)
downloadpoky-865d2feff6178010a21a994e9ed8b155671dc160.tar.gz
bitbake: fetch2: fixes copying of file://dir; subdir=foo, bug 6128 and bug 6129
When in SRC_URI appears file://dir;subdir=foo unpacker copies 'dir' to ${WORKDIR}, not ${WORKDIR}/foo as it should be. These changes are fixing following bugs as well: Bug 6128 - Incorrect wildcard unpack behaviour in fetcher Bug 6129 - Local directories unpack to a different location than local files (Bitbake rev: e659a3b0c2771679057ee3e13cd42e6c62383ff2) Signed-off-by: Alexander Shashkevich <alex@stunpix.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py61
1 files changed, 24 insertions, 37 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index d36655071b..9ebdcdb91d 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -1318,6 +1318,11 @@ class FetchMethod(object):
1318 iterate = False 1318 iterate = False
1319 file = urldata.localpath 1319 file = urldata.localpath
1320 1320
1321 # Localpath can't deal with 'dir/*' entries, so it converts them to '.',
1322 # but it must be corrected back for local files copying
1323 if urldata.basename == '*' and file.endswith('/.'):
1324 file = '%s/%s' % (file.rstrip('/.'), urldata.path)
1325
1321 try: 1326 try:
1322 unpack = bb.utils.to_boolean(urldata.parm.get('unpack'), True) 1327 unpack = bb.utils.to_boolean(urldata.parm.get('unpack'), True)
1323 except ValueError as exc: 1328 except ValueError as exc:
@@ -1375,50 +1380,32 @@ class FetchMethod(object):
1375 elif file.endswith('.7z'): 1380 elif file.endswith('.7z'):
1376 cmd = '7za x -y %s 1>/dev/null' % file 1381 cmd = '7za x -y %s 1>/dev/null' % file
1377 1382
1383 # If 'subdir' param exists, create a dir and use it as destination for unpack cmd
1384 if 'subdir' in urldata.parm:
1385 unpackdir = '%s/%s' % (rootdir, urldata.parm.get('subdir'))
1386 bb.utils.mkdirhier(unpackdir)
1387 else:
1388 unpackdir = rootdir
1389
1378 if not unpack or not cmd: 1390 if not unpack or not cmd:
1379 # If file == dest, then avoid any copies, as we already put the file into dest! 1391 # If file == dest, then avoid any copies, as we already put the file into dest!
1380 dest = os.path.join(rootdir, os.path.basename(file)) 1392 dest = os.path.join(unpackdir, os.path.basename(file))
1381 if (file != dest) and not (os.path.exists(dest) and os.path.samefile(file, dest)): 1393 if file != dest and not (os.path.exists(dest) and os.path.samefile(file, dest)):
1382 if os.path.isdir(file): 1394 destdir = '.'
1383 # If for example we're asked to copy file://foo/bar, we need to unpack the result into foo/bar 1395 # For file:// entries all intermediate dirs in path must be created at destination
1384 basepath = getattr(urldata, "basepath", None) 1396 if urldata.type == "file":
1385 destdir = "." 1397 urlpath = urldata.path.rstrip('/') # Trailing '/' does a copying to wrong place
1386 if basepath and basepath.endswith("/"): 1398 if urlpath.find("/") != -1:
1387 basepath = basepath.rstrip("/") 1399 destdir = urlpath.rsplit("/", 1)[0] + '/'
1388 elif basepath: 1400 bb.utils.mkdirhier("%s/%s" % (unpackdir, destdir))
1389 basepath = os.path.dirname(basepath) 1401 cmd = 'cp -fpPR %s %s' % (file, destdir)
1390 if basepath and basepath.find("/") != -1:
1391 destdir = basepath[:basepath.rfind('/')]
1392 destdir = destdir.strip('/')
1393 if destdir != "." and not os.access("%s/%s" % (rootdir, destdir), os.F_OK):
1394 os.makedirs("%s/%s" % (rootdir, destdir))
1395 cmd = 'cp -fpPR %s %s/%s/' % (file, rootdir, destdir)
1396 #cmd = 'tar -cf - -C "%d" -ps . | tar -xf - -C "%s/%s/"' % (file, rootdir, destdir)
1397 else:
1398 # The "destdir" handling was specifically done for FILESPATH
1399 # items. So, only do so for file:// entries.
1400 if urldata.type == "file" and urldata.path.find("/") != -1:
1401 destdir = urldata.path.rsplit("/", 1)[0]
1402 if urldata.parm.get('subdir') != None:
1403 destdir = urldata.parm.get('subdir') + "/" + destdir
1404 else:
1405 if urldata.parm.get('subdir') != None:
1406 destdir = urldata.parm.get('subdir')
1407 else:
1408 destdir = "."
1409 bb.utils.mkdirhier("%s/%s" % (rootdir, destdir))
1410 cmd = 'cp -f %s %s/%s/' % (file, rootdir, destdir)
1411 1402
1412 if not cmd: 1403 if not cmd:
1413 return 1404 return
1414 1405
1415 # Change to subdir before executing command 1406 # Change to unpackdir before executing command
1416 save_cwd = os.getcwd(); 1407 save_cwd = os.getcwd();
1417 os.chdir(rootdir) 1408 os.chdir(unpackdir)
1418 if 'subdir' in urldata.parm:
1419 newdir = ("%s/%s" % (rootdir, urldata.parm.get('subdir')))
1420 bb.utils.mkdirhier(newdir)
1421 os.chdir(newdir)
1422 1409
1423 path = data.getVar('PATH', True) 1410 path = data.getVar('PATH', True)
1424 if path: 1411 if path: