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

Ash Charles ashcharles at gmail.com
Fri Apr 30 17:28:40 UTC 2010


Hi,

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:
==================================

This is a learning experience for me so comments on how to submit
patches properly are very welcome :).

-Ash
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nounpack.patch
Type: text/x-patch
Size: 1906 bytes
Desc: not available
URL: <http://lists.openembedded.org/pipermail/openembedded-devel/attachments/20100430/2ea29554/attachment-0002.bin>


More information about the Openembedded-devel mailing list