diff options
| -rw-r--r-- | meta/classes/patch.bbclass | 105 | ||||
| -rw-r--r-- | meta/lib/oe/patch.py | 107 | ||||
| -rw-r--r-- | meta/lib/oe/recipeutils.py | 12 |
3 files changed, 116 insertions, 108 deletions
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass index 7ebae282b6..0e5b602462 100644 --- a/meta/classes/patch.bbclass +++ b/meta/classes/patch.bbclass | |||
| @@ -80,110 +80,13 @@ python patch_task_postfunc() { | |||
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | def src_patches(d, all=False, expand=True): | 82 | def src_patches(d, all=False, expand=True): |
| 83 | workdir = d.getVar('WORKDIR', True) | 83 | import oe.patch |
| 84 | fetch = bb.fetch2.Fetch([], d) | 84 | return oe.patch.src_patches(d, all, expand) |
| 85 | patches = [] | ||
| 86 | sources = [] | ||
| 87 | for url in fetch.urls: | ||
| 88 | local = patch_path(url, fetch, workdir, expand) | ||
| 89 | if not local: | ||
| 90 | if all: | ||
| 91 | local = fetch.localpath(url) | ||
| 92 | sources.append(local) | ||
| 93 | continue | ||
| 94 | |||
| 95 | urldata = fetch.ud[url] | ||
| 96 | parm = urldata.parm | ||
| 97 | patchname = parm.get('pname') or os.path.basename(local) | ||
| 98 | |||
| 99 | apply, reason = should_apply(parm, d) | ||
| 100 | if not apply: | ||
| 101 | if reason: | ||
| 102 | bb.note("Patch %s %s" % (patchname, reason)) | ||
| 103 | continue | ||
| 104 | |||
| 105 | patchparm = {'patchname': patchname} | ||
| 106 | if "striplevel" in parm: | ||
| 107 | striplevel = parm["striplevel"] | ||
| 108 | elif "pnum" in parm: | ||
| 109 | #bb.msg.warn(None, "Deprecated usage of 'pnum' url parameter in '%s', please use 'striplevel'" % url) | ||
| 110 | striplevel = parm["pnum"] | ||
| 111 | else: | ||
| 112 | striplevel = '1' | ||
| 113 | patchparm['striplevel'] = striplevel | ||
| 114 | |||
| 115 | patchdir = parm.get('patchdir') | ||
| 116 | if patchdir: | ||
| 117 | patchparm['patchdir'] = patchdir | ||
| 118 | |||
| 119 | localurl = bb.fetch.encodeurl(('file', '', local, '', '', patchparm)) | ||
| 120 | patches.append(localurl) | ||
| 121 | |||
| 122 | if all: | ||
| 123 | return sources | ||
| 124 | |||
| 125 | return patches | ||
| 126 | |||
| 127 | def patch_path(url, fetch, workdir, expand=True): | ||
| 128 | """Return the local path of a patch, or None if this isn't a patch""" | ||
| 129 | |||
| 130 | local = fetch.localpath(url) | ||
| 131 | base, ext = os.path.splitext(os.path.basename(local)) | ||
| 132 | if ext in ('.gz', '.bz2', '.Z'): | ||
| 133 | if expand: | ||
| 134 | local = os.path.join(workdir, base) | ||
| 135 | ext = os.path.splitext(base)[1] | ||
| 136 | |||
| 137 | urldata = fetch.ud[url] | ||
| 138 | if "apply" in urldata.parm: | ||
| 139 | apply = oe.types.boolean(urldata.parm["apply"]) | ||
| 140 | if not apply: | ||
| 141 | return | ||
| 142 | elif ext not in (".diff", ".patch"): | ||
| 143 | return | ||
| 144 | |||
| 145 | return local | ||
| 146 | 85 | ||
| 147 | def should_apply(parm, d): | 86 | def should_apply(parm, d): |
| 148 | """Determine if we should apply the given patch""" | 87 | """Determine if we should apply the given patch""" |
| 149 | 88 | import oe.patch | |
| 150 | if "mindate" in parm or "maxdate" in parm: | 89 | return oe.patch.should_apply(parm, d) |
| 151 | pn = d.getVar('PN', True) | ||
| 152 | srcdate = d.getVar('SRCDATE_%s' % pn, True) | ||
| 153 | if not srcdate: | ||
| 154 | srcdate = d.getVar('SRCDATE', True) | ||
| 155 | |||
| 156 | if srcdate == "now": | ||
| 157 | srcdate = d.getVar('DATE', True) | ||
| 158 | |||
| 159 | if "maxdate" in parm and parm["maxdate"] < srcdate: | ||
| 160 | return False, 'is outdated' | ||
| 161 | |||
| 162 | if "mindate" in parm and parm["mindate"] > srcdate: | ||
| 163 | return False, 'is predated' | ||
| 164 | |||
| 165 | |||
| 166 | if "minrev" in parm: | ||
| 167 | srcrev = d.getVar('SRCREV', True) | ||
| 168 | if srcrev and srcrev < parm["minrev"]: | ||
| 169 | return False, 'applies to later revisions' | ||
| 170 | |||
| 171 | if "maxrev" in parm: | ||
| 172 | srcrev = d.getVar('SRCREV', True) | ||
| 173 | if srcrev and srcrev > parm["maxrev"]: | ||
| 174 | return False, 'applies to earlier revisions' | ||
| 175 | |||
| 176 | if "rev" in parm: | ||
| 177 | srcrev = d.getVar('SRCREV', True) | ||
| 178 | if srcrev and parm["rev"] not in srcrev: | ||
| 179 | return False, "doesn't apply to revision" | ||
| 180 | |||
| 181 | if "notrev" in parm: | ||
| 182 | srcrev = d.getVar('SRCREV', True) | ||
| 183 | if srcrev and parm["notrev"] in srcrev: | ||
| 184 | return False, "doesn't apply to revision" | ||
| 185 | |||
| 186 | return True, None | ||
| 187 | 90 | ||
| 188 | should_apply[vardepsexclude] = "DATE SRCDATE" | 91 | should_apply[vardepsexclude] = "DATE SRCDATE" |
| 189 | 92 | ||
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index dbefd28e67..456ee70f7d 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py | |||
| @@ -769,3 +769,110 @@ class UserResolver(Resolver): | |||
| 769 | os.chdir(olddir) | 769 | os.chdir(olddir) |
| 770 | raise | 770 | raise |
| 771 | os.chdir(olddir) | 771 | os.chdir(olddir) |
| 772 | |||
| 773 | |||
| 774 | def patch_path(url, fetch, workdir, expand=True): | ||
| 775 | """Return the local path of a patch, or None if this isn't a patch""" | ||
| 776 | |||
| 777 | local = fetch.localpath(url) | ||
| 778 | base, ext = os.path.splitext(os.path.basename(local)) | ||
| 779 | if ext in ('.gz', '.bz2', '.Z'): | ||
| 780 | if expand: | ||
| 781 | local = os.path.join(workdir, base) | ||
| 782 | ext = os.path.splitext(base)[1] | ||
| 783 | |||
| 784 | urldata = fetch.ud[url] | ||
| 785 | if "apply" in urldata.parm: | ||
| 786 | apply = oe.types.boolean(urldata.parm["apply"]) | ||
| 787 | if not apply: | ||
| 788 | return | ||
| 789 | elif ext not in (".diff", ".patch"): | ||
| 790 | return | ||
| 791 | |||
| 792 | return local | ||
| 793 | |||
| 794 | def src_patches(d, all=False, expand=True): | ||
| 795 | workdir = d.getVar('WORKDIR', True) | ||
| 796 | fetch = bb.fetch2.Fetch([], d) | ||
| 797 | patches = [] | ||
| 798 | sources = [] | ||
| 799 | for url in fetch.urls: | ||
| 800 | local = patch_path(url, fetch, workdir, expand) | ||
| 801 | if not local: | ||
| 802 | if all: | ||
| 803 | local = fetch.localpath(url) | ||
| 804 | sources.append(local) | ||
| 805 | continue | ||
| 806 | |||
| 807 | urldata = fetch.ud[url] | ||
| 808 | parm = urldata.parm | ||
| 809 | patchname = parm.get('pname') or os.path.basename(local) | ||
| 810 | |||
| 811 | apply, reason = should_apply(parm, d) | ||
| 812 | if not apply: | ||
| 813 | if reason: | ||
| 814 | bb.note("Patch %s %s" % (patchname, reason)) | ||
| 815 | continue | ||
| 816 | |||
| 817 | patchparm = {'patchname': patchname} | ||
| 818 | if "striplevel" in parm: | ||
| 819 | striplevel = parm["striplevel"] | ||
| 820 | elif "pnum" in parm: | ||
| 821 | #bb.msg.warn(None, "Deprecated usage of 'pnum' url parameter in '%s', please use 'striplevel'" % url) | ||
| 822 | striplevel = parm["pnum"] | ||
| 823 | else: | ||
| 824 | striplevel = '1' | ||
| 825 | patchparm['striplevel'] = striplevel | ||
| 826 | |||
| 827 | patchdir = parm.get('patchdir') | ||
| 828 | if patchdir: | ||
| 829 | patchparm['patchdir'] = patchdir | ||
| 830 | |||
| 831 | localurl = bb.fetch.encodeurl(('file', '', local, '', '', patchparm)) | ||
| 832 | patches.append(localurl) | ||
| 833 | |||
| 834 | if all: | ||
| 835 | return sources | ||
| 836 | |||
| 837 | return patches | ||
| 838 | |||
| 839 | |||
| 840 | def should_apply(parm, d): | ||
| 841 | if "mindate" in parm or "maxdate" in parm: | ||
| 842 | pn = d.getVar('PN', True) | ||
| 843 | srcdate = d.getVar('SRCDATE_%s' % pn, True) | ||
| 844 | if not srcdate: | ||
| 845 | srcdate = d.getVar('SRCDATE', True) | ||
| 846 | |||
| 847 | if srcdate == "now": | ||
| 848 | srcdate = d.getVar('DATE', True) | ||
| 849 | |||
| 850 | if "maxdate" in parm and parm["maxdate"] < srcdate: | ||
| 851 | return False, 'is outdated' | ||
| 852 | |||
| 853 | if "mindate" in parm and parm["mindate"] > srcdate: | ||
| 854 | return False, 'is predated' | ||
| 855 | |||
| 856 | |||
| 857 | if "minrev" in parm: | ||
| 858 | srcrev = d.getVar('SRCREV', True) | ||
| 859 | if srcrev and srcrev < parm["minrev"]: | ||
| 860 | return False, 'applies to later revisions' | ||
| 861 | |||
| 862 | if "maxrev" in parm: | ||
| 863 | srcrev = d.getVar('SRCREV', True) | ||
| 864 | if srcrev and srcrev > parm["maxrev"]: | ||
| 865 | return False, 'applies to earlier revisions' | ||
| 866 | |||
| 867 | if "rev" in parm: | ||
| 868 | srcrev = d.getVar('SRCREV', True) | ||
| 869 | if srcrev and parm["rev"] not in srcrev: | ||
| 870 | return False, "doesn't apply to revision" | ||
| 871 | |||
| 872 | if "notrev" in parm: | ||
| 873 | srcrev = d.getVar('SRCREV', True) | ||
| 874 | if srcrev and parm["notrev"] in srcrev: | ||
| 875 | return False, "doesn't apply to revision" | ||
| 876 | |||
| 877 | return True, None | ||
| 878 | |||
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index ae83aabec1..92fa431e0b 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py | |||
| @@ -382,6 +382,7 @@ def copy_recipe_files(d, tgt_dir, whole_dir=False, download=True): | |||
| 382 | 382 | ||
| 383 | def get_recipe_local_files(d, patches=False, archives=False): | 383 | def get_recipe_local_files(d, patches=False, archives=False): |
| 384 | """Get a list of local files in SRC_URI within a recipe.""" | 384 | """Get a list of local files in SRC_URI within a recipe.""" |
| 385 | import oe.patch | ||
| 385 | uris = (d.getVar('SRC_URI', True) or "").split() | 386 | uris = (d.getVar('SRC_URI', True) or "").split() |
| 386 | fetch = bb.fetch2.Fetch(uris, d) | 387 | fetch = bb.fetch2.Fetch(uris, d) |
| 387 | # FIXME this list should be factored out somewhere else (such as the | 388 | # FIXME this list should be factored out somewhere else (such as the |
| @@ -393,7 +394,7 @@ def get_recipe_local_files(d, patches=False, archives=False): | |||
| 393 | for uri in uris: | 394 | for uri in uris: |
| 394 | if fetch.ud[uri].type == 'file': | 395 | if fetch.ud[uri].type == 'file': |
| 395 | if (not patches and | 396 | if (not patches and |
| 396 | bb.utils.exec_flat_python_func('patch_path', uri, fetch, '', expand=False)): | 397 | oe.patch.patch_path(uri, fetch, '', expand=False)): |
| 397 | continue | 398 | continue |
| 398 | # Skip files that are referenced by absolute path | 399 | # Skip files that are referenced by absolute path |
| 399 | fname = fetch.ud[uri].basepath | 400 | fname = fetch.ud[uri].basepath |
| @@ -418,10 +419,9 @@ def get_recipe_local_files(d, patches=False, archives=False): | |||
| 418 | 419 | ||
| 419 | def get_recipe_patches(d): | 420 | def get_recipe_patches(d): |
| 420 | """Get a list of the patches included in SRC_URI within a recipe.""" | 421 | """Get a list of the patches included in SRC_URI within a recipe.""" |
| 422 | import oe.patch | ||
| 423 | patches = oe.patch.src_patches(d, expand=False) | ||
| 421 | patchfiles = [] | 424 | patchfiles = [] |
| 422 | # Execute src_patches() defined in patch.bbclass - this works since that class | ||
| 423 | # is inherited globally | ||
| 424 | patches = bb.utils.exec_flat_python_func('src_patches', d, expand=False) | ||
| 425 | for patch in patches: | 425 | for patch in patches: |
| 426 | _, _, local, _, _, parm = bb.fetch.decodeurl(patch) | 426 | _, _, local, _, _, parm = bb.fetch.decodeurl(patch) |
| 427 | patchfiles.append(local) | 427 | patchfiles.append(local) |
| @@ -438,9 +438,7 @@ def get_recipe_patched_files(d): | |||
| 438 | change mode ('A' for add, 'D' for delete or 'M' for modify) | 438 | change mode ('A' for add, 'D' for delete or 'M' for modify) |
| 439 | """ | 439 | """ |
| 440 | import oe.patch | 440 | import oe.patch |
| 441 | # Execute src_patches() defined in patch.bbclass - this works since that class | 441 | patches = oe.patch.src_patches(d, expand=False) |
| 442 | # is inherited globally | ||
| 443 | patches = bb.utils.exec_flat_python_func('src_patches', d, expand=False) | ||
| 444 | patchedfiles = {} | 442 | patchedfiles = {} |
| 445 | for patch in patches: | 443 | for patch in patches: |
| 446 | _, _, patchfile, _, _, parm = bb.fetch.decodeurl(patch) | 444 | _, _, patchfile, _, _, parm = bb.fetch.decodeurl(patch) |
