summaryrefslogtreecommitdiffstats
path: root/lib/bb/fetch2
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2011-02-07 18:18:18 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-10 23:37:32 +0000
commit3372d84fa90ba51e8b2cd4557ee5ce501d0c6bf7 (patch)
tree136338daad9a0299745f0ea7c41f61752693996b /lib/bb/fetch2
parent43b9d70bbad02495af54014a25611f8e0d78d6bf (diff)
downloadbitbake-3372d84fa90ba51e8b2cd4557ee5ce501d0c6bf7.tar.gz
fetch2: Add SRPM knowledge
Enable the fetcher to be able to unpack and SRPM. By default the system will unpack the contents of the SRPM into the WORKDIR. A new syntax "unpack=file" was developed for the SRC_URI, to allow for a recipe to extract a specific file within an SRPM. An unpack operation will then be executed on the extracted file. In order to apply extracted patches (or unpack files not specified with unpack), you must specify the path using WORKDIR, i.e.: file://${WORKDIR}/mypatch.patch (From Poky rev: 906285ff00d6ffd3fd7713af52250e7c6503edb7) Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/fetch2')
-rw-r--r--lib/bb/fetch2/__init__.py62
1 files changed, 38 insertions, 24 deletions
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index ee3476bcc..9a4acc2ed 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -628,6 +628,7 @@ class FetchMethod(object):
def unpack(self, urldata, rootdir, data):
import subprocess
+ iterate = False
file = urldata.localpath
dots = file.split(".")
if dots[-1] in ['gz', 'bz2', 'Z']:
@@ -635,6 +636,7 @@ class FetchMethod(object):
else:
efile = file
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'):
@@ -654,36 +656,43 @@ class FetchMethod(object):
if 'dos' in urldata.parm:
cmd = '%s -a' % cmd
cmd = "%s '%s'" % (cmd, file)
- elif os.path.isdir(file):
- filesdir = os.path.realpath(bb.data.getVar("FILESDIR", data, True))
- destdir = "."
- if file[0:len(filesdir)] == filesdir:
- destdir = file[len(filesdir):file.rfind('/')]
- destdir = destdir.strip('/')
- if len(destdir) < 1:
- destdir = "."
- elif not os.access("%s/%s" % (rootdir, destdir), os.F_OK):
- os.makedirs("%s/%s" % (rootdir, destdir))
- cmd = 'cp -pPR %s %s/%s/' % (file, rootdir, destdir)
+ elif file.endswith('.src.rpm') or file.endswith('.srpm'):
+ if 'unpack' in urldata.parm:
+ unpack_file = ("%s" % urldata.parm['unpack'])
+ cmd = 'rpm2cpio.sh %s | cpio -i %s' % (file, unpack_file)
+ iterate = True
+ iterate_file = unpack_file
+ else:
+ cmd = 'rpm2cpio.sh %s | cpio -i' % (file)
else:
- if not 'patch' in urldata.parm:
- # The "destdir" handling was specifically done for FILESPATH
- # items. So, only do so for file:// entries.
- if urldata.type == "file" and urldata.path.find("/") != -1:
- destdir = urldata.path.rsplit("/", 1)[0]
- else:
+ # If file == dest, then avoid any copies, as we already put the file into dest!
+ 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 os.path.isdir(file):
+ filesdir = os.path.realpath(bb.data.getVar("FILESDIR", data, True))
destdir = "."
- bb.mkdirhier("%s/%s" % (rootdir, destdir))
- cmd = 'cp %s %s/%s/' % (file, rootdir, destdir)
+ if file[0:len(filesdir)] == filesdir:
+ destdir = file[len(filesdir):file.rfind('/')]
+ destdir = destdir.strip('/')
+ if len(destdir) < 1:
+ destdir = "."
+ elif not os.access("%s/%s" % (rootdir, destdir), os.F_OK):
+ os.makedirs("%s/%s" % (rootdir, destdir))
+ cmd = 'cp -pPR %s %s/%s/' % (file, rootdir, destdir)
+ else:
+ if not 'patch' in urldata.parm:
+ # The "destdir" handling was specifically done for FILESPATH
+ # items. So, only do so for file:// entries.
+ if urldata.type == "file" and urldata.path.find("/") != -1:
+ destdir = urldata.path.rsplit("/", 1)[0]
+ else:
+ destdir = "."
+ bb.mkdirhier("%s/%s" % (rootdir, destdir))
+ cmd = 'cp %s %s/%s/' % (file, rootdir, destdir)
if not cmd:
return
- dest = os.path.join(rootdir, os.path.basename(file))
- if os.path.exists(dest):
- if os.path.samefile(file, dest):
- return
-
# Change to subdir before executing command
save_cwd = os.getcwd();
os.chdir(rootdir)
@@ -701,6 +710,11 @@ class FetchMethod(object):
if ret != 0:
raise UnpackError("Unpack command %s failed with return value %s" % (cmd, ret), urldata.url)
+ if iterate is True:
+ iterate_urldata = urldata
+ iterate_urldata.localpath = "%s/%s" % (rootdir, iterate_file)
+ self.unpack(urldata, rootdir, data)
+
return
def try_premirror(self, url, urldata, d):