summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/patch.bbclass59
1 files changed, 36 insertions, 23 deletions
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index b8207680ba..7ba8abb72c 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -6,7 +6,7 @@ QUILTRCFILE ?= "${STAGING_BINDIR_NATIVE}/quiltrc"
6PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot" 6PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot"
7 7
8python patch_do_patch() { 8python patch_do_patch() {
9 import oe.patch 9 import oe.patch
10 10
11 src_uri = (bb.data.getVar('SRC_URI', d, 1) or '').split() 11 src_uri = (bb.data.getVar('SRC_URI', d, 1) or '').split()
12 if not src_uri: 12 if not src_uri:
@@ -25,7 +25,7 @@ python patch_do_patch() {
25 "user": oe.patch.UserResolver, 25 "user": oe.patch.UserResolver,
26 } 26 }
27 27
28 rcls = resolvermap[bb.data.getVar('PATCHRESOLVE', d, 1) or 'noop'] 28 rcls = resolvermap[bb.data.getVar('PATCHRESOLVE', d, 1) or 'user']
29 29
30 s = bb.data.getVar('S', d, 1) 30 s = bb.data.getVar('S', d, 1)
31 31
@@ -39,32 +39,44 @@ python patch_do_patch() {
39 workdir = bb.data.getVar('WORKDIR', d, 1) 39 workdir = bb.data.getVar('WORKDIR', d, 1)
40 for url in src_uri: 40 for url in src_uri:
41 (type, host, path, user, pswd, parm) = bb.decodeurl(url) 41 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
42 if not "patch" in parm:
43 continue
44
45 bb.fetch.init([url],d)
46 url = bb.encodeurl((type, host, path, user, pswd, []))
47 local = os.path.join('/', bb.fetch.localpath(url, d))
48 42
49 # did it need to be unpacked? 43 local = None
50 dots = os.path.basename(local).split(".") 44 base, ext = os.path.splitext(os.path.basename(path))
51 if dots[-1] in ['gz', 'bz2', 'Z']: 45 if ext in ('.gz', '.bz2', '.Z'):
52 unpacked = os.path.join(bb.data.getVar('WORKDIR', d),'.'.join(dots[0:-1])) 46 local = os.path.join(workdir, base)
53 else: 47 ext = os.path.splitext(base)[1]
54 unpacked = local 48
55 unpacked = bb.data.expand(unpacked, d) 49 if "apply" in parm:
50 apply = parm["apply"]
51 if apply != "yes":
52 if apply != "no":
53 bb.msg.warn(None, "Unsupported value '%s' for 'apply' url param in '%s', please use 'yes' or 'no'" % (apply, url))
54 continue
55 #elif "patch" in parm:
56 #bb.msg.warn(None, "Deprecated usage of 'patch' url param in '%s', please use 'apply={yes,no}'" % url)
57 elif ext not in (".diff", ".patch"):
58 continue
56 59
57 if "pnum" in parm: 60 if not local:
58 pnum = parm["pnum"] 61 bb.fetch.init([url],d)
62 url = bb.encodeurl((type, host, path, user, pswd, []))
63 local = os.path.join('/', bb.fetch.localpath(url, d))
64 local = bb.data.expand(local, d)
65
66 if "striplevel" in parm:
67 striplevel = parm["striplevel"]
68 elif "pnum" in parm:
69 #bb.msg.warn(None, "Deprecated usage of 'pnum' url parameter in '%s', please use 'striplevel'" % url)
70 striplevel = parm["pnum"]
59 else: 71 else:
60 pnum = "1" 72 striplevel = '1'
61 73
62 if "pname" in parm: 74 if "pname" in parm:
63 pname = parm["pname"] 75 pname = parm["pname"]
64 else: 76 else:
65 pname = os.path.basename(unpacked) 77 pname = os.path.basename(local)
66 78
67 if "mindate" in parm or "maxdate" in parm: 79 if "mindate" in parm or "maxdate" in parm:
68 pn = bb.data.getVar('PN', d, 1) 80 pn = bb.data.getVar('PN', d, 1)
69 srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1) 81 srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
70 if not srcdate: 82 if not srcdate:
@@ -106,16 +118,17 @@ python patch_do_patch() {
106 bb.note("Patch '%s' doesn't apply to revision" % pname) 118 bb.note("Patch '%s' doesn't apply to revision" % pname)
107 continue 119 continue
108 120
109 bb.note("Applying patch '%s'" % pname) 121 bb.note("Applying patch '%s' (%s)" % (pname, oe.path.format_display(local, d)))
110 try: 122 try:
111 patchset.Import({"file":unpacked, "remote":url, "strippath": pnum}, True) 123 patchset.Import({"file":local, "remote":url, "strippath": striplevel}, True)
112 resolver.Resolve()
113 except Exception: 124 except Exception:
114 import sys 125 import sys
115 raise bb.build.FuncFailed(str(sys.exc_value)) 126 raise bb.build.FuncFailed(str(sys.exc_value))
127 resolver.Resolve()
116} 128}
117 129
118addtask patch after do_unpack 130addtask patch after do_unpack
119do_patch[dirs] = "${WORKDIR}" 131do_patch[dirs] = "${WORKDIR}"
120do_patch[depends] = "${PATCHDEPENDENCY}" 132do_patch[depends] = "${PATCHDEPENDENCY}"
133
121EXPORT_FUNCTIONS do_patch 134EXPORT_FUNCTIONS do_patch