diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-12-13 20:09:39 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-12-14 12:30:50 +0000 |
commit | 275b3fe5f47c5dabb5bd16e916bf6ad9118bee79 (patch) | |
tree | 20a9746f0df284a548e428c6bd8c6999a06efeff /meta/classes | |
parent | 45adbe370908901d0d2e94b3c4daea821772e2ff (diff) | |
download | poky-275b3fe5f47c5dabb5bd16e916bf6ad9118bee79.tar.gz |
classes/patch: move several functions to oe.patch
Move patch_path(), src_patches() and should_apply() to oe.patch, making
them easier to call from elsewhere (particularly across the
UI/server boundary).
(From OE-Core rev: 2724511e18810cc8082c1b028e3b7c8a8b5def56)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/patch.bbclass | 105 |
1 files changed, 4 insertions, 101 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 | ||