1 # Copyright (C) 2006 OpenedHand LTD
3 # Point to an empty file so any user's custom settings don't break things
4 QUILTRCFILE ?= "${STAGING_BINDIR_NATIVE}/quiltrc"
6 PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot"
8 python patch_do_patch() {
12 src_uri = (bb.data.getVar('SRC_URI', d, 1) or '').split()
17 "patch": oe.patch.PatchTree,
18 "quilt": oe.patch.QuiltTree,
19 "git": oe.patch.GitApplyTree,
22 cls = patchsetmap[bb.data.getVar('PATCHTOOL', d, 1) or 'quilt']
25 "noop": oe.patch.NOOPResolver,
26 "user": oe.patch.UserResolver,
29 rcls = resolvermap[bb.data.getVar('PATCHRESOLVE', d, 1) or 'user']
31 s = bb.data.getVar('S', d, 1)
33 path = os.getenv('PATH')
34 os.putenv('PATH', bb.data.getVar('PATH', d, 1))
38 src_uri = d.getVar("SRC_URI", True).split()
39 srcurldata = bb.fetch.init(src_uri, d, True)
40 workdir = bb.data.getVar('WORKDIR', d, 1)
41 for url in d.getVar("SRC_URI", True).split():
42 urldata = srcurldata[url]
44 local = urldata.localpath
46 raise bb.build.FuncFailed('Unable to locate local file for %s' % url)
48 base, ext = os.path.splitext(os.path.basename(local))
49 if ext in ('.gz', '.bz2', '.Z'):
50 local = oe.path.join(workdir, base)
52 if not oe.unpack.is_patch(local, urldata.parm):
57 if "striplevel" in parm:
58 striplevel = parm["striplevel"]
60 bb.msg.warn(None, "Deprecated usage of 'pnum' url parameter in '%s', please use 'striplevel'" % url)
61 striplevel = parm["pnum"]
68 pname = os.path.basename(local)
70 if "mindate" in parm or "maxdate" in parm:
71 pn = bb.data.getVar('PN', d, 1)
72 srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
74 srcdate = bb.data.getVar('SRCDATE', d, 1)
77 srcdate = bb.data.getVar('DATE', d, 1)
79 if "maxdate" in parm and parm["maxdate"] < srcdate:
80 bb.note("Patch '%s' is outdated" % pname)
83 if "mindate" in parm and parm["mindate"] > srcdate:
84 bb.note("Patch '%s' is predated" % pname)
89 srcrev = bb.data.getVar('SRCREV', d, 1)
90 if srcrev and srcrev < parm["minrev"]:
91 bb.note("Patch '%s' applies to later revisions" % pname)
95 srcrev = bb.data.getVar('SRCREV', d, 1)
96 if srcrev and srcrev > parm["maxrev"]:
97 bb.note("Patch '%s' applies to earlier revisions" % pname)
100 if "patchdir" in parm:
101 patchdir = parm["patchdir"]
102 if not os.path.isabs(patchdir):
103 patchdir = os.path.join(s, patchdir)
107 if not patchdir in classes:
108 patchset = cls(patchdir, d)
109 resolver = rcls(patchset)
110 classes[patchdir] = (patchset, resolver)
113 patchset, resolver = classes[patchdir]
115 bb.note("Applying patch '%s' (%s)" % (pname, oe.path.format_display(local, d)))
117 patchset.Import({"file":local, "remote":url, "strippath": striplevel}, True)
120 raise bb.build.FuncFailed(str(sys.exc_value))
124 addtask patch after do_unpack
125 do_patch[dirs] = "${WORKDIR}"
126 do_patch[depends] = "${PATCHDEPENDENCY}"
128 EXPORT_FUNCTIONS do_patch