summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/migrate_localcount.bbclass47
-rw-r--r--meta/conf/migrate_localcount.conf1
-rwxr-xr-xscripts/bitbake-prserv-tool32
3 files changed, 80 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"
diff --git a/scripts/bitbake-prserv-tool b/scripts/bitbake-prserv-tool
index f3855df0cc..4654e6d421 100755
--- a/scripts/bitbake-prserv-tool
+++ b/scripts/bitbake-prserv-tool
@@ -47,6 +47,35 @@ do_import ()
47 return $ret 47 return $ret
48} 48}
49 49
50do_migrate_localcount ()
51{
52 df=`bitbake -R conf/migrate_localcount.conf -e | \
53 grep ^LOCALCOUNT_DUMPFILE= | cut -f2 -d\"`
54 if [ "x${df}" == "x" ];
55 then
56 echo "LOCALCOUNT_DUMPFILE is not defined!"
57 return 1
58 fi
59
60 rm -rf $df
61 clean_cache
62 echo "Exporting LOCALCOUNT to AUTOINCs..."
63 bitbake -R conf/migrate_localcount.conf -p
64 [ ! $? -eq 0 ] && echo "Exporting failed!" && exit 1
65
66 echo "Importing generated AUTOINC entries..."
67 [ -e $df ] && do_import $df
68
69 if [ ! $? -eq 0 ]
70 then
71 echo "Migration from LOCALCOUNT to AUTOINCs failed!"
72 return 1
73 fi
74
75 echo "Migration from LOCALCOUNT to AUTOINCs succeeded!"
76 return 0
77}
78
50[ $# -eq 0 ] && help && exit 1 79[ $# -eq 0 ] && help && exit 1
51 80
52case $1 in 81case $1 in
@@ -56,6 +85,9 @@ export)
56import) 85import)
57 do_import $2 86 do_import $2
58 ;; 87 ;;
88migrate_localcount)
89 do_migrate_localcount
90 ;;
59*) 91*)
60 help 92 help
61 exit 1 93 exit 1