Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | PRSERV_DUMPOPT_VERSION = "${PRAUTOINX}" |
| 8 | PRSERV_DUMPOPT_PKGARCH = "" |
| 9 | PRSERV_DUMPOPT_CHECKSUM = "" |
| 10 | PRSERV_DUMPOPT_COL = "0" |
| 11 | |
| 12 | PRSERV_DUMPDIR ??= "${LOG_DIR}/db" |
| 13 | PRSERV_DUMPFILE ??= "${PRSERV_DUMPDIR}/prserv.inc" |
| 14 | |
| 15 | python prexport_handler () { |
| 16 | import bb.event |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 17 | if not e.data or bb.data.inherits_class('native', e.data) or \ |
| 18 | bb.data.inherits_class('crosssdk', e.data): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 19 | return |
| 20 | |
| 21 | if isinstance(e, bb.event.RecipeParsed): |
| 22 | import oe.prservice |
| 23 | #get all PR values for the current PRAUTOINX |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 24 | ver = e.data.getVar('PRSERV_DUMPOPT_VERSION') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 31 | bb.note("prexport_handler: No AUTOPR values found for %s" % ver) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 49 | bb.utils.remove(e.data.getVar('PRSERV_DUMPFILE')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 50 | 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 | |
| 64 | addhandler prexport_handler |
| 65 | prexport_handler[eventmask] = "bb.event.RecipeParsed bb.event.ParseStarted bb.event.ParseCompleted" |