1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# Copyright (C) 2006 OpenedHand LTD
# Point to an empty file so any user's custom settings don't break things
QUILTRCFILE ?= "${STAGING_BINDIR_NATIVE}/quiltrc"
PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot"
python patch_do_patch() {
import oe.patch
import oe.unpack
src_uri = (bb.data.getVar('SRC_URI', d, 1) or '').split()
if not src_uri:
return
patchsetmap = {
"patch": oe.patch.PatchTree,
"quilt": oe.patch.QuiltTree,
"git": oe.patch.GitApplyTree,
}
cls = patchsetmap[bb.data.getVar('PATCHTOOL', d, 1) or 'quilt']
resolvermap = {
"noop": oe.patch.NOOPResolver,
"user": oe.patch.UserResolver,
}
rcls = resolvermap[bb.data.getVar('PATCHRESOLVE', d, 1) or 'user']
s = bb.data.getVar('S', d, 1)
path = os.getenv('PATH')
os.putenv('PATH', bb.data.getVar('PATH', d, 1))
classes = {}
src_uri = d.getVar("SRC_URI", True).split()
srcurldata = bb.fetch.init(src_uri, d, True)
workdir = bb.data.getVar('WORKDIR', d, 1)
for url in d.getVar("SRC_URI", True).split():
urldata = srcurldata[url]
local = urldata.localpath
if not local:
raise bb.build.FuncFailed('Unable to locate local file for %s' % url)
base, ext = os.path.splitext(os.path.basename(local))
if ext in ('.gz', '.bz2', '.Z'):
local = oe.path.join(workdir, base)
if not oe.unpack.is_patch(local, urldata.parm):
continue
parm = urldata.parm
if "striplevel" in parm:
striplevel = parm["striplevel"]
elif "pnum" in parm:
bb.msg.warn(None, "Deprecated usage of 'pnum' url parameter in '%s', please use 'striplevel'" % url)
striplevel = parm["pnum"]
else:
striplevel = '1'
if "pname" in parm:
pname = parm["pname"]
else:
pname = os.path.basename(local)
if "mindate" in parm or "maxdate" in parm:
pn = bb.data.getVar('PN', d, 1)
srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
if not srcdate:
srcdate = bb.data.getVar('SRCDATE', d, 1)
if srcdate == "now":
srcdate = bb.data.getVar('DATE', d, 1)
if "maxdate" in parm and parm["maxdate"] < srcdate:
bb.note("Patch '%s' is outdated" % pname)
continue
if "mindate" in parm and parm["mindate"] > srcdate:
bb.note("Patch '%s' is predated" % pname)
continue
if "minrev" in parm:
srcrev = bb.data.getVar('SRCREV', d, 1)
if srcrev and srcrev < parm["minrev"]:
bb.note("Patch '%s' applies to later revisions" % pname)
continue
if "maxrev" in parm:
srcrev = bb.data.getVar('SRCREV', d, 1)
if srcrev and srcrev > parm["maxrev"]:
bb.note("Patch '%s' applies to earlier revisions" % pname)
continue
if "patchdir" in parm:
patchdir = parm["patchdir"]
if not os.path.isabs(patchdir):
patchdir = os.path.join(s, patchdir)
else:
patchdir = s
if not patchdir in classes:
patchset = cls(patchdir, d)
resolver = rcls(patchset)
classes[patchdir] = (patchset, resolver)
patchset.Clean()
else:
patchset, resolver = classes[patchdir]
bb.note("Applying patch '%s' (%s)" % (pname, oe.path.format_display(local, d)))
try:
patchset.Import({"file":local, "remote":url, "strippath": striplevel}, True)
except Exception:
import sys
raise bb.build.FuncFailed(str(sys.exc_value))
resolver.Resolve()
}
addtask patch after do_unpack
do_patch[dirs] = "${WORKDIR}"
do_patch[depends] = "${PATCHDEPENDENCY}"
EXPORT_FUNCTIONS do_patch
|