[oe] Adding a nounpack url parameter to base.bbclass

Roman I Khimov roman at khimov.ru
Fri Apr 30 18:06:08 UTC 2010


В сообщении от Пятница 30 апреля 2010 21:28:40 автор Ash Charles написал:
> I added a minor change to base.bbclass to accept a 'nounpack=1'
> parameter to stop bitbake from unpacking a file that has a bz2, tar...
> extension; this is useful if you actually want to include such an
> archive file in a package.  I'm not familiar with the policies for
> submitting patches however I thought other people might find it useful
> so I've included it below:
> ==================================
> diff --git a/classes/base.bbclass b/classes/base.bbclass
> index 4d5d73d..387a066 100644
> --- a/classes/base.bbclass
> +++ b/classes/base.bbclass
> @@ -171,21 +171,29 @@ def oe_unpack_file(file, data, url = None):
>         else:
>                 efile = file
>         cmd = None
> -       if file.endswith('.tar'):
> +
> +        # allow a 'nounpack=1' url parameter to prevent unpacking of
>  archives +        unpack = True
> +        (type, host, path, user, pswd, parm) = bb.decodeurl(url)
> +        if 'nounpack' in parm:
> +                if parm['nounpack']:
> +                        unpack = False
> +
> +       if unpack and file.endswith('.tar'):
>                 cmd = 'tar x --no-same-owner -f %s' % file
> -       elif file.endswith('.tgz') or file.endswith('.tar.gz') or
> file.endswith('.tar.Z'):
> +       elif unpack and (file.endswith('.tgz') or
> file.endswith('.tar.gz') or file.endswith('.tar.Z')):
>                 cmd = 'tar xz --no-same-owner -f %s' % file
> -       elif file.endswith('.tbz') or file.endswith('.tbz2') or
> file.endswith('.tar.bz2'):
> +       elif unpack and (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'): +       elif unpack and (file.endswith('.gz') or
>  file.endswith('.Z') or file.endswith('.z')):
>                 cmd = 'gzip -dc %s > %s' % (file, efile)
> -       elif file.endswith('.bz2'):
> +       elif unpack and file.endswith('.bz2'):
>                 cmd = 'bzip2 -dc %s > %s' % (file, efile)
> -       elif file.endswith('.tar.xz'):
> +       elif unpack and file.endswith('.tar.xz'):
>                 cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file
> -       elif file.endswith('.xz'):
> +       elif unpack and file.endswith('.xz'):
>                 cmd = 'xz -dc %s > %s' % (file, efile)
> -       elif file.endswith('.zip') or file.endswith('.jar'):
> +       elif unpack and (file.endswith('.zip') or file.endswith('.jar')):
>                 cmd = 'unzip -q -o'
>                 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
>                 if 'dos' in parm:
> ==================================

Wouldn't it be easier to do something like:

+        if 'nounpack' not in parm:
+            if file.endswith('.tar'):
....
+            elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
....

? The diff would be a bit bigger, but the end result is cleaner IMO.

-- 
 http://roman.khimov.ru
mailto: roman at khimov.ru
gpg --keyserver hkp://subkeys.pgp.net --recv-keys 0xE5E055C3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.openembedded.org/pipermail/openembedded-devel/attachments/20100430/d5ca55bb/attachment-0002.sig>


More information about the Openembedded-devel mailing list