summaryrefslogtreecommitdiffstats
path: root/meta/classes/migrate_localcount.bbclass
diff options
context:
space:
mode:
authorConstantin Musca <constantinx.musca@intel.com>2013-01-22 11:39:30 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-01-22 16:01:32 +0000
commit8d6e55bf2192524bda84138b5356a2791adbbe61 (patch)
tree2e48407212a6df2311668ca0d531ea5d18cc89c7 /meta/classes/migrate_localcount.bbclass
parentcb902c35038b79f8e8ee115fb401f54dd6082d90 (diff)
downloadpoky-8d6e55bf2192524bda84138b5356a2791adbbe61.tar.gz
prserv: add LOCALCOUNT to AUTOINCs migration feature1.4_M3.rc1
- use migrate_localcount.bbclass to generate AUTOINC entries which are exported to LOCALCOUNT_DUMPFILE - import the generated AUTOINC entries - one can migrate LOCALCOUNT to AUTOINC by executing: bitbake-prserv-tool migrate_localcount [YOCTO #3071] (From OE-Core rev: ffab86f13cafb10d8d6273b6af8cd9a3c84eae20) Signed-off-by: Constantin Musca <constantinx.musca@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/migrate_localcount.bbclass')
-rw-r--r--meta/classes/migrate_localcount.bbclass47
1 files changed, 47 insertions, 0 deletions
diff --git a/meta/classes/migrate_localcount.bbclass b/meta/classes/migrate_localcount.bbclass
new file mode 100644
index 0000000000..59f14e8a34
--- /dev/null
+++ b/meta/classes/migrate_localcount.bbclass
@@ -0,0 +1,47 @@
1PRSERV_DUMPDIR ??= "${LOG_DIR}/db"
2LOCALCOUNT_DUMPFILE ??= "${PRSERV_DUMPDIR}/prserv-localcount-exports.inc"
3
4python migrate_localcount_handler () {
5 import bb.event
6 if not e.data:
7 return
8
9 if isinstance(e, bb.event.RecipeParsed):
10 pv = e.data.getVar('PV', True)
11 if not 'AUTOINC' in pv:
12 return
13
14 localcounts = bb.persist_data.persist('BB_URI_LOCALCOUNT', e.data)
15 pn = e.data.getVar('PN', True)
16 revs = localcounts.get_by_pattern('%%-%s_rev' % pn)
17 counts = localcounts.get_by_pattern('%%-%s_count' % pn)
18 if not revs or not counts:
19 return
20
21 srcrev = bb.fetch2.get_srcrev(e.data)
22 bpv = pv[:pv.find(srcrev)]
23
24 if len(revs) != len(counts):
25 bb.warn("The number of revs and localcounts don't match in %s" % pn)
26 return
27
28 version = 'AUTOINC-%s-%s' % (pn, bpv)
29 pkgarch = e.data.getVar('PACKAGE_ARCH', True)
30 value = max(int(count) for count in counts)
31
32 if len(revs) == 1:
33 if srcrev != ('AUTOINC+%s' % revs[0]):
34 value += 1
35 else:
36 value += 1
37
38 bb.utils.mkdirhier(e.data.getVar('PRSERV_DUMPDIR', True))
39 df = e.data.getVar('LOCALCOUNT_DUMPFILE', True)
40 flock = bb.utils.lockfile("%s.lock" % df)
41 with open(df, 'a') as fd:
42 fd.write('PRAUTO$%s$%s$%s = "%s"\n' %
43 (version, pkgarch, srcrev, str(value)))
44 bb.utils.unlockfile(flock)
45}
46
47addhandler migrate_localcount_handler