diff mbox series

[RFC,07/21] fetch2: add unpack support for npm archives

Message ID 20241220112613.22647-8-stefan.herbrechtsmeier-oss@weidmueller.com
State New
Headers show
Series Concept for tightly coupled package manager (Node.js, Go, Rust) | expand

Commit Message

Stefan Herbrechtsmeier Dec. 20, 2024, 11:25 a.m. UTC
From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Add unpack support for npm archives with unusual member ordering and
disable warnings for unknown extended header keywords.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
---

 lib/bb/fetch2/__init__.py | 1 +
 1 file changed, 1 insertion(+)

Comments

Richard Purdie Dec. 23, 2024, 11:56 a.m. UTC | #1
On Fri, 2024-12-20 at 12:25 +0100, Stefan Herbrechtsmeier via lists.openembedded.org wrote:
> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> 
> Add unpack support for npm archives with unusual member ordering and
> disable warnings for unknown extended header keywords.
> 
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> ---
> 
>  lib/bb/fetch2/__init__.py | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
> index 4b7c01d6a..7d8f71b20 100644
> --- a/lib/bb/fetch2/__init__.py
> +++ b/lib/bb/fetch2/__init__.py
> @@ -1535,6 +1535,7 @@ class FetchMethod(object):
>  
>          if unpack:
>              tar_cmd = 'tar --extract --no-same-owner'
> +            tar_cmd += ' --delay-directory-restore --warning=no-unknown-keyword'
>              if 'striplevel' in urldata.parm:
>                  tar_cmd += ' --strip-components=%s' %  urldata.parm['striplevel']
>              if file.endswith('.tar'):

I think I'd be happier if this option was only added for the npm fetcher...

Cheers,

Richard
Stefan Herbrechtsmeier Jan. 2, 2025, 12:39 p.m. UTC | #2
Am 23.12.2024 um 12:56 schrieb Richard Purdie:
> On Fri, 2024-12-20 at 12:25 +0100, Stefan Herbrechtsmeier via lists.openembedded.org wrote:
>> From: Stefan Herbrechtsmeier<stefan.herbrechtsmeier@weidmueller.com>
>>
>> Add unpack support for npm archives with unusual member ordering and
>> disable warnings for unknown extended header keywords.
>>
>> Signed-off-by: Stefan Herbrechtsmeier<stefan.herbrechtsmeier@weidmueller.com>
>> ---
>>
>>   lib/bb/fetch2/__init__.py | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
>> index 4b7c01d6a..7d8f71b20 100644
>> --- a/lib/bb/fetch2/__init__.py
>> +++ b/lib/bb/fetch2/__init__.py
>> @@ -1535,6 +1535,7 @@ class FetchMethod(object):
>>   
>>           if unpack:
>>               tar_cmd = 'tar --extract --no-same-owner'
>> +            tar_cmd += ' --delay-directory-restore --warning=no-unknown-keyword'
>>               if 'striplevel' in urldata.parm:
>>                   tar_cmd += ' --strip-components=%s' %  urldata.parm['striplevel']
>>               if file.endswith('.tar'):
> I think I'd be happier if this option was only added for the npm fetcher...

Can I check the ud.type to add the args or should I move the args to an 
optional argument for the unpack method or an FetchMethod variable?
Richard Purdie Jan. 2, 2025, 1:59 p.m. UTC | #3
On Thu, 2025-01-02 at 13:39 +0100, Stefan Herbrechtsmeier wrote:
>  
> Am 23.12.2024 um 12:56 schrieb Richard Purdie:
>  
>  
> >  
> > On Fri, 2024-12-20 at 12:25 +0100, Stefan Herbrechtsmeier via
> > lists.openembedded.org wrote:
> >  
> > >  
> > > From: Stefan Herbrechtsmeier
> > > <stefan.herbrechtsmeier@weidmueller.com>
> > > 
> > > Add unpack support for npm archives with unusual member ordering
> > > and
> > > disable warnings for unknown extended header keywords.
> > > 
> > > Signed-off-by: Stefan Herbrechtsmeier
> > > <stefan.herbrechtsmeier@weidmueller.com>
> > > ---
> > > 
> > >  lib/bb/fetch2/__init__.py | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/lib/bb/fetch2/__init__.py
> > > b/lib/bb/fetch2/__init__.py
> > > index 4b7c01d6a..7d8f71b20 100644
> > > --- a/lib/bb/fetch2/__init__.py
> > > +++ b/lib/bb/fetch2/__init__.py
> > > @@ -1535,6 +1535,7 @@ class FetchMethod(object):
> > >  
> > >          if unpack:
> > >              tar_cmd = 'tar --extract --no-same-owner'
> > > +            tar_cmd += ' --delay-directory-restore --warning=no-
> > > unknown-keyword'
> > >              if 'striplevel' in urldata.parm:
> > >                  tar_cmd += ' --strip-components=%s' % 
> > > urldata.parm['striplevel']
> > >              if file.endswith('.tar'):
> > >  
> >  
> > I think I'd be happier if this option was only added for the npm
> > fetcher...
> 
> Can I check the ud.type to add the args or should I move the args to
> an optional argument for the unpack method or an FetchMethod
> variable?

I suspect a FetchMethod variable would be most in keeping with the rest
of the code. We've tried very hard not to fill the code with "if
ud.type" conditionals as we did that in fetch v1 and it became
unreadable and unmaintainable. This way it forces us to have some kind
of thought and methods/variables to document things.

Cheers,

Richard
diff mbox series

Patch

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index 4b7c01d6a..7d8f71b20 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1535,6 +1535,7 @@  class FetchMethod(object):
 
         if unpack:
             tar_cmd = 'tar --extract --no-same-owner'
+            tar_cmd += ' --delay-directory-restore --warning=no-unknown-keyword'
             if 'striplevel' in urldata.parm:
                 tar_cmd += ' --strip-components=%s' %  urldata.parm['striplevel']
             if file.endswith('.tar'):