Re: [OE-core] [RFC PATCH 04/15] bitbake: fetch2: Add striplevel support to unpack

2021-11-24 Thread Alexander Kanavin
Please extend the explanation a bit: how would a typical SRC_URI look that
uses the feature, what is the typical tarball structure and how it maps to
the unpacked tree.

Alex

On Wed, 24 Nov 2021 at 15:48, Stefan Herbrechtsmeier <
stefan.herbrechtsmeier-...@weidmueller.com> wrote:

> From: Stefan Herbrechtsmeier 
>
> Add striplevel support to unpack tar archives into specified sub
> directories. The node package manager (npm) need this feature to unpack
> packages into its node_modules directory.
>
> Signed-off-by: Stefan Herbrechtsmeier <
> stefan.herbrechtsme...@weidmueller.com>
> ---
>
>  bitbake/lib/bb/fetch2/__init__.py | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/bitbake/lib/bb/fetch2/__init__.py
> b/bitbake/lib/bb/fetch2/__init__.py
> index ded3106173..05b2d2e924 100644
> --- a/bitbake/lib/bb/fetch2/__init__.py
> +++ b/bitbake/lib/bb/fetch2/__init__.py
> @@ -1462,6 +1462,9 @@ class FetchMethod(object):
>  cmd = 'tar x --no-same-owner -f %s' % file
>  elif file.endswith('.tgz') or file.endswith('.tar.gz') or
> file.endswith('.tar.Z'):
>  cmd = 'tar xz --no-same-owner -f %s' % file
> +striplevel = urldata.parm.get('striplevel')
> +if striplevel:
> +cmd += ' --strip-components=%s' % striplevel
>  elif file.endswith('.tbz') or file.endswith('.tbz2') or
> file.endswith('.tar.bz2'):
>  cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
>  elif file.endswith('.gz') or file.endswith('.Z') or
> file.endswith('.z'):
> --
> 2.20.1
>
>

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#158717): 
https://lists.openembedded.org/g/openembedded-core/message/158717
Mute This Topic: https://lists.openembedded.org/mt/87282281/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[OE-core] [RFC PATCH 04/15] bitbake: fetch2: Add striplevel support to unpack

2021-11-24 Thread Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier 

Add striplevel support to unpack tar archives into specified sub
directories. The node package manager (npm) need this feature to unpack
packages into its node_modules directory.

Signed-off-by: Stefan Herbrechtsmeier 
---

 bitbake/lib/bb/fetch2/__init__.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/bitbake/lib/bb/fetch2/__init__.py 
b/bitbake/lib/bb/fetch2/__init__.py
index ded3106173..05b2d2e924 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -1462,6 +1462,9 @@ class FetchMethod(object):
 cmd = 'tar x --no-same-owner -f %s' % file
 elif file.endswith('.tgz') or file.endswith('.tar.gz') or 
file.endswith('.tar.Z'):
 cmd = 'tar xz --no-same-owner -f %s' % file
+striplevel = urldata.parm.get('striplevel')
+if striplevel:
+cmd += ' --strip-components=%s' % striplevel
 elif file.endswith('.tbz') or file.endswith('.tbz2') or 
file.endswith('.tar.bz2'):
 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
 elif file.endswith('.gz') or file.endswith('.Z') or 
file.endswith('.z'):
-- 
2.20.1


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#158703): 
https://lists.openembedded.org/g/openembedded-core/message/158703
Mute This Topic: https://lists.openembedded.org/mt/87282281/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-