* Using tar option strip-components in do_unpack
@ 2010-05-14 21:23 Henning Heinold
2010-05-15 7:37 ` Koen Kooi
2010-05-15 8:24 ` Phil Blundell
0 siblings, 2 replies; 3+ messages in thread
From: Henning Heinold @ 2010-05-14 21:23 UTC (permalink / raw)
To: openembedded-devel
[-- Attachment #1: Type: text/plain, Size: 277 bytes --]
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
[-- Attachment #2: 0001-base.bbclass-introduce-strip-components-option-for-t.patch --]
[-- Type: text/x-diff, Size: 2419 bytes --]
From 0688f07fe2e8b1926ae1dc34a03d6b5845871f74 Mon Sep 17 00:00:00 2001
From: Henning Heinold <heinold@inf.fu-berlin.de>
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: Using tar option strip-components in do_unpack
2010-05-14 21:23 Using tar option strip-components in do_unpack Henning Heinold
@ 2010-05-15 7:37 ` Koen Kooi
2010-05-15 8:24 ` Phil Blundell
1 sibling, 0 replies; 3+ messages in thread
From: Koen Kooi @ 2010-05-15 7:37 UTC (permalink / raw)
To: openembedded-devel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 14-05-10 23:23, Henning Heinold wrote:
> 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.
Please don't forget to update docs/usermanual when adding new features.
regards,
Koen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iD8DBQFL7k88MkyGM64RGpERAoP/AJ0fMfFBe9tU9EVo0OWwPIgX2O/28ACeMRNC
YG2B3XCuKE7FQeHnAEBKZ64=
=bF/F
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Using tar option strip-components in do_unpack
2010-05-14 21:23 Using tar option strip-components in do_unpack Henning Heinold
2010-05-15 7:37 ` Koen Kooi
@ 2010-05-15 8:24 ` Phil Blundell
1 sibling, 0 replies; 3+ messages in thread
From: Phil Blundell @ 2010-05-15 8:24 UTC (permalink / raw)
To: openembedded-devel
On Fri, 2010-05-14 at 23:23 +0200, Henning Heinold wrote:
> 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.
> + 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)
I think it would be a good idea to try to keep "-f" and the filename
together, rather than splitting them across two strings. It isn't
completely obvious to someone looking at this code that "-f" needs to be
the last thing in tar_options and that the filename needs to follow it
immediately.
So, I suggest not adding -f to tar_options and instead doing something
like:
cmd = 'tar %s -f %s' % (tar_options, file)
Apart from that I think your patch is good. Thanks for looking at this.
p.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-15 8:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-14 21:23 Using tar option strip-components in do_unpack Henning Heinold
2010-05-15 7:37 ` Koen Kooi
2010-05-15 8:24 ` Phil Blundell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.