Hi, I discussed with pb on irc, how it would be the best way to unpack two tar archivs into the same directory. He pointed me to the tar strip-components options and attached is the outcome. Because base.bbclass is touched it is open for discussion here.
Bye Henning
>From 0688f07fe2e8b1926ae1dc34a03d6b5845871f74 Mon Sep 17 00:00:00 2001 From: Henning Heinold <[email protected]> Date: Fri, 14 May 2010 21:16:30 +0200 Subject: [PATCH] base.bbclass: introduce strip-components option for tar and set tar options in a sane way * you can use now the following in your SRC_URI to munge diffrent tar archivs into the same directory http://foo.tar.bz2;strip_components=1;subdir=foo \ http://foo2.tar.bz2;strip_components=1;subdir=foo --- classes/base.bbclass | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/classes/base.bbclass b/classes/base.bbclass index 3c854c6..373f5f2 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -171,18 +171,24 @@ def oe_unpack_file(file, data, url = None): else: efile = file cmd = None + tar_options = 'x --no-same-owner' + parm = bb.decodeurl(url)[5] + if 'strip_components' in parm: + bb.note("using strip_componetes") + tar_options = tar_options + ' --strip-components=%s' % parm['strip_components'] + tar_options = tar_options + ' -f' if file.endswith('.tar'): - cmd = 'tar x --no-same-owner -f %s' % file + cmd = 'tar %s %s' % (tar_options, file) elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'): - cmd = 'tar xz --no-same-owner -f %s' % file + cmd = 'tar z%s %s' % (tar_options, file) elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'): - cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file + cmd = 'bzip2 -dc %s | tar %s -' % (file, tar_options) elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'): cmd = 'gzip -dc %s > %s' % (file, efile) elif file.endswith('.bz2'): cmd = 'bzip2 -dc %s > %s' % (file, efile) elif file.endswith('.tar.xz'): - cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file + cmd = 'xz -dc %s | tar %s -' % (file, tar_options) elif file.endswith('.xz'): cmd = 'xz -dc %s > %s' % (file, efile) elif file.endswith('.zip') or file.endswith('.jar'): @@ -227,7 +233,6 @@ def oe_unpack_file(file, data, url = None): # Change to subdir before executing command save_cwd = os.getcwd(); - parm = bb.decodeurl(url)[5] if 'subdir' in parm: newdir = ("%s/%s" % (os.getcwd(), parm['subdir'])) bb.mkdirhier(newdir) -- 1.7.1
_______________________________________________ Openembedded-devel mailing list [email protected] http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
