fetch2: unpack revision
Revise the unpack function to have a way to disable the unpack. This is based on the work from "Andreas Oberritter <obi@opendreambox.org>", see http://cgit.openembedded.net/cgit.cgi/openembedded/commit/?id=2bdfe8519eda8067845019a699acdf19a21ba380 In addition, the to_boolean function comes from the work of "Chris Larson <chris_larson@mentor.com>", see http://cgit.openembedded.net/cgit.cgi/openembedded/commit/?id=900cc29b603691eb3a077cb660545ead3715ed54 Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
This commit is contained in:
parent
e56f63a284
commit
3faa635fd4
|
@ -658,6 +658,13 @@ class FetchMethod(object):
|
||||||
import subprocess
|
import subprocess
|
||||||
iterate = False
|
iterate = False
|
||||||
file = urldata.localpath
|
file = urldata.localpath
|
||||||
|
|
||||||
|
try:
|
||||||
|
unpack = bb.utils.to_boolean(urldata.parm.get('unpack'), True)
|
||||||
|
except ValueError, exc:
|
||||||
|
bb.fatal("Invalid value for 'unpack' parameter for %s: %s" %
|
||||||
|
(file, urldata.parm.get('unpack')))
|
||||||
|
|
||||||
dots = file.split(".")
|
dots = file.split(".")
|
||||||
if dots[-1] in ['gz', 'bz2', 'Z']:
|
if dots[-1] in ['gz', 'bz2', 'Z']:
|
||||||
efile = os.path.join(bb.data.getVar('WORKDIR', data, True),os.path.basename('.'.join(dots[0:-1])))
|
efile = os.path.join(bb.data.getVar('WORKDIR', data, True),os.path.basename('.'.join(dots[0:-1])))
|
||||||
|
@ -665,34 +672,41 @@ class FetchMethod(object):
|
||||||
efile = file
|
efile = file
|
||||||
cmd = None
|
cmd = None
|
||||||
|
|
||||||
if file.endswith('.tar'):
|
if unpack:
|
||||||
cmd = 'tar x --no-same-owner -f %s' % file
|
if file.endswith('.tar'):
|
||||||
elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
|
cmd = 'tar x --no-same-owner -f %s' % file
|
||||||
cmd = 'tar xz --no-same-owner -f %s' % file
|
elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
|
||||||
elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'):
|
cmd = 'tar xz --no-same-owner -f %s' % file
|
||||||
cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
|
elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'):
|
||||||
elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
|
cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
|
||||||
cmd = 'gzip -dc %s > %s' % (file, efile)
|
elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
|
||||||
elif file.endswith('.bz2'):
|
cmd = 'gzip -dc %s > %s' % (file, efile)
|
||||||
cmd = 'bzip2 -dc %s > %s' % (file, efile)
|
elif file.endswith('.bz2'):
|
||||||
elif file.endswith('.tar.xz'):
|
cmd = 'bzip2 -dc %s > %s' % (file, efile)
|
||||||
cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file
|
elif file.endswith('.tar.xz'):
|
||||||
elif file.endswith('.xz'):
|
cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file
|
||||||
cmd = 'xz -dc %s > %s' % (file, efile)
|
elif file.endswith('.xz'):
|
||||||
elif file.endswith('.zip') or file.endswith('.jar'):
|
cmd = 'xz -dc %s > %s' % (file, efile)
|
||||||
cmd = 'unzip -q -o'
|
elif file.endswith('.zip') or file.endswith('.jar'):
|
||||||
if 'dos' in urldata.parm:
|
try:
|
||||||
cmd = '%s -a' % cmd
|
dos = bb.utils.to_boolean(urldata.parm.get('dos'), False)
|
||||||
cmd = "%s '%s'" % (cmd, file)
|
except ValueError, exc:
|
||||||
elif file.endswith('.src.rpm') or file.endswith('.srpm'):
|
bb.fatal("Invalid value for 'dos' parameter for %s: %s" %
|
||||||
if 'unpack' in urldata.parm:
|
(file, urldata.parm.get('dos')))
|
||||||
unpack_file = ("%s" % urldata.parm['unpack'])
|
cmd = 'unzip -q -o'
|
||||||
cmd = 'rpm2cpio.sh %s | cpio -i %s' % (file, unpack_file)
|
if dos:
|
||||||
iterate = True
|
cmd = '%s -a' % cmd
|
||||||
iterate_file = unpack_file
|
cmd = "%s '%s'" % (cmd, file)
|
||||||
else:
|
elif file.endswith('.src.rpm') or file.endswith('.srpm'):
|
||||||
cmd = 'rpm2cpio.sh %s | cpio -i' % (file)
|
if 'extract' in urldata.parm:
|
||||||
else:
|
unpack_file = urldata.parm.get('extract')
|
||||||
|
cmd = 'rpm2cpio.sh %s | cpio -i %s' % (file, unpack_file)
|
||||||
|
iterate = True
|
||||||
|
iterate_file = unpack_file
|
||||||
|
else:
|
||||||
|
cmd = 'rpm2cpio.sh %s | cpio -i' % (file)
|
||||||
|
|
||||||
|
if not unpack or not cmd:
|
||||||
# If file == dest, then avoid any copies, as we already put the file into dest!
|
# If file == dest, then avoid any copies, as we already put the file into dest!
|
||||||
dest = os.path.join(rootdir, os.path.basename(file))
|
dest = os.path.join(rootdir, os.path.basename(file))
|
||||||
if (file != dest) and not (os.path.exists(dest) and os.path.samefile(file, dest)):
|
if (file != dest) and not (os.path.exists(dest) and os.path.samefile(file, dest)):
|
||||||
|
@ -706,17 +720,17 @@ class FetchMethod(object):
|
||||||
destdir = "."
|
destdir = "."
|
||||||
elif not os.access("%s/%s" % (rootdir, destdir), os.F_OK):
|
elif not os.access("%s/%s" % (rootdir, destdir), os.F_OK):
|
||||||
os.makedirs("%s/%s" % (rootdir, destdir))
|
os.makedirs("%s/%s" % (rootdir, destdir))
|
||||||
cmd = 'cp -pPR %s %s/%s/' % (file, rootdir, destdir)
|
#cmd = 'cp -pPR %s %s/%s/' % (file, rootdir, destdir)
|
||||||
|
cmd = 'tar -cf - -C "%d" -ps . | tar -xf - -C "%s/%s/"' % (file, rootdir, destdir)
|
||||||
else:
|
else:
|
||||||
if not 'patch' in urldata.parm:
|
# The "destdir" handling was specifically done for FILESPATH
|
||||||
# The "destdir" handling was specifically done for FILESPATH
|
# items. So, only do so for file:// entries.
|
||||||
# items. So, only do so for file:// entries.
|
if urldata.type == "file" and urldata.path.find("/") != -1:
|
||||||
if urldata.type == "file" and urldata.path.find("/") != -1:
|
destdir = urldata.path.rsplit("/", 1)[0]
|
||||||
destdir = urldata.path.rsplit("/", 1)[0]
|
else:
|
||||||
else:
|
destdir = "."
|
||||||
destdir = "."
|
bb.mkdirhier("%s/%s" % (rootdir, destdir))
|
||||||
bb.mkdirhier("%s/%s" % (rootdir, destdir))
|
cmd = 'cp %s %s/%s/' % (file, rootdir, destdir)
|
||||||
cmd = 'cp %s %s/%s/' % (file, rootdir, destdir)
|
|
||||||
|
|
||||||
if not cmd:
|
if not cmd:
|
||||||
return
|
return
|
||||||
|
@ -725,7 +739,7 @@ class FetchMethod(object):
|
||||||
save_cwd = os.getcwd();
|
save_cwd = os.getcwd();
|
||||||
os.chdir(rootdir)
|
os.chdir(rootdir)
|
||||||
if 'subdir' in urldata.parm:
|
if 'subdir' in urldata.parm:
|
||||||
newdir = ("%s/%s" % (rootdir, urldata.parm['subdir']))
|
newdir = ("%s/%s" % (rootdir, urldata.parm.get('subdir')))
|
||||||
bb.mkdirhier(newdir)
|
bb.mkdirhier(newdir)
|
||||||
os.chdir(newdir)
|
os.chdir(newdir)
|
||||||
|
|
||||||
|
|
|
@ -831,3 +831,15 @@ def init_logger(logger, verbose, debug, debug_domains):
|
||||||
|
|
||||||
if debug_domains:
|
if debug_domains:
|
||||||
bb.msg.set_debug_domains(debug_domains)
|
bb.msg.set_debug_domains(debug_domains)
|
||||||
|
|
||||||
|
def to_boolean(string, default=None):
|
||||||
|
if not string:
|
||||||
|
return default
|
||||||
|
|
||||||
|
normalized = string.lower()
|
||||||
|
if normalized in ("y", "yes", "1", "true"):
|
||||||
|
return True
|
||||||
|
elif normalized in ("n", "no", "0", "false"):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
raise ValueError("Invalid value for to_boolean: %s" % string)
|
||||||
|
|
|
@ -47,7 +47,7 @@ PR = "r11"
|
||||||
|
|
||||||
# rpm2cpio is a shell script, which is part of the rpm src.rpm. It is needed
|
# rpm2cpio is a shell script, which is part of the rpm src.rpm. It is needed
|
||||||
# in order to extract the distribution SRPM into a format we can extract...
|
# in order to extract the distribution SRPM into a format we can extract...
|
||||||
SRC_URI = "http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.0-0.20101229.src.rpm;unpack=rpm-5.4.0.tar.gz \
|
SRC_URI = "http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.0-0.20101229.src.rpm;extract=rpm-5.4.0.tar.gz \
|
||||||
file://perfile_rpmdeps.sh \
|
file://perfile_rpmdeps.sh \
|
||||||
file://rpm-autogen.patch \
|
file://rpm-autogen.patch \
|
||||||
file://rpm-libsql-fix.patch \
|
file://rpm-libsql-fix.patch \
|
||||||
|
|
Loading…
Reference in New Issue