Patchwork buildhistory: record tag names and show warning when the same tag corresponds to different revision

login
register
mail settings
Submitter Martin Jansa
Date April 1, 2013, 12:50 p.m.
Message ID <1364820644-9373-1-git-send-email-Martin.Jansa@gmail.com>
Download mbox | patch
Permalink /patch/47203/
State Accepted, archived
Headers show

Comments

Martin Jansa - April 1, 2013, 12:50 p.m.
* persistent cache records tag-srcrev mappings, but is not shared between builders
* when tag is moved in remote repo, all builders should rebuild the component to
  use the same source, show warning when revision is different than what was used
  in last build

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 meta/classes/buildhistory.bbclass | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
Martin Jansa - April 3, 2013, 8:24 a.m.
On Mon, Apr 01, 2013 at 02:50:44PM +0200, Martin Jansa wrote:
> * persistent cache records tag-srcrev mappings, but is not shared between builders
> * when tag is moved in remote repo, all builders should rebuild the component to
>   use the same source, show warning when revision is different than what was used
>   in last build
> 
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  meta/classes/buildhistory.bbclass | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
> index 82d0bf8..760075f 100644
> --- a/meta/classes/buildhistory.bbclass
> +++ b/meta/classes/buildhistory.bbclass
> @@ -546,6 +546,10 @@ def _get_srcrev_values(d):
>              if rev.startswith(autoinc_templ):
>                  rev = rev[len(autoinc_templ):]
>              dict[name] = rev
> +            if 'tag' in ud.parm:
> +                tag = ud.parm['tag'];
> +                key = 'tag_'+name+'_'+tag
> +                dict[key] = rev
>      return dict
>  
>  python do_write_srcrev() {
> @@ -556,8 +560,18 @@ python do_write_srcrev() {
>      if srcrevs:
>          if not os.path.exists(pkghistdir):
>              os.makedirs(pkghistdir)
> +        data = {}
> +        if os.path.exists(srcrevfile):
> +            with open(srcrevfile) as f:
> +                for line in f:
> +                    if line.startswith('# tag_'):
> +                        key, value = line.split("=", 1)
> +                        key = key.replace('# ', '').strip()
> +                        value = value.replace('"', '').strip()
> +                        data[key] = value
>          with open(srcrevfile, 'w') as f:
>              orig_srcrev = d.getVar('SRCREV', False) or 'INVALID'
> +            pkg = d.getVar('PN', True)
>              if orig_srcrev != 'INVALID':
>                  f.write('# SRCREV = "%s"\n' % orig_srcrev)
>              if len(srcrevs) > 1:

Please hold this patch, this len(srcrevs) doesn't work anymore to detect
multiple names (when there is another line for tag-srcrev).

So it's causing changes like this for every recipe with 1 git repo in
SRC_URI with tag parameter:
-SRCREV = "594dbb8992b42a33f78b57c15f194fae0923a7f8"
+SRCREV_default = "594dbb8992b42a33f78b57c15f194fae0923a7f8"

> @@ -565,6 +579,12 @@ python do_write_srcrev() {
>                      orig_srcrev = d.getVar('SRCREV_%s' % name, False)
>                      if orig_srcrev:
>                          f.write('# SRCREV_%s = "%s"\n' % (name, orig_srcrev))
> +                    if name.startswith('tag_'):
> +                        f.write('# %s = "%s"\n' % (name, srcrev))
> +                        if name in data and data[name] != srcrev:
> +                            bb.warn("Revision for tag %s in package %s was changed since last build (from %s to %s)" % (name, pkg, data[name], srcrev))
> +                        continue
> +
>                      f.write('SRCREV_%s = "%s"\n' % (name, srcrev))
>              else:
>                  f.write('SRCREV = "%s"\n' % srcrevs.itervalues().next())
> -- 
> 1.8.1.5
>

Patch

diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 82d0bf8..760075f 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -546,6 +546,10 @@  def _get_srcrev_values(d):
             if rev.startswith(autoinc_templ):
                 rev = rev[len(autoinc_templ):]
             dict[name] = rev
+            if 'tag' in ud.parm:
+                tag = ud.parm['tag'];
+                key = 'tag_'+name+'_'+tag
+                dict[key] = rev
     return dict
 
 python do_write_srcrev() {
@@ -556,8 +560,18 @@  python do_write_srcrev() {
     if srcrevs:
         if not os.path.exists(pkghistdir):
             os.makedirs(pkghistdir)
+        data = {}
+        if os.path.exists(srcrevfile):
+            with open(srcrevfile) as f:
+                for line in f:
+                    if line.startswith('# tag_'):
+                        key, value = line.split("=", 1)
+                        key = key.replace('# ', '').strip()
+                        value = value.replace('"', '').strip()
+                        data[key] = value
         with open(srcrevfile, 'w') as f:
             orig_srcrev = d.getVar('SRCREV', False) or 'INVALID'
+            pkg = d.getVar('PN', True)
             if orig_srcrev != 'INVALID':
                 f.write('# SRCREV = "%s"\n' % orig_srcrev)
             if len(srcrevs) > 1:
@@ -565,6 +579,12 @@  python do_write_srcrev() {
                     orig_srcrev = d.getVar('SRCREV_%s' % name, False)
                     if orig_srcrev:
                         f.write('# SRCREV_%s = "%s"\n' % (name, orig_srcrev))
+                    if name.startswith('tag_'):
+                        f.write('# %s = "%s"\n' % (name, srcrev))
+                        if name in data and data[name] != srcrev:
+                            bb.warn("Revision for tag %s in package %s was changed since last build (from %s to %s)" % (name, pkg, data[name], srcrev))
+                        continue
+
                     f.write('SRCREV_%s = "%s"\n' % (name, srcrev))
             else:
                 f.write('SRCREV = "%s"\n' % srcrevs.itervalues().next())