aboutsummaryrefslogtreecommitdiffstats
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:34 +0000
commitaa4926e5d9c92f33b4434e2da709ff0bf3049f5b (patch)
tree197da6d5fc8f5231f044bd2270eaa4932ae79bc3
parenta08e57c9eaec1d9740a96149bf4843e576da4e5c (diff)
downloadbitbake-aa4926e5d9c92f33b4434e2da709ff0bf3049f5b.tar.gz
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. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/fetch2/__init__.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index b0d5508d0..0b39ea6aa 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1459,6 +1459,8 @@ class FetchMethod(object):
if unpack:
tar_cmd = 'tar --extract --no-same-owner'
+ if 'striplevel' in urldata.parm:
+ tar_cmd += ' --strip-components=%s' % urldata.parm['striplevel']
if file.endswith('.tar'):
cmd = '%s -f %s' % (tar_cmd, file)
elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):