summaryrefslogtreecommitdiffstats
path: root/meta/classes/patch.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-07-11 17:33:43 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-07-19 10:24:50 +0100
commitbfd279de3275abbfaf3e630383ec244131e0375f (patch)
tree0d1c90461a890d21444f5d2afb13c52b302427f1 /meta/classes/patch.bbclass
parent99203edda6f0b09d817454d656c100b7a8806b18 (diff)
downloadpoky-bfd279de3275abbfaf3e630383ec244131e0375f.tar.gz
Convert tab indentation in python functions into four-space
(From OE-Core rev: 604d46c686d06d62d5a07b9c7f4fa170f99307d8) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/patch.bbclass')
-rw-r--r--meta/classes/patch.bbclass274
1 files changed, 137 insertions, 137 deletions
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index 3c4d997833..a724972821 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -8,164 +8,164 @@ PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot"
8inherit terminal 8inherit terminal
9 9
10def src_patches(d, all = False ): 10def src_patches(d, all = False ):
11 workdir = d.getVar('WORKDIR', True) 11 workdir = d.getVar('WORKDIR', True)
12 fetch = bb.fetch2.Fetch([], d) 12 fetch = bb.fetch2.Fetch([], d)
13 patches = [] 13 patches = []
14 sources = [] 14 sources = []
15 for url in fetch.urls: 15 for url in fetch.urls:
16 local = patch_path(url, fetch, workdir) 16 local = patch_path(url, fetch, workdir)
17 if not local: 17 if not local:
18 if all: 18 if all:
19 local = fetch.localpath(url) 19 local = fetch.localpath(url)
20 sources.append(local) 20 sources.append(local)
21 continue 21 continue
22 22
23 urldata = fetch.ud[url] 23 urldata = fetch.ud[url]
24 parm = urldata.parm 24 parm = urldata.parm
25 patchname = parm.get('pname') or os.path.basename(local) 25 patchname = parm.get('pname') or os.path.basename(local)
26 26
27 apply, reason = should_apply(parm, d) 27 apply, reason = should_apply(parm, d)
28 if not apply: 28 if not apply:
29 if reason: 29 if reason:
30 bb.note("Patch %s %s" % (patchname, reason)) 30 bb.note("Patch %s %s" % (patchname, reason))
31 continue 31 continue
32 32
33 patchparm = {'patchname': patchname} 33 patchparm = {'patchname': patchname}
34 if "striplevel" in parm: 34 if "striplevel" in parm:
35 striplevel = parm["striplevel"] 35 striplevel = parm["striplevel"]
36 elif "pnum" in parm: 36 elif "pnum" in parm:
37 #bb.msg.warn(None, "Deprecated usage of 'pnum' url parameter in '%s', please use 'striplevel'" % url) 37 #bb.msg.warn(None, "Deprecated usage of 'pnum' url parameter in '%s', please use 'striplevel'" % url)
38 striplevel = parm["pnum"] 38 striplevel = parm["pnum"]
39 else: 39 else:
40 striplevel = '1' 40 striplevel = '1'
41 patchparm['striplevel'] = striplevel 41 patchparm['striplevel'] = striplevel
42 42
43 patchdir = parm.get('patchdir') 43 patchdir = parm.get('patchdir')
44 if patchdir: 44 if patchdir:
45 patchparm['patchdir'] = patchdir 45 patchparm['patchdir'] = patchdir
46 46
47 localurl = bb.encodeurl(('file', '', local, '', '', patchparm)) 47 localurl = bb.encodeurl(('file', '', local, '', '', patchparm))
48 patches.append(localurl) 48 patches.append(localurl)
49 49
50 if all: 50 if all:
51 return sources 51 return sources
52 52
53 return patches 53 return patches
54 54
55def patch_path(url, fetch, workdir): 55def patch_path(url, fetch, workdir):
56 """Return the local path of a patch, or None if this isn't a patch""" 56 """Return the local path of a patch, or None if this isn't a patch"""
57 57
58 local = fetch.localpath(url) 58 local = fetch.localpath(url)
59 base, ext = os.path.splitext(os.path.basename(local)) 59 base, ext = os.path.splitext(os.path.basename(local))
60 if ext in ('.gz', '.bz2', '.Z'): 60 if ext in ('.gz', '.bz2', '.Z'):
61 local = os.path.join(workdir, base) 61 local = os.path.join(workdir, base)
62 ext = os.path.splitext(base)[1] 62 ext = os.path.splitext(base)[1]
63 63
64 urldata = fetch.ud[url] 64 urldata = fetch.ud[url]
65 if "apply" in urldata.parm: 65 if "apply" in urldata.parm:
66 apply = oe.types.boolean(urldata.parm["apply"]) 66 apply = oe.types.boolean(urldata.parm["apply"])
67 if not apply: 67 if not apply:
68 return 68 return
69 elif ext not in (".diff", ".patch"): 69 elif ext not in (".diff", ".patch"):
70 return 70 return
71 71
72 return local 72 return local
73 73
74def should_apply(parm, d): 74def should_apply(parm, d):
75 """Determine if we should apply the given patch""" 75 """Determine if we should apply the given patch"""
76 76
77 if "mindate" in parm or "maxdate" in parm: 77 if "mindate" in parm or "maxdate" in parm:
78 pn = d.getVar('PN', True) 78 pn = d.getVar('PN', True)
79 srcdate = d.getVar('SRCDATE_%s' % pn, True) 79 srcdate = d.getVar('SRCDATE_%s' % pn, True)
80 if not srcdate: 80 if not srcdate:
81 srcdate = d.getVar('SRCDATE', True) 81 srcdate = d.getVar('SRCDATE', True)
82 82
83 if srcdate == "now": 83 if srcdate == "now":
84 srcdate = d.getVar('DATE', True) 84 srcdate = d.getVar('DATE', True)
85 85
86 if "maxdate" in parm and parm["maxdate"] < srcdate: 86 if "maxdate" in parm and parm["maxdate"] < srcdate:
87 return False, 'is outdated' 87 return False, 'is outdated'
88 88
89 if "mindate" in parm and parm["mindate"] > srcdate: 89 if "mindate" in parm and parm["mindate"] > srcdate:
90 return False, 'is predated' 90 return False, 'is predated'
91 91
92 92
93 if "minrev" in parm: 93 if "minrev" in parm:
94 srcrev = d.getVar('SRCREV', True) 94 srcrev = d.getVar('SRCREV', True)
95 if srcrev and srcrev < parm["minrev"]: 95 if srcrev and srcrev < parm["minrev"]:
96 return False, 'applies to later revisions' 96 return False, 'applies to later revisions'
97 97
98 if "maxrev" in parm: 98 if "maxrev" in parm:
99 srcrev = d.getVar('SRCREV', True) 99 srcrev = d.getVar('SRCREV', True)
100 if srcrev and srcrev > parm["maxrev"]: 100 if srcrev and srcrev > parm["maxrev"]:
101 return False, 'applies to earlier revisions' 101 return False, 'applies to earlier revisions'
102 102
103 if "rev" in parm: 103 if "rev" in parm:
104 srcrev = d.getVar('SRCREV', True) 104 srcrev = d.getVar('SRCREV', True)
105 if srcrev and parm["rev"] not in srcrev: 105 if srcrev and parm["rev"] not in srcrev:
106 return False, "doesn't apply to revision" 106 return False, "doesn't apply to revision"
107 107
108 if "notrev" in parm: 108 if "notrev" in parm:
109 srcrev = d.getVar('SRCREV', True) 109 srcrev = d.getVar('SRCREV', True)
110 if srcrev and parm["notrev"] in srcrev: 110 if srcrev and parm["notrev"] in srcrev:
111 return False, "doesn't apply to revision" 111 return False, "doesn't apply to revision"
112 112
113 return True, None 113 return True, None
114 114
115should_apply[vardepsexclude] = "DATE SRCDATE" 115should_apply[vardepsexclude] = "DATE SRCDATE"
116 116
117python patch_do_patch() { 117python patch_do_patch() {
118 import oe.patch 118 import oe.patch
119 119
120 patchsetmap = { 120 patchsetmap = {
121 "patch": oe.patch.PatchTree, 121 "patch": oe.patch.PatchTree,
122 "quilt": oe.patch.QuiltTree, 122 "quilt": oe.patch.QuiltTree,
123 "git": oe.patch.GitApplyTree, 123 "git": oe.patch.GitApplyTree,
124 } 124 }
125 125
126 cls = patchsetmap[d.getVar('PATCHTOOL', True) or 'quilt'] 126 cls = patchsetmap[d.getVar('PATCHTOOL', True) or 'quilt']
127 127
128 resolvermap = { 128 resolvermap = {
129 "noop": oe.patch.NOOPResolver, 129 "noop": oe.patch.NOOPResolver,
130 "user": oe.patch.UserResolver, 130 "user": oe.patch.UserResolver,
131 } 131 }
132 132
133 rcls = resolvermap[d.getVar('PATCHRESOLVE', True) or 'user'] 133 rcls = resolvermap[d.getVar('PATCHRESOLVE', True) or 'user']
134 134
135 classes = {} 135 classes = {}
136 136
137 s = d.getVar('S', True) 137 s = d.getVar('S', True)
138 138
139 path = os.getenv('PATH') 139 path = os.getenv('PATH')
140 os.putenv('PATH', d.getVar('PATH', True)) 140 os.putenv('PATH', d.getVar('PATH', True))
141 141
142 for patch in src_patches(d): 142 for patch in src_patches(d):
143 _, _, local, _, _, parm = bb.decodeurl(patch) 143 _, _, local, _, _, parm = bb.decodeurl(patch)
144 144
145 if "patchdir" in parm: 145 if "patchdir" in parm:
146 patchdir = parm["patchdir"] 146 patchdir = parm["patchdir"]
147 if not os.path.isabs(patchdir): 147 if not os.path.isabs(patchdir):
148 patchdir = os.path.join(s, patchdir) 148 patchdir = os.path.join(s, patchdir)
149 else: 149 else:
150 patchdir = s 150 patchdir = s
151 151
152 if not patchdir in classes: 152 if not patchdir in classes:
153 patchset = cls(patchdir, d) 153 patchset = cls(patchdir, d)
154 resolver = rcls(patchset, oe_terminal) 154 resolver = rcls(patchset, oe_terminal)
155 classes[patchdir] = (patchset, resolver) 155 classes[patchdir] = (patchset, resolver)
156 patchset.Clean() 156 patchset.Clean()
157 else: 157 else:
158 patchset, resolver = classes[patchdir] 158 patchset, resolver = classes[patchdir]
159 159
160 bb.note("Applying patch '%s' (%s)" % (parm['patchname'], oe.path.format_display(local, d))) 160 bb.note("Applying patch '%s' (%s)" % (parm['patchname'], oe.path.format_display(local, d)))
161 try: 161 try:
162 patchset.Import({"file":local, "strippath": parm['striplevel']}, True) 162 patchset.Import({"file":local, "strippath": parm['striplevel']}, True)
163 except Exception as exc: 163 except Exception as exc:
164 bb.fatal(str(exc)) 164 bb.fatal(str(exc))
165 try: 165 try:
166 resolver.Resolve() 166 resolver.Resolve()
167 except bb.BBHandledException as e: 167 except bb.BBHandledException as e:
168 bb.fatal(str(e)) 168 bb.fatal(str(e))
169} 169}
170patch_do_patch[vardepsexclude] = "PATCHRESOLVE" 170patch_do_patch[vardepsexclude] = "PATCHRESOLVE"
171 171