aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Oberritter <obi@opendreambox.org>2011-01-06 12:48:29 +0000
committerKhem Raj <raj.khem@gmail.com>2011-01-15 16:05:16 -0800
commit2bdfe8519eda8067845019a699acdf19a21ba380 (patch)
tree6bc81c572458b8e0ff31eebf3b4aeca4a38a82b4 /lib
parent54573959d3f6479ac6e26a9a4a4d2d258082a8df (diff)
downloadopenembedded-2bdfe8519eda8067845019a699acdf19a21ba380.tar.gz
unpack.py: add SRC_URI parameter unpack=<bool> (default: true)
* This allows to download compressed files without extracting them * Use case: gcj requires ecj.jar, which must be downloaded separately and put into the gcc source directory before configure gets executed. Signed-off-by: Andreas Oberritter <obi@opendreambox.org> CC: Chris Larson <chris_larson@mentor.com> Reviewed-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/oe/unpack.py81
1 files changed, 48 insertions, 33 deletions
diff --git a/lib/oe/unpack.py b/lib/oe/unpack.py
index e4fe5d8363..8e8bf36408 100644
--- a/lib/oe/unpack.py
+++ b/lib/oe/unpack.py
@@ -47,47 +47,62 @@ def subprocess_setup():
# non-Python subprocesses expect.
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-def unpack_file(file, destdir, dos=False, env=None):
+def unpack_file(file, destdir, parameters, env=None):
import subprocess, shutil
+ try:
+ dos = to_boolean(parameters.get("dos"), False)
+ except ValueError, exc:
+ bb.fatal("Invalid value for 'dos' parameter for %s: %s" %
+ (filename, parameters.get("dos")))
+
+ try:
+ unpack = to_boolean(parameters.get("unpack"), True)
+ except ValueError, exc:
+ bb.fatal("Invalid value for 'unpack' parameter for %s: %s" %
+ (filename, parameters.get("unpack")))
+
dest = os.path.join(destdir, os.path.basename(file))
if os.path.exists(dest):
if os.path.samefile(file, dest):
return True
cmd = None
- if 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'):
- cmd = 'tar xz --no-same-owner -f %s' % 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
- elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
- root, ext = os.path.splitext(file)
- cmd = 'gzip -dc %s > %s' % (file, os.path.basename(root))
- elif file.endswith('.bz2'):
- root, ext = os.path.splitext(file)
- cmd = 'bzip2 -dc %s > %s' % (file, os.path.basename(root))
- elif file.endswith('.tar.xz'):
- cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file
- elif file.endswith('.xz'):
- root, ext = os.path.splitext(file)
- cmd = 'xz -dc %s > %s' % (file, os.path.basename(root))
- elif file.endswith('.tar.lz'):
- cmd = 'lzip -dc %s | tar x --no-same-owner -f -' % file
- elif file.endswith('.lz'):
- root, ext = os.path.splitext(file)
- cmd = 'lzip -dc %s > %s' % (file, os.path.basename(root))
- elif file.endswith('.zip') or file.endswith('.jar'):
- cmd = 'unzip -q -o'
- if dos:
- cmd = '%s -a' % cmd
- cmd = "%s '%s'" % (cmd, file)
- elif os.path.isdir(file):
- shutil.rmtree(dest, True)
- shutil.copytree(file, dest, True)
- else:
- shutil.copy2(file, dest)
+ if unpack:
+ if 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'):
+ cmd = 'tar xz --no-same-owner -f %s' % 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
+ elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
+ root, ext = os.path.splitext(file)
+ cmd = 'gzip -dc %s > %s' % (file, os.path.basename(root))
+ elif file.endswith('.bz2'):
+ root, ext = os.path.splitext(file)
+ cmd = 'bzip2 -dc %s > %s' % (file, os.path.basename(root))
+ elif file.endswith('.tar.xz'):
+ cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file
+ elif file.endswith('.xz'):
+ root, ext = os.path.splitext(file)
+ cmd = 'xz -dc %s > %s' % (file, os.path.basename(root))
+ elif file.endswith('.tar.lz'):
+ cmd = 'lzip -dc %s | tar x --no-same-owner -f -' % file
+ elif file.endswith('.lz'):
+ root, ext = os.path.splitext(file)
+ cmd = 'lzip -dc %s > %s' % (file, os.path.basename(root))
+ elif file.endswith('.zip') or file.endswith('.jar'):
+ cmd = 'unzip -q -o'
+ if dos:
+ cmd = '%s -a' % cmd
+ cmd = "%s '%s'" % (cmd, file)
+
+ if not unpack or not cmd:
+ if os.path.isdir(file):
+ shutil.rmtree(dest, True)
+ shutil.copytree(file, dest, True)
+ else:
+ shutil.copy2(file, dest)
if not cmd:
return