All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] patch.bbclass: abstract out logic that determines patches to apply
@ 2011-12-20 17:38 Christopher Larson
  2011-12-20 18:28 ` Bruce Ashfield
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Christopher Larson @ 2011-12-20 17:38 UTC (permalink / raw)
  To: openembedded-core

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.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
  meta/classes/patch.bbclass |  196 
+++++++++++++++++++++++--------------------
  1 files changed, 105 insertions(+), 91 deletions(-)

diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index ac6c1ce..454d9ce 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -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"
-- 
1.7.8




^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] patch.bbclass: abstract out logic that determines patches to apply
  2011-12-20 17:38 [PATCH] patch.bbclass: abstract out logic that determines patches to apply Christopher Larson
@ 2011-12-20 18:28 ` Bruce Ashfield
  2011-12-21 17:24 ` Richard Purdie
  2011-12-27 20:33 ` Saul Wold
  2 siblings, 0 replies; 8+ messages in thread
From: Bruce Ashfield @ 2011-12-20 18:28 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer

On Tue, Dec 20, 2011 at 12:38 PM, Christopher Larson <kergoth@gmail.com> wrote:
> 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

>
> Signed-off-by: Christopher Larson <chris_larson@mentor.com>
> ---
>  meta/classes/patch.bbclass |  196
> +++++++++++++++++++++++--------------------
>  1 files changed, 105 insertions(+), 91 deletions(-)
>
> diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
> index ac6c1ce..454d9ce 100644
> --- a/meta/classes/patch.bbclass
> +++ b/meta/classes/patch.bbclass
> @@ -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"
> --
> 1.7.8
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core



-- 
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] patch.bbclass: abstract out logic that determines patches to apply
  2011-12-20 17:38 [PATCH] patch.bbclass: abstract out logic that determines patches to apply Christopher Larson
  2011-12-20 18:28 ` Bruce Ashfield
@ 2011-12-21 17:24 ` Richard Purdie
  2011-12-27 17:31   ` Chris Larson
  2011-12-27 20:33 ` Saul Wold
  2 siblings, 1 reply; 8+ messages in thread
From: Richard Purdie @ 2011-12-21 17:24 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer

On Tue, 2011-12-20 at 10:38 -0700, Christopher Larson wrote:
> 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.
> 
> Signed-off-by: Christopher Larson <chris_larson@mentor.com>
> ---
>   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




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] patch.bbclass: abstract out logic that determines patches to apply
  2011-12-21 17:24 ` Richard Purdie
@ 2011-12-27 17:31   ` Chris Larson
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Larson @ 2011-12-27 17:31 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer

On Wed, Dec 21, 2011 at 10:24 AM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> On Tue, 2011-12-20 at 10:38 -0700, Christopher Larson wrote:
>> 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.
>>
>> Signed-off-by: Christopher Larson <chris_larson@mentor.com>
>> ---
>>   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
-- 
Christopher Larson



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] patch.bbclass: abstract out logic that determines patches to apply
  2011-12-20 17:38 [PATCH] patch.bbclass: abstract out logic that determines patches to apply Christopher Larson
  2011-12-20 18:28 ` Bruce Ashfield
  2011-12-21 17:24 ` Richard Purdie
@ 2011-12-27 20:33 ` Saul Wold
  2011-12-27 20:38   ` Chris Larson
  2 siblings, 1 reply; 8+ messages in thread
From: Saul Wold @ 2011-12-27 20:33 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer

On 12/20/2011 09:38 AM, Christopher Larson wrote:
> 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.
>
> Signed-off-by: Christopher Larson <chris_larson@mentor.com>
> ---
> meta/classes/patch.bbclass | 196
> +++++++++++++++++++++++--------------------
> 1 files changed, 105 insertions(+), 91 deletions(-)
>
> diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
> index ac6c1ce..454d9ce 100644
> --- a/meta/classes/patch.bbclass
> +++ b/meta/classes/patch.bbclass
> @@ -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):

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!

> + """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"



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] patch.bbclass: abstract out logic that determines patches to apply
  2011-12-27 20:33 ` Saul Wold
@ 2011-12-27 20:38   ` Chris Larson
  2011-12-28  3:18     ` Christopher Larson
  0 siblings, 1 reply; 8+ messages in thread
From: Chris Larson @ 2011-12-27 20:38 UTC (permalink / raw)
  To: Saul Wold; +Cc: Patches and discussions about the oe-core layer

On Tue, Dec 27, 2011 at 1:33 PM, Saul Wold <sgw@linux.intel.com> wrote:
> 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.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] patch.bbclass: abstract out logic that determines patches to apply
  2011-12-27 20:38   ` Chris Larson
@ 2011-12-28  3:18     ` Christopher Larson
  2012-01-03 23:52       ` Saul Wold
  0 siblings, 1 reply; 8+ messages in thread
From: Christopher Larson @ 2011-12-28  3:18 UTC (permalink / raw)
  To: Saul Wold; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 593 bytes --]

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


On Tuesday, December 27, 2011 at 1:38 PM, Chris Larson wrote:

> On Tue, Dec 27, 2011 at 1:33 PM, Saul Wold <sgw@linux.intel.com (mailto:sgw@linux.intel.com)> wrote:
> > 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.
> 
> 


[-- Attachment #2: Type: text/html, Size: 1166 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] patch.bbclass: abstract out logic that determines patches to apply
  2011-12-28  3:18     ` Christopher Larson
@ 2012-01-03 23:52       ` Saul Wold
  0 siblings, 0 replies; 8+ messages in thread
From: Saul Wold @ 2012-01-03 23:52 UTC (permalink / raw)
  To: Christopher Larson; +Cc: Patches and discussions about the oe-core layer

On 12/27/2011 07:18 PM, Christopher Larson wrote:
> Pushed an updated version of the patch-refactor commit that should fix this.
> --
> Christopher Larson
>
> On Tuesday, December 27, 2011 at 1:38 PM, Chris Larson wrote:
>
>> On Tue, Dec 27, 2011 at 1:33 PM, Saul Wold <sgw@linux.intel.com
>> <mailto:sgw@linux.intel.com>> wrote:
>>> 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!



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-04  0:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-20 17:38 [PATCH] patch.bbclass: abstract out logic that determines patches to apply Christopher Larson
2011-12-20 18:28 ` Bruce Ashfield
2011-12-21 17:24 ` Richard Purdie
2011-12-27 17:31   ` Chris Larson
2011-12-27 20:33 ` Saul Wold
2011-12-27 20:38   ` Chris Larson
2011-12-28  3:18     ` Christopher Larson
2012-01-03 23:52       ` Saul Wold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.