Merge remote-tracking branch 'agl/sandbox/locust2001/rocko' into HEAD
[AGL/meta-agl.git] / meta-app-framework / recipes-security / cynara / cynara_git.bbappend
1 FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
2 SRC_URI_append = " file://0001-gcc-7-requires-include-functional-for-std-function.patch"
3
4 CXXFLAGS_append = " -Wimplicit-fallthrough=0"
5
6 pkg_postinst_${PN} () {
7    # Fail on error.
8    set -e
9
10    # It would be nice to run the code below while building an image,
11    # but currently the calls to cynara-db-chsgen (a binary) in
12    # cynara-db-migration (a script) prevent that. Rely instead
13    # on OE's support for running failed postinst scripts at first boot.
14    if [ x"$D" != "x" ]; then
15       exit 1
16    fi
17
18    mkdir -p $D${sysconfdir}/cynara
19    ${CHSMACK} -a System $D${sysconfdir}/cynara
20
21    # Strip git patch level information, the version comparison code
22    # in cynara-db-migration only expect major.minor.patch version numbers.
23    VERSION=${@d.getVar('PV',d,1).split('+git')[0]}
24    if [ -d $D${localstatedir}/cynara ] ; then
25       # upgrade
26       echo "NOTE: updating cynara DB to version $VERSION"
27       $D${sbindir}/cynara-db-migration upgrade -f 0.0.0 -t $VERSION
28    else
29       # install
30       echo "NOTE: creating cynara DB for version $VERSION"
31       mkdir -p $D${localstatedir}/cynara
32       ${CHSMACK} -a System $D${localstatedir}/cynara
33       $D${sbindir}/cynara-db-migration install -t $VERSION
34    fi
35
36    # Workaround for systemd.bbclass issue: it would call
37    # "systemctl start" without "--no-block", but because
38    # the service is not ready to run at the time when
39    # this scripts gets executed by run-postinsts.service,
40    # booting deadlocks.
41    echo "NOTE: enabling and starting cynara service"
42    systemctl enable cynara
43    systemctl start --no-block cynara
44 }