Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | PRSERV_DUMPOPT_VERSION = "${PRAUTOINX}" |
| 2 | PRSERV_DUMPOPT_PKGARCH = "" |
| 3 | PRSERV_DUMPOPT_CHECKSUM = "" |
| 4 | PRSERV_DUMPOPT_COL = "0" |
| 5 | |
| 6 | PRSERV_DUMPDIR ??= "${LOG_DIR}/db" |
| 7 | PRSERV_DUMPFILE ??= "${PRSERV_DUMPDIR}/prserv.inc" |
| 8 | |
| 9 | python prexport_handler () { |
| 10 | import bb.event |
| 11 | if not e.data: |
| 12 | return |
| 13 | |
| 14 | if isinstance(e, bb.event.RecipeParsed): |
| 15 | import oe.prservice |
| 16 | #get all PR values for the current PRAUTOINX |
| 17 | ver = e.data.getVar('PRSERV_DUMPOPT_VERSION', True) |
| 18 | ver = ver.replace('%','-') |
| 19 | retval = oe.prservice.prserv_dump_db(e.data) |
| 20 | if not retval: |
| 21 | bb.fatal("prexport_handler: export failed!") |
| 22 | (metainfo, datainfo) = retval |
| 23 | if not datainfo: |
| 24 | bb.warn("prexport_handler: No AUTOPR values found for %s" % ver) |
| 25 | return |
| 26 | oe.prservice.prserv_export_tofile(e.data, None, datainfo, False) |
| 27 | if 'AUTOINC' in ver: |
| 28 | import re |
| 29 | srcpv = bb.fetch2.get_srcrev(e.data) |
| 30 | base_ver = "AUTOINC-%s" % ver[:ver.find(srcpv)] |
| 31 | e.data.setVar('PRSERV_DUMPOPT_VERSION', base_ver) |
| 32 | retval = oe.prservice.prserv_dump_db(e.data) |
| 33 | if not retval: |
| 34 | bb.fatal("prexport_handler: export failed!") |
| 35 | (metainfo, datainfo) = retval |
| 36 | oe.prservice.prserv_export_tofile(e.data, None, datainfo, False) |
| 37 | elif isinstance(e, bb.event.ParseStarted): |
| 38 | import bb.utils |
| 39 | import oe.prservice |
| 40 | oe.prservice.prserv_check_avail(e.data) |
| 41 | #remove dumpfile |
| 42 | bb.utils.remove(e.data.getVar('PRSERV_DUMPFILE', True)) |
| 43 | elif isinstance(e, bb.event.ParseCompleted): |
| 44 | import oe.prservice |
| 45 | #dump meta info of tables |
| 46 | d = e.data.createCopy() |
| 47 | d.setVar('PRSERV_DUMPOPT_COL', "1") |
| 48 | retval = oe.prservice.prserv_dump_db(d) |
| 49 | if not retval: |
| 50 | bb.error("prexport_handler: export failed!") |
| 51 | return |
| 52 | (metainfo, datainfo) = retval |
| 53 | oe.prservice.prserv_export_tofile(d, metainfo, None, True) |
| 54 | |
| 55 | } |
| 56 | |
| 57 | addhandler prexport_handler |
| 58 | prexport_handler[eventmask] = "bb.event.RecipeParsed bb.event.ParseStarted bb.event.ParseCompleted" |