summaryrefslogtreecommitdiff
path: root/bitbake
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-08 18:01:35 +0000
commit906285ff00d6ffd3fd7713af52250e7c6503edb7 (patch)
tree2ae9c99eb5772b965c8c690817407c0327f04e59 /bitbake
parent2f3a7348b7da637d2362e7ed50c96a248ff58fc5 (diff)
downloadopenembedded-core-906285ff00d6ffd3fd7713af52250e7c6503edb7.tar.gz
openembedded-core-906285ff00d6ffd3fd7713af52250e7c6503edb7.tar.bz2
openembedded-core-906285ff00d6ffd3fd7713af52250e7c6503edb7.zip
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 Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py62
1 files changed, 38 insertions, 24 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index ee3476bcc8..9a4acc2ede 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/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):