summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/migrate_localcount.bbclass47
-rw-r--r--meta/conf/migrate_localcount.conf1
2 files changed, 48 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
diff --git a/meta/conf/migrate_localcount.conf b/meta/conf/migrate_localcount.conf
new file mode 100644
index 0000000000..e486e03e5f
--- /dev/null
+++ b/meta/conf/migrate_localcount.conf
@@ -0,0 +1 @@
INHERIT += "migrate_localcount"