Skip to contentSkip to conversation

patch.bbclass: abstract out logic that determines patches to apply

PATCH In review Christopher Larson 4 participants 8 messages Dec 20, 2011 – Jan 4, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 patch.bbclass: abstract out logic that determines patches to apply

This is needed by the copyleft_compliance class, so it can emit series files for the patches, which greatly increases their usefulness to a user trying to reconstruct the sources outside of OE.

---
 meta/classes/patch.bbclass |  196 
+++++++++++++++++++++++--------------------
 1 files changed, 105 insertions(+), 91 deletions(-)
meta/classes/patch.bbclass +99 -83
index ac6c1ce..454d9ce 100644
@@ -7,13 +7,106 @@ PATCHDEPENDENCY = "${PATCHTOOL}-native:do_populate_sysroot"
  inherit terminal
 -python patch_do_patch() {
-	import oe.patch
+def src_patches(d):
+	workdir = d.getVar('WORKDIR', True)
+	fetch = bb.fetch2.Fetch([], d)
+	patches = []
+	for url in fetch.urls:
+		local = patch_path(url, fetch, workdir)
+		if not local:
+			continue
+
+		urldata = fetch.ud[url]
+		parm = urldata.parm
+		patchname = parm.get('pname') or os.path.basename(local)
+
+		apply, reason = should_apply(parm)
+		if not apply:
+			if reason:
+				bb.note("Patch %s %s" % (patchname, reason))
+			continue
 -	src_uri = (d.getVar('SRC_URI', 1) or '').split()
-	if not src_uri:
+		patchparm = {'patchname': patchname}
+		if "striplevel" in parm:
+			striplevel = parm["striplevel"]
+		elif "pnum" in parm:
+			striplevel = parm["pnum"]
+		else:
+			striplevel = '1'
+		patchparm['striplevel'] = striplevel
+
+		patchdir = parm.get('patchdir')
+		if patchdir:
+			patchparm['patchdir'] = patchdir
+
+		localurl = bb.encodeurl(('file', '', local, '', '', patchparm))
+		patches.append(localurl)
+
+	return patches
+
+def patch_path(url, fetch, workdir):
+	"""Return the local path of a patch, or None if this isn't a patch"""
+
+	local = fetch.localpath(url)
+	base, ext = os.path.splitext(os.path.basename(local))
+	if ext in ('.gz', '.bz2', '.Z'):
+		local = os.path.join(workdir, base)
+		ext = os.path.splitext(base)[1]
+
+	urldata = fetch.ud[url]
+	if "apply" in urldata.parm:
+		apply = oe.types.boolean(urldata.parm["apply"])
+		if not apply:
+			return
+	elif ext not in (".diff", ".patch"):
 		return
 +	return local
+
+def should_apply(parm):
+	"""Determine if we should apply the given patch"""
+
+	if "mindate" in parm or "maxdate" in parm:
+		pn = d.getVar('PN', 1)
+		srcdate = d.getVar('SRCDATE_%s' % pn, 1)
+		if not srcdate:
+			srcdate = d.getVar('SRCDATE', 1)
+
+		if srcdate == "now":
+			srcdate = d.getVar('DATE', 1)
+
+		if "maxdate" in parm and parm["maxdate"] < srcdate:
+			return False, 'is outdated'
+
+		if "mindate" in parm and parm["mindate"] > srcdate:
+			return False, 'is predated'
+
+
+	if "minrev" in parm:
+		srcrev = d.getVar('SRCREV', 1)
+		if srcrev and srcrev < parm["minrev"]:
+			return False, 'applies to later revisions'
+
+	if "maxrev" in parm:
+		srcrev = d.getVar('SRCREV', 1)
+		if srcrev and srcrev > parm["maxrev"]:
+			return False, 'applies to earlier revisions'
+
+	if "rev" in parm:
+		srcrev = d.getVar('SRCREV', 1)
+		if srcrev and parm["rev"] not in srcrev:
+			return False, "doesn't apply to revision"
+
+	if "notrev" in parm:
+		srcrev = d.getVar('SRCREV', 1)
+		if srcrev and parm["notrev"] in srcrev:
+			return False, "doesn't apply to revision"
+
+	return True, None
+
+python patch_do_patch() {
+	import oe.patch
+
 	patchsetmap = {
 		"patch": oe.patch.PatchTree,
 		"quilt": oe.patch.QuiltTree,
@@ -29,93 +122,15 @@ python patch_do_patch() {
  	rcls = resolvermap[d.getVar('PATCHRESOLVE', 1) or 'user']
 +	classes = {}
+
 	s = d.getVar('S', 1)
  	path = os.getenv('PATH')
 	os.putenv('PATH', d.getVar('PATH', 1))
 -	classes = {}
-
-	workdir = d.getVar('WORKDIR', 1)
-	for url in src_uri:
-		(type, host, path, user, pswd, parm) = bb.decodeurl(url)
-
-		local = None
-		base, ext = os.path.splitext(os.path.basename(path))
-		if ext in ('.gz', '.bz2', '.Z'):
-			local = os.path.join(workdir, base)
-			ext = os.path.splitext(base)[1]
-
-		if "apply" in parm:
-			apply = parm["apply"]
-			if apply != "yes":
-				if apply != "no":
-					bb.msg.warn(None, "Unsupported value '%s' for 'apply' url param in '%s', please use 'yes' or 'no'" % (apply, url))
-				continue
-		#elif "patch" in parm:
-			#bb.msg.warn(None, "Deprecated usage of 'patch' url param in '%s', please use 'apply={yes,no}'" % url)
-		elif ext not in (".diff", ".patch"):
-			continue
-
-		if not local:
-			url = bb.encodeurl((type, host, path, user, pswd, []))
-			local = os.path.join('/', bb.fetch2.localpath(url, d))
-		local = bb.data.expand(local, d)
-
-		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 = d.getVar('PN', 1)
-			srcdate = d.getVar('SRCDATE_%s' % pn, 1)
-			if not srcdate:
-				srcdate = d.getVar('SRCDATE', 1)
-
-			if srcdate == "now":
-				srcdate = d.getVar('DATE', 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 = d.getVar('SRCREV', 1)
-			if srcrev and srcrev < parm["minrev"]:
-				bb.note("Patch '%s' applies to later revisions" % pname)
-				continue
-
-		if "maxrev" in parm:
-			srcrev = d.getVar('SRCREV', 1)		
-			if srcrev and srcrev > parm["maxrev"]:
-				bb.note("Patch '%s' applies to earlier revisions" % pname)
-				continue
-
-		if "rev" in parm:
-			srcrev = d.getVar('SRCREV', 1)		
-			if srcrev and parm["rev"] not in srcrev:
-				bb.note("Patch '%s' doesn't apply to revision" % pname)
-				continue
-
-		if "notrev" in parm:
-			srcrev = d.getVar('SRCREV', 1)		
-			if srcrev and parm["notrev"] in srcrev:
-				bb.note("Patch '%s' doesn't apply to revision" % pname)
-				continue
+	for patch in src_patches(d):
+		_, _, local, _, _, parm = bb.decodeurl(patch)
  		if "patchdir" in parm:
 			patchdir = parm["patchdir"]
@@ -132,12 +147,11 @@ python patch_do_patch() {
 		else:
 			patchset, resolver = classes[patchdir]
 -		bb.note("Applying patch '%s' (%s)" % (pname, 

oe.path.format_display(local, d)))
+ bb.note("Applying patch '%s' (%s)" % (parm['patchname'], 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))
+ patchset.Import({"file":local, "strippath": parm['striplevel']}, True)
+ except Exception as exc:
+ bb.fatal(str(exc))
resolver.Resolve()
}
patch_do_patch[vardepsexclude] = "DATE SRCDATE PATCHRESOLVE"

Signature · 1 line
1.7.8
#1 lore raw
Quoted 4 lines · Christopher Larson

This is needed by the copyleft_compliance class, so it can emit series files for the patches, which greatly increases their usefulness to a user trying to
reconstruct the sources outside of OE.

.. or inside! As it turns out, I was writing something very similar to this to export
patches for processing with the linux-yocto build changes. I was about to send them out, but this looks drop in or even better.

I'm going to take this for a spin here and see if I can get it working with my other
changes.

Cheers,

Bruce

Quoted 252 lines

---
 meta/classes/patch.bbclass |  196
+++++++++++++++++++++++--------------------

 1 files changed, 105 insertions(+), 91 deletions(-)
meta/classes/patch.bbclass +0 -0
index ac6c1ce..454d9ce 100644
@@ -7,13 +7,106 @@ PATCHDEPENDENCY =

"${PATCHTOOL}-native:do_populate_sysroot"
 inherit terminal
 -python patch_do_patch() {
-       import oe.patch

meta/classes/patch.bbclass +18 -0
+def src_patches(d):
+       workdir = d.getVar('WORKDIR', True)
+       fetch = bb.fetch2.Fetch([], d)
+       patches = []
+       for url in fetch.urls:
+               local = patch_path(url, fetch, workdir)
+               if not local:
+                       continue
+
+               urldata = fetch.ud[url]
+               parm = urldata.parm
+               patchname = parm.get('pname') or os.path.basename(local)
+
+               apply, reason = should_apply(parm)
+               if not apply:
+                       if reason:
+                               bb.note("Patch %s %s" % (patchname, reason))
+                       continue

 -      src_uri = (d.getVar('SRC_URI', 1) or '').split()
-       if not src_uri:
+               patchparm = {'patchname': patchname}
+               if "striplevel" in parm:
+                       striplevel = parm["striplevel"]
+               elif "pnum" in parm:
+                       striplevel = parm["pnum"]
+               else:
+                       striplevel = '1'
+               patchparm['striplevel'] = striplevel

meta/classes/patch.bbclass +6 -0
+
+               patchdir = parm.get('patchdir')
+               if patchdir:
+                       patchparm['patchdir'] = patchdir
+
+               localurl = bb.encodeurl(('file', '', local, '', '',

patchparm))
+               patches.append(localurl)

meta/classes/patch.bbclass +5 -0
+
+       return patches
+
+def patch_path(url, fetch, workdir):
+       """Return the local path of a patch, or None if this isn't a

patch"""

meta/classes/patch.bbclass +13 -0
+
+       local = fetch.localpath(url)
+       base, ext = os.path.splitext(os.path.basename(local))
+       if ext in ('.gz', '.bz2', '.Z'):
+               local = os.path.join(workdir, base)
+               ext = os.path.splitext(base)[1]
+
+       urldata = fetch.ud[url]
+       if "apply" in urldata.parm:
+               apply = oe.types.boolean(urldata.parm["apply"])
+               if not apply:
+                       return
+       elif ext not in (".diff", ".patch"):

               return
 +      return local

meta/classes/patch.bbclass +45 -0
+
+def should_apply(parm):
+       """Determine if we should apply the given patch"""
+
+       if "mindate" in parm or "maxdate" in parm:
+               pn = d.getVar('PN', 1)
+               srcdate = d.getVar('SRCDATE_%s' % pn, 1)
+               if not srcdate:
+                       srcdate = d.getVar('SRCDATE', 1)
+
+               if srcdate == "now":
+                       srcdate = d.getVar('DATE', 1)
+
+               if "maxdate" in parm and parm["maxdate"] < srcdate:
+                       return False, 'is outdated'
+
+               if "mindate" in parm and parm["mindate"] > srcdate:
+                       return False, 'is predated'
+
+
+       if "minrev" in parm:
+               srcrev = d.getVar('SRCREV', 1)
+               if srcrev and srcrev < parm["minrev"]:
+                       return False, 'applies to later revisions'
+
+       if "maxrev" in parm:
+               srcrev = d.getVar('SRCREV', 1)
+               if srcrev and srcrev > parm["maxrev"]:
+                       return False, 'applies to earlier revisions'
+
+       if "rev" in parm:
+               srcrev = d.getVar('SRCREV', 1)
+               if srcrev and parm["rev"] not in srcrev:
+                       return False, "doesn't apply to revision"
+
+       if "notrev" in parm:
+               srcrev = d.getVar('SRCREV', 1)
+               if srcrev and parm["notrev"] in srcrev:
+                       return False, "doesn't apply to revision"
+
+       return True, None
+
+python patch_do_patch() {
+       import oe.patch
+

       patchsetmap = {
               "patch": oe.patch.PatchTree,
               "quilt": oe.patch.QuiltTree,

meta/classes/patch.bbclass +0 -0
@@ -29,93 +122,15 @@ python patch_do_patch() {

       rcls = resolvermap[d.getVar('PATCHRESOLVE', 1) or 'user']
 +      classes = {}
+
       s = d.getVar('S', 1)
       path = os.getenv('PATH')
       os.putenv('PATH', d.getVar('PATH', 1))
 -      classes = {}

meta/classes/patch.bbclass +0 -16
-
-       workdir = d.getVar('WORKDIR', 1)
-       for url in src_uri:
-               (type, host, path, user, pswd, parm) = bb.decodeurl(url)
-
-               local = None
-               base, ext = os.path.splitext(os.path.basename(path))
-               if ext in ('.gz', '.bz2', '.Z'):
-                       local = os.path.join(workdir, base)
-                       ext = os.path.splitext(base)[1]
-
-               if "apply" in parm:
-                       apply = parm["apply"]
-                       if apply != "yes":
-                               if apply != "no":
-                                       bb.msg.warn(None, "Unsupported value

'%s' for 'apply' url param in '%s', please use 'yes' or 'no'" % (apply, url))
-                               continue
-               #elif "patch" in parm:
-                       #bb.msg.warn(None, "Deprecated usage of 'patch' url param in '%s', please use 'apply={yes,no}'" % url)
-               elif ext not in (".diff", ".patch"):
-                       continue
-
-               if not local:
-                       url = bb.encodeurl((type, host, path, user, pswd, []))
-                       local = os.path.join('/', bb.fetch2.localpath(url, d))
-               local = bb.data.expand(local, d)
-
-               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'

meta/classes/patch.bbclass +0 -28
-
-               if "pname" in parm:
-                       pname = parm["pname"]
-               else:
-                       pname = os.path.basename(local)
-
-               if "mindate" in parm or "maxdate" in parm:
-                       pn = d.getVar('PN', 1)
-                       srcdate = d.getVar('SRCDATE_%s' % pn, 1)
-                       if not srcdate:
-                               srcdate = d.getVar('SRCDATE', 1)
-
-                       if srcdate == "now":
-                               srcdate = d.getVar('DATE', 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 = d.getVar('SRCREV', 1)
-                       if srcrev and srcrev < parm["minrev"]:
-                               bb.note("Patch '%s' applies to later

revisions" % pname)
-                               continue
-
-               if "maxrev" in parm:
-                       srcrev = d.getVar('SRCREV', 1)
-                       if srcrev and srcrev > parm["maxrev"]:
-                               bb.note("Patch '%s' applies to earlier revisions" % pname)
-                               continue
-
-               if "rev" in parm:
-                       srcrev = d.getVar('SRCREV', 1)
-                       if srcrev and parm["rev"] not in srcrev:
-                               bb.note("Patch '%s' doesn't apply to revision" % pname)
-                               continue
-
-               if "notrev" in parm:
-                       srcrev = d.getVar('SRCREV', 1)
-                       if srcrev and parm["notrev"] in srcrev:
-                               bb.note("Patch '%s' doesn't apply to revision" % pname)
-                               continue
+       for patch in src_patches(d):
+               _, _, local, _, _, parm = bb.decodeurl(patch) if "patchdir" in parm:
                       patchdir = parm["patchdir"]

meta/classes/patch.bbclass +0 -0
@@ -132,12 +147,11 @@ python patch_do_patch() {

               else:
                       patchset, resolver = classes[patchdir]
 -              bb.note("Applying patch '%s' (%s)" % (pname, oe.path.format_display(local, d)))
+               bb.note("Applying patch '%s' (%s)" % (parm['patchname'], 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))
+                       patchset.Import({"file":local, "strippath":
parm['striplevel']}, True)
+               except Exception as exc:
+                       bb.fatal(str(exc)) resolver.Resolve()
 }
 patch_do_patch[vardepsexclude] = "DATE SRCDATE PATCHRESOLVE" --
1.7.8

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"
#2 lore raw
In reply to Christopher Larson
Quoted 10 lines · Christopher Larson

This is needed by the copyleft_compliance class, so it can emit series files for the patches, which greatly increases their usefulness to a user trying to
reconstruct the sources outside of OE.

---
  meta/classes/patch.bbclass |  196 
+++++++++++++++++++++++--------------------
  1 files changed, 105 insertions(+), 91 deletions(-)

I have no objection to the change but the patch seems to be mangled somehow. Could you resend it or point me at a git tree please?

Cheers,

Richard

#3 lore raw
Quoted 6 lines · Richard Purdie
Quoted 5 lines · Christopher Larson

This is needed by the copyleft_compliance class, so it can emit series files for the patches, which greatly increases their usefulness to a user trying to
reconstruct the sources outside of OE.

Quoted 8 lines
Quoted 5 lines

---
  meta/classes/patch.bbclass |  196
+++++++++++++++++++++++--------------------

  1 files changed, 105 insertions(+), 91 deletions(-)

I have no objection to the change but the patch seems to be mangled somehow. Could you resend it or point me at a git tree please?

Sorry about that, my git send-email isn't working on my main dev machine at the moment, strange error from git that no one seems to recognize. used imap-send, and apparently tbird defaults to wrapping the same way the gmail UI does *eyeroll*. See
https://github.com/kergoth/oe-core/compare/patch-refactor

Signature · 1 line
Christopher Larson
#4 lore raw
In reply to Christopher Larson
Quoted 76 lines · Christopher Larson

This is needed by the copyleft_compliance class, so it can emit series files
for the patches, which greatly increases their usefulness to a user trying to
reconstruct the sources outside of OE.

---
meta/classes/patch.bbclass | 196
+++++++++++++++++++++++--------------------

1 files changed, 105 insertions(+), 91 deletions(-)
meta/classes/patch.bbclass +0 -0
index ac6c1ce..454d9ce 100644
@@ -7,13 +7,106 @@ PATCHDEPENDENCY =

"${PATCHTOOL}-native:do_populate_sysroot"
inherit terminal

meta/classes/patch.bbclass +51 -4
-python patch_do_patch() {
- import oe.patch
+def src_patches(d):
+ workdir = d.getVar('WORKDIR', True)
+ fetch = bb.fetch2.Fetch([], d)
+ patches = []
+ for url in fetch.urls:
+ local = patch_path(url, fetch, workdir)
+ if not local:
+ continue
+
+ urldata = fetch.ud[url]
+ parm = urldata.parm
+ patchname = parm.get('pname') or os.path.basename(local)
+
+ apply, reason = should_apply(parm)
+ if not apply:
+ if reason:
+ bb.note("Patch %s %s" % (patchname, reason))
+ continue
- src_uri = (d.getVar('SRC_URI', 1) or '').split()
- if not src_uri:
+ patchparm = {'patchname': patchname}
+ if "striplevel" in parm:
+ striplevel = parm["striplevel"]
+ elif "pnum" in parm:
+ striplevel = parm["pnum"]
+ else:
+ striplevel = '1'
+ patchparm['striplevel'] = striplevel
+
+ patchdir = parm.get('patchdir')
+ if patchdir:
+ patchparm['patchdir'] = patchdir
+
+ localurl = bb.encodeurl(('file', '', local, '', '', patchparm))
+ patches.append(localurl)
+
+ return patches
+
+def patch_path(url, fetch, workdir):
+ """Return the local path of a patch, or None if this isn't a patch"""
+
+ local = fetch.localpath(url)
+ base, ext = os.path.splitext(os.path.basename(local))
+ if ext in ('.gz', '.bz2', '.Z'):
+ local = os.path.join(workdir, base)
+ ext = os.path.splitext(base)[1]
+
+ urldata = fetch.ud[url]
+ if "apply" in urldata.parm:
+ apply = oe.types.boolean(urldata.parm["apply"])
+ if not apply:
+ return
+ elif ext not in (".diff", ".patch"):

return
+ return local

meta/classes/patch.bbclass

Quoted 2 lines
meta/classes/patch.bbclass +2 -0
+
+def should_apply(parm):

Do you need to pass d here?

I am seeing errors (see http://autobuilder.yoctoproject.org:8010/builders/nightly-x86/builds/295/steps/shell_14/logs/stdio)

Sau!

Quoted 161 lines

+ """Determine if we should apply the given patch"""

meta/classes/patch.bbclass +42 -0
+
+ if "mindate" in parm or "maxdate" in parm:
+ pn = d.getVar('PN', 1)
+ srcdate = d.getVar('SRCDATE_%s' % pn, 1)
+ if not srcdate:
+ srcdate = d.getVar('SRCDATE', 1)
+
+ if srcdate == "now":
+ srcdate = d.getVar('DATE', 1)
+
+ if "maxdate" in parm and parm["maxdate"] < srcdate:
+ return False, 'is outdated'
+
+ if "mindate" in parm and parm["mindate"] > srcdate:
+ return False, 'is predated'
+
+
+ if "minrev" in parm:
+ srcrev = d.getVar('SRCREV', 1)
+ if srcrev and srcrev < parm["minrev"]:
+ return False, 'applies to later revisions'
+
+ if "maxrev" in parm:
+ srcrev = d.getVar('SRCREV', 1)
+ if srcrev and srcrev > parm["maxrev"]:
+ return False, 'applies to earlier revisions'
+
+ if "rev" in parm:
+ srcrev = d.getVar('SRCREV', 1)
+ if srcrev and parm["rev"] not in srcrev:
+ return False, "doesn't apply to revision"
+
+ if "notrev" in parm:
+ srcrev = d.getVar('SRCREV', 1)
+ if srcrev and parm["notrev"] in srcrev:
+ return False, "doesn't apply to revision"
+
+ return True, None
+
+python patch_do_patch() {
+ import oe.patch
+

patchsetmap = {
"patch": oe.patch.PatchTree,
"quilt": oe.patch.QuiltTree,

meta/classes/patch.bbclass +0 -0
@@ -29,93 +122,15 @@ python patch_do_patch() {

rcls = resolvermap[d.getVar('PATCHRESOLVE', 1) or 'user']
+ classes = {}
+
s = d.getVar('S', 1)
path = os.getenv('PATH')
os.putenv('PATH', d.getVar('PATH', 1))
- classes = {}

meta/classes/patch.bbclass +0 -16
-
- workdir = d.getVar('WORKDIR', 1)
- for url in src_uri:
- (type, host, path, user, pswd, parm) = bb.decodeurl(url)
-
- local = None
- base, ext = os.path.splitext(os.path.basename(path))
- if ext in ('.gz', '.bz2', '.Z'):
- local = os.path.join(workdir, base)
- ext = os.path.splitext(base)[1]
-
- if "apply" in parm:
- apply = parm["apply"]
- if apply != "yes":
- if apply != "no":
- bb.msg.warn(None, "Unsupported value '%s' for 'apply' url param in

'%s', please use 'yes' or 'no'" % (apply, url))
- continue
- #elif "patch" in parm:
- #bb.msg.warn(None, "Deprecated usage of 'patch' url param in '%s', please use 'apply={yes,no}'" % url)
- elif ext not in (".diff", ".patch"):
- continue

meta/classes/patch.bbclass +0 -10
-
- if not local:
- url = bb.encodeurl((type, host, path, user, pswd, []))
- local = os.path.join('/', bb.fetch2.localpath(url, d))
- local = bb.data.expand(local, d)
-
- 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'

meta/classes/patch.bbclass +2 -47
-
- if "pname" in parm:
- pname = parm["pname"]
- else:
- pname = os.path.basename(local)
-
- if "mindate" in parm or "maxdate" in parm:
- pn = d.getVar('PN', 1)
- srcdate = d.getVar('SRCDATE_%s' % pn, 1)
- if not srcdate:
- srcdate = d.getVar('SRCDATE', 1)
-
- if srcdate == "now":
- srcdate = d.getVar('DATE', 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 = d.getVar('SRCREV', 1)
- if srcrev and srcrev < parm["minrev"]:
- bb.note("Patch '%s' applies to later revisions" % pname)
- continue
-
- if "maxrev" in parm:
- srcrev = d.getVar('SRCREV', 1)
- if srcrev and srcrev > parm["maxrev"]:
- bb.note("Patch '%s' applies to earlier revisions" % pname)
- continue
-
- if "rev" in parm:
- srcrev = d.getVar('SRCREV', 1)
- if srcrev and parm["rev"] not in srcrev:
- bb.note("Patch '%s' doesn't apply to revision" % pname)
- continue
-
- if "notrev" in parm:
- srcrev = d.getVar('SRCREV', 1)
- if srcrev and parm["notrev"] in srcrev:
- bb.note("Patch '%s' doesn't apply to revision" % pname)
- continue
+ for patch in src_patches(d):
+ _, _, local, _, _, parm = bb.decodeurl(patch)

if "patchdir" in parm:
patchdir = parm["patchdir"]

meta/classes/patch.bbclass +0 -0
@@ -132,12 +147,11 @@ python patch_do_patch() {

else:
patchset, resolver = classes[patchdir]
- bb.note("Applying patch '%s' (%s)" % (pname, oe.path.format_display(local, d)))
+ bb.note("Applying patch '%s' (%s)" % (parm['patchname'], 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))
+ patchset.Import({"file":local, "strippath": parm['striplevel']}, True)
+ except Exception as exc:
+ bb.fatal(str(exc))
resolver.Resolve()
}
patch_do_patch[vardepsexclude] = "DATE SRCDATE PATCHRESOLVE"

#5 lore raw
Quoted 4 lines · Saul Wold

Do you need to pass d here?

I am seeing errors (see
http://autobuilder.yoctoproject.org:8010/builders/nightly-x86/builds/295/steps/shell_14/logs/stdio)

Bah, indeed, apparently my testing didn't hit any recipes using minrev/maxrev/notrev. Will rework the patch. Grr.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#7 lore raw
Quoted 4 lines · Christopher Larson

Pushed an updated version of the patch-refactor commit that should fix this. --
Christopher Larson

Quoted 11 lines
Quoted 9 lines · Chris Larson
Quoted 4 lines · On Tue, Dec 27, 2011 at 1:33 PM, Saul Wold <[email protected]…

Do you need to pass d here?

I am seeing errors (see
http://autobuilder.yoctoproject.org:8010/builders/nightly-x86/builds/295/steps/shell_14/logs/stdio)

Bah, indeed, apparently my testing didn't hit any recipes using minrev/maxrev/notrev. Will rework the patch. Grr.

Merged the Updated version to OE-Core

Thanks
Sau!