summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>2021-11-25 13:59:52 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-26 17:01:37 +0000
commite241d0e78cc2312d4c751421a0fcecc53624aabf (patch)
tree1df18fc7ac185a86a104bca9313a8145b65a4597
parent8091ad4347ecbf14fcf4d1ee2d47b91670932cf8 (diff)
downloadpoky-e241d0e78cc2312d4c751421a0fcecc53624aabf.tar.gz
bitbake: fetch2: Add striplevel support to unpack
Add a parameter `striplevel` to the SRC_URI to strip NUMBER leading components (levels) from file names on extraction. For example, if the archive `archive.tar.gz` contains `some/file`, the SRC_URI `https://.../archive.tar.gz;subdir=other;striplevel=1` will extract `some/file` to `other/file`. This is useful to extract archives to a specified directory instead of the original root component of the archive. The feature is required for the npm support. The npm package contents should reside in a subfolder inside a npm archive (usually it is called package/). npm strips one directory layer when installing the package. (Bitbake rev: aa4926e5d9c92f33b4434e2da709ff0bf3049f5b) Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index b0d5508d06..0b39ea6aaa 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -1459,6 +1459,8 @@ class FetchMethod(object):
1459 1459
1460 if unpack: 1460 if unpack:
1461 tar_cmd = 'tar --extract --no-same-owner' 1461 tar_cmd = 'tar --extract --no-same-owner'
1462 if 'striplevel' in urldata.parm:
1463 tar_cmd += ' --strip-components=%s' % urldata.parm['striplevel']
1462 if file.endswith('.tar'): 1464 if file.endswith('.tar'):
1463 cmd = '%s -f %s' % (tar_cmd, file) 1465 cmd = '%s -f %s' % (tar_cmd, file)
1464 elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'): 1466 elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):