blob: e5098e3308b9a3ad198047b92d6e447e70ac2ee7 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007PRSERV_DUMPOPT_VERSION = "${PRAUTOINX}"
8PRSERV_DUMPOPT_PKGARCH = ""
9PRSERV_DUMPOPT_CHECKSUM = ""
10PRSERV_DUMPOPT_COL = "0"
11
12PRSERV_DUMPDIR ??= "${LOG_DIR}/db"
13PRSERV_DUMPFILE ??= "${PRSERV_DUMPDIR}/prserv.inc"
14
15python prexport_handler () {
16 import bb.event
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050017 if not e.data or bb.data.inherits_class('native', e.data) or \
18 bb.data.inherits_class('crosssdk', e.data):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 return
20
21 if isinstance(e, bb.event.RecipeParsed):
22 import oe.prservice
23 #get all PR values for the current PRAUTOINX
Brad Bishop6e60e8b2018-02-01 10:27:11 -050024 ver = e.data.getVar('PRSERV_DUMPOPT_VERSION')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025 ver = ver.replace('%','-')
26 retval = oe.prservice.prserv_dump_db(e.data)
27 if not retval:
28 bb.fatal("prexport_handler: export failed!")
29 (metainfo, datainfo) = retval
30 if not datainfo:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050031 bb.note("prexport_handler: No AUTOPR values found for %s" % ver)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032 return
33 oe.prservice.prserv_export_tofile(e.data, None, datainfo, False)
34 if 'AUTOINC' in ver:
35 import re
36 srcpv = bb.fetch2.get_srcrev(e.data)
37 base_ver = "AUTOINC-%s" % ver[:ver.find(srcpv)]
38 e.data.setVar('PRSERV_DUMPOPT_VERSION', base_ver)
39 retval = oe.prservice.prserv_dump_db(e.data)
40 if not retval:
41 bb.fatal("prexport_handler: export failed!")
42 (metainfo, datainfo) = retval
43 oe.prservice.prserv_export_tofile(e.data, None, datainfo, False)
44 elif isinstance(e, bb.event.ParseStarted):
45 import bb.utils
46 import oe.prservice
47 oe.prservice.prserv_check_avail(e.data)
48 #remove dumpfile
Brad Bishop6e60e8b2018-02-01 10:27:11 -050049 bb.utils.remove(e.data.getVar('PRSERV_DUMPFILE'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050 elif isinstance(e, bb.event.ParseCompleted):
51 import oe.prservice
52 #dump meta info of tables
53 d = e.data.createCopy()
54 d.setVar('PRSERV_DUMPOPT_COL', "1")
55 retval = oe.prservice.prserv_dump_db(d)
56 if not retval:
57 bb.error("prexport_handler: export failed!")
58 return
59 (metainfo, datainfo) = retval
60 oe.prservice.prserv_export_tofile(d, metainfo, None, True)
61
62}
63
64addhandler prexport_handler
65prexport_handler[eventmask] = "bb.event.RecipeParsed bb.event.ParseStarted bb.event.ParseCompleted"