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