Skip to contentSkip to conversation

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

PATCH Superseded Martin Jansa 2 participants 4 messages Apr 1, 2013 – Apr 3, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 buildhistory: record tag names and show warning when the same tag corresponds to different revision

* 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

---
 meta/classes/buildhistory.bbclass | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
meta/classes/buildhistory.bbclass +20 -0
index 82d0bf8..760075f 100644
@@ -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())
Signature · 1 line
1.8.1.5
#1 lore raw
Quoted 34 lines · Martin Jansa

* 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

---
 meta/classes/buildhistory.bbclass | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
meta/classes/buildhistory.bbclass +9 -0
index 82d0bf8..760075f 100644
@@ -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_'):

meta/classes/buildhistory.bbclass python do_write_srcrev() { · line 577

Quoted 10 lines
meta/classes/buildhistory.bbclass +5 -0
+                        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"

Quoted 16 lines
meta/classes/buildhistory.bbclass +6 -0
@@ -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())
Signature · 1 line
1.8.1.5
Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#2 lore raw

PATCH v2 1/1 buildhistory: record tag names and show warning when the same tag corresponds to different revision

* 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

---
 meta/classes/buildhistory.bbclass | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)
meta/classes/buildhistory.bbclass +25 -4
index 82d0bf8..8c9f794 100644
@@ -538,24 +538,38 @@ def _get_srcrev_values(d):
             scms.append(u)
 
     autoinc_templ = 'AUTOINC+'
-    dict = {}
+    dict_srcrevs = {}
+    dict_tag_srcrevs = {}
     for scm in scms:
         ud = urldata[scm]
         for name in ud.names:
             rev = ud.method.sortable_revision(scm, ud, d, name)
             if rev.startswith(autoinc_templ):
                 rev = rev[len(autoinc_templ):]
-            dict[name] = rev
-    return dict
+            dict_srcrevs[name] = rev
+            if 'tag' in ud.parm:
+                tag = ud.parm['tag'];
+                key = name+'_'+tag
+                dict_tag_srcrevs[key] = rev
+    return (dict_srcrevs, dict_tag_srcrevs)
 
 python do_write_srcrev() {
     pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
     srcrevfile = os.path.join(pkghistdir, 'latest_srcrev')
 
-    srcrevs = _get_srcrev_values(d)
+    srcrevs, tag_srcrevs = _get_srcrev_values(d)
     if srcrevs:
         if not os.path.exists(pkghistdir):
             os.makedirs(pkghistdir)
+        old_tag_srcrevs = {}
+        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('# tag_', '').strip()
+                        value = value.replace('"', '').strip()
+                        old_tag_srcrevs[key] = value
         with open(srcrevfile, 'w') as f:
             orig_srcrev = d.getVar('SRCREV', False) or 'INVALID'
             if orig_srcrev != 'INVALID':
@@ -568,6 +582,13 @@ python do_write_srcrev() {
                     f.write('SRCREV_%s = "%s"\n' % (name, srcrev))
             else:
                 f.write('SRCREV = "%s"\n' % srcrevs.itervalues().next())
+            if len(tag_srcrevs) > 0:
+                for name, srcrev in tag_srcrevs.items():
+                    f.write('# tag_%s = "%s"\n' % (name, srcrev))
+                    if name in old_tag_srcrevs and old_tag_srcrevs[name] != srcrev:
+                        pkg = d.getVar('PN', True)
+                        bb.warn("Revision for tag %s in package %s was changed since last build (from %s to %s)" % (name, pkg, old_tag_srcrevs[name], srcrev))
+
     else:
         if os.path.exists(srcrevfile):
             os.remove(srcrevfile)
Signature · 1 line
1.8.1.5
Acked-by on v2 1/1
#3 lore raw
Quoted 69 lines · On Wednesday 03 April 2013 10:49:36 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

---
 meta/classes/buildhistory.bbclass | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/meta/classes/buildhistory.bbclass index 82d0bf8..8c9f794 100644

meta/classes/buildhistory.bbclass +23 -4
@@ -538,24 +538,38 @@ def _get_srcrev_values(d):
             scms.append(u)
 
     autoinc_templ = 'AUTOINC+'
-    dict = {}
+    dict_srcrevs = {}
+    dict_tag_srcrevs = {}
     for scm in scms:
         ud = urldata[scm]
         for name in ud.names:
             rev = ud.method.sortable_revision(scm, ud, d, name)
             if rev.startswith(autoinc_templ):
                 rev = rev[len(autoinc_templ):]
-            dict[name] = rev
-    return dict
+            dict_srcrevs[name] = rev
+            if 'tag' in ud.parm:
+                tag = ud.parm['tag'];
+                key = name+'_'+tag
+                dict_tag_srcrevs[key] = rev
+    return (dict_srcrevs, dict_tag_srcrevs)
 
 python do_write_srcrev() {
     pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
     srcrevfile = os.path.join(pkghistdir, 'latest_srcrev')
 
-    srcrevs = _get_srcrev_values(d)
+    srcrevs, tag_srcrevs = _get_srcrev_values(d)
     if srcrevs:
         if not os.path.exists(pkghistdir):
             os.makedirs(pkghistdir)
+        old_tag_srcrevs = {}
+        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('# tag_', '').strip()
+                        value = value.replace('"', '').strip()
+                        old_tag_srcrevs[key] = value
         with open(srcrevfile, 'w') as f:
             orig_srcrev = d.getVar('SRCREV', False) or 'INVALID'
             if orig_srcrev != 'INVALID':
@@ -568,6 +582,13 @@ python do_write_srcrev() {
                     f.write('SRCREV_%s = "%s"\n' % (name, srcrev))
             else:
                 f.write('SRCREV = "%s"\n' % srcrevs.itervalues().next())
+            if len(tag_srcrevs) > 0:
+                for name, srcrev in tag_srcrevs.items():
+                    f.write('# tag_%s = "%s"\n' % (name, srcrev))
+                    if name in old_tag_srcrevs and old_tag_srcrevs[name] !=
 srcrev: +                        pkg = d.getVar('PN', True)
+                        bb.warn("Revision for tag %s in package %s was
 changed since last build (from %s to %s)" % (name, pkg,
Quoted 4 lines

old_tag_srcrevs[name], srcrev)) +
else:
if os.path.exists(srcrevfile):
os.remove(srcrevfile)

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre