diff options
author | Mark Hatle <mark.hatle@windriver.com> | 2011-02-07 18:18:18 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-02-08 18:01:35 +0000 |
commit | 906285ff00d6ffd3fd7713af52250e7c6503edb7 (patch) | |
tree | 2ae9c99eb5772b965c8c690817407c0327f04e59 /bitbake/lib | |
parent | 2f3a7348b7da637d2362e7ed50c96a248ff58fc5 (diff) | |
download | poky-906285ff00d6ffd3fd7713af52250e7c6503edb7.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
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 62 |
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): | |||
628 | 628 | ||
629 | def unpack(self, urldata, rootdir, data): | 629 | def unpack(self, urldata, rootdir, data): |
630 | import subprocess | 630 | import subprocess |
631 | iterate = False | ||
631 | file = urldata.localpath | 632 | file = urldata.localpath |
632 | dots = file.split(".") | 633 | dots = file.split(".") |
633 | if dots[-1] in ['gz', 'bz2', 'Z']: | 634 | if dots[-1] in ['gz', 'bz2', 'Z']: |
@@ -635,6 +636,7 @@ class FetchMethod(object): | |||
635 | else: | 636 | else: |
636 | efile = file | 637 | efile = file |
637 | cmd = None | 638 | cmd = None |
639 | |||
638 | if file.endswith('.tar'): | 640 | if file.endswith('.tar'): |
639 | cmd = 'tar x --no-same-owner -f %s' % file | 641 | cmd = 'tar x --no-same-owner -f %s' % file |
640 | elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'): | 642 | elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'): |
@@ -654,36 +656,43 @@ class FetchMethod(object): | |||
654 | if 'dos' in urldata.parm: | 656 | if 'dos' in urldata.parm: |
655 | cmd = '%s -a' % cmd | 657 | cmd = '%s -a' % cmd |
656 | cmd = "%s '%s'" % (cmd, file) | 658 | cmd = "%s '%s'" % (cmd, file) |
657 | elif os.path.isdir(file): | 659 | elif file.endswith('.src.rpm') or file.endswith('.srpm'): |
658 | filesdir = os.path.realpath(bb.data.getVar("FILESDIR", data, True)) | 660 | if 'unpack' in urldata.parm: |
659 | destdir = "." | 661 | unpack_file = ("%s" % urldata.parm['unpack']) |
660 | if file[0:len(filesdir)] == filesdir: | 662 | cmd = 'rpm2cpio.sh %s | cpio -i %s' % (file, unpack_file) |
661 | destdir = file[len(filesdir):file.rfind('/')] | 663 | iterate = True |
662 | destdir = destdir.strip('/') | 664 | iterate_file = unpack_file |
663 | if len(destdir) < 1: | 665 | else: |
664 | destdir = "." | 666 | cmd = 'rpm2cpio.sh %s | cpio -i' % (file) |
665 | elif not os.access("%s/%s" % (rootdir, destdir), os.F_OK): | ||
666 | os.makedirs("%s/%s" % (rootdir, destdir)) | ||
667 | cmd = 'cp -pPR %s %s/%s/' % (file, rootdir, destdir) | ||
668 | else: | 667 | else: |
669 | if not 'patch' in urldata.parm: | 668 | # If file == dest, then avoid any copies, as we already put the file into dest! |
670 | # The "destdir" handling was specifically done for FILESPATH | 669 | dest = os.path.join(rootdir, os.path.basename(file)) |
671 | # items. So, only do so for file:// entries. | 670 | if (file != dest) and not (os.path.exists(dest) and os.path.samefile(file, dest)): |
672 | if urldata.type == "file" and urldata.path.find("/") != -1: | 671 | if os.path.isdir(file): |
673 | destdir = urldata.path.rsplit("/", 1)[0] | 672 | filesdir = os.path.realpath(bb.data.getVar("FILESDIR", data, True)) |
674 | else: | ||
675 | destdir = "." | 673 | destdir = "." |
676 | bb.mkdirhier("%s/%s" % (rootdir, destdir)) | 674 | if file[0:len(filesdir)] == filesdir: |
677 | cmd = 'cp %s %s/%s/' % (file, rootdir, destdir) | 675 | destdir = file[len(filesdir):file.rfind('/')] |
676 | destdir = destdir.strip('/') | ||
677 | if len(destdir) < 1: | ||
678 | destdir = "." | ||
679 | elif not os.access("%s/%s" % (rootdir, destdir), os.F_OK): | ||
680 | os.makedirs("%s/%s" % (rootdir, destdir)) | ||
681 | cmd = 'cp -pPR %s %s/%s/' % (file, rootdir, destdir) | ||
682 | else: | ||
683 | if not 'patch' in urldata.parm: | ||
684 | # The "destdir" handling was specifically done for FILESPATH | ||
685 | # items. So, only do so for file:// entries. | ||
686 | if urldata.type == "file" and urldata.path.find("/") != -1: | ||
687 | destdir = urldata.path.rsplit("/", 1)[0] | ||
688 | else: | ||
689 | destdir = "." | ||
690 | bb.mkdirhier("%s/%s" % (rootdir, destdir)) | ||
691 | cmd = 'cp %s %s/%s/' % (file, rootdir, destdir) | ||
678 | 692 | ||
679 | if not cmd: | 693 | if not cmd: |
680 | return | 694 | return |
681 | 695 | ||
682 | dest = os.path.join(rootdir, os.path.basename(file)) | ||
683 | if os.path.exists(dest): | ||
684 | if os.path.samefile(file, dest): | ||
685 | return | ||
686 | |||
687 | # Change to subdir before executing command | 696 | # Change to subdir before executing command |
688 | save_cwd = os.getcwd(); | 697 | save_cwd = os.getcwd(); |
689 | os.chdir(rootdir) | 698 | os.chdir(rootdir) |
@@ -701,6 +710,11 @@ class FetchMethod(object): | |||
701 | if ret != 0: | 710 | if ret != 0: |
702 | raise UnpackError("Unpack command %s failed with return value %s" % (cmd, ret), urldata.url) | 711 | raise UnpackError("Unpack command %s failed with return value %s" % (cmd, ret), urldata.url) |
703 | 712 | ||
713 | if iterate is True: | ||
714 | iterate_urldata = urldata | ||
715 | iterate_urldata.localpath = "%s/%s" % (rootdir, iterate_file) | ||
716 | self.unpack(urldata, rootdir, data) | ||
717 | |||
704 | return | 718 | return |
705 | 719 | ||
706 | def try_premirror(self, url, urldata, d): | 720 | def try_premirror(self, url, urldata, d): |