summaryrefslogtreecommitdiffstats
path: root/meta/classes/migrate_localcount.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-12 16:31:57 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-14 11:55:47 (GMT)
commit53841ce521d44c0c9cca512675a12f81a491fe52 (patch)
tree98a2ca75581f4bb488e43087b6b9128017aac135 /meta/classes/migrate_localcount.bbclass
parent98abb113a02a4504ae969dbaf9844ab6539dcdb8 (diff)
downloadpoky-53841ce521d44c0c9cca512675a12f81a491fe52.tar.gz
classes/conf: Add eventmasks for event handlers
Now that bitbake supports masking events for event handlers, lets use this so event handlers are only called for events they care about. This lets us simplify the code indentation a bit at least as well as mildly improving the event handling performance. (From OE-Core rev: bff73743280f9eafebe4591f7368ead91a4eb74d) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/migrate_localcount.bbclass')
-rw-r--r--meta/classes/migrate_localcount.bbclass68
1 files changed, 34 insertions, 34 deletions
diff --git a/meta/classes/migrate_localcount.bbclass b/meta/classes/migrate_localcount.bbclass
index 3916ad4..aa0df8b 100644
--- a/meta/classes/migrate_localcount.bbclass
+++ b/meta/classes/migrate_localcount.bbclass
@@ -6,41 +6,41 @@ python migrate_localcount_handler () {
6 if not e.data: 6 if not e.data:
7 return 7 return
8 8
9 if isinstance(e, bb.event.RecipeParsed): 9 pv = e.data.getVar('PV', True)
10 pv = e.data.getVar('PV', True) 10 if not 'AUTOINC' in pv:
11 if not 'AUTOINC' in pv: 11 return
12 return 12
13 13 localcounts = bb.persist_data.persist('BB_URI_LOCALCOUNT', e.data)
14 localcounts = bb.persist_data.persist('BB_URI_LOCALCOUNT', e.data) 14 pn = e.data.getVar('PN', True)
15 pn = e.data.getVar('PN', True) 15 revs = localcounts.get_by_pattern('%%-%s_rev' % pn)
16 revs = localcounts.get_by_pattern('%%-%s_rev' % pn) 16 counts = localcounts.get_by_pattern('%%-%s_count' % pn)
17 counts = localcounts.get_by_pattern('%%-%s_count' % pn) 17 if not revs or not counts:
18 if not revs or not counts: 18 return
19 return
20
21 if len(revs) != len(counts):
22 bb.warn("The number of revs and localcounts don't match in %s" % pn)
23 return
24
25 version = e.data.getVar('PRAUTOINX', True)
26 srcrev = bb.fetch2.get_srcrev(e.data)
27 base_ver = 'AUTOINC-%s' % version[:version.find(srcrev)]
28 pkgarch = e.data.getVar('PACKAGE_ARCH', True)
29 value = max(int(count) for count in counts)
30
31 if len(revs) == 1:
32 if srcrev != ('AUTOINC+%s' % revs[0]):
33 value += 1
34 else:
35 value += 1
36 19
37 bb.utils.mkdirhier(e.data.getVar('PRSERV_DUMPDIR', True)) 20 if len(revs) != len(counts):
38 df = e.data.getVar('LOCALCOUNT_DUMPFILE', True) 21 bb.warn("The number of revs and localcounts don't match in %s" % pn)
39 flock = bb.utils.lockfile("%s.lock" % df) 22 return
40 with open(df, 'a') as fd: 23
41 fd.write('PRAUTO$%s$%s$%s = "%s"\n' % 24 version = e.data.getVar('PRAUTOINX', True)
42 (base_ver, pkgarch, srcrev, str(value))) 25 srcrev = bb.fetch2.get_srcrev(e.data)
43 bb.utils.unlockfile(flock) 26 base_ver = 'AUTOINC-%s' % version[:version.find(srcrev)]
27 pkgarch = e.data.getVar('PACKAGE_ARCH', True)
28 value = max(int(count) for count in counts)
29
30 if len(revs) == 1:
31 if srcrev != ('AUTOINC+%s' % revs[0]):
32 value += 1
33 else:
34 value += 1
35
36 bb.utils.mkdirhier(e.data.getVar('PRSERV_DUMPDIR', True))
37 df = e.data.getVar('LOCALCOUNT_DUMPFILE', True)
38 flock = bb.utils.lockfile("%s.lock" % df)
39 with open(df, 'a') as fd:
40 fd.write('PRAUTO$%s$%s$%s = "%s"\n' %
41 (base_ver, pkgarch, srcrev, str(value)))
42 bb.utils.unlockfile(flock)
44} 43}
45 44
46addhandler migrate_localcount_handler 45addhandler migrate_localcount_handler
46migrate_localcount_handler[eventmask] = "bb.event.RecipeParsed"