1 DESCRIPTION = "Cynara service with client libraries"
3 LIC_FILES_CHKSUM = "file://LICENSE;md5=86d3f3a95c324c9479bd8986968f4327;beginline=3"
16 # Use debug mode to increase logging. Beware, also compiles with less optimization
17 # and thus has to disable FORTIFY_SOURCE below.
18 PACKAGECONFIG[debug] = "-DCMAKE_BUILD_TYPE=DEBUG,-DCMAKE_BUILD_TYPE=RELEASE,libunwind elfutils"
23 -DCYNARA_STATE_PATH=\\\\\"${localstatedir}/cynara/\\\\\" \
24 -DCYNARA_LIB_PATH=\\\\\"${prefix}/lib/cynara/\\\\\" \
25 -DCYNARA_TESTS_DIR=\\\\\"${prefix}/share/cynara/tests/\\\\\" \
26 -DCYNARA_CONFIGURATION_DIR=\\\\\"${sysconfdir}/cynara/\\\\\" \
27 ${@bb.utils.contains('PACKAGECONFIG', 'debug', '-Wp,-U_FORTIFY_SOURCE', '', d)} \
31 -DCMAKE_VERBOSE_MAKEFILE=ON \
32 -DBUILD_WITH_SYSTEMD=ON \
33 -DSYSTEMD_UNIT_DIR=${systemd_unitdir}/system \
34 -DSOCKET_DIR=/run/cynara \
37 # Explicitly package empty directory. Otherwise Cynara prints warnings
39 # cyad[198]: Couldn't scan for plugins in </usr/lib/cynara/plugin/service/> : <No such file or directory>
40 FILES_${PN}_append = " \
41 ${libdir}/cynara/plugin/service \
42 ${libdir}/cynara/plugin/client \
45 # Testing depends on gmock and gtest. They can be found in meta-oe
46 # and are not necessarily available, so this feature is off by default.
47 # If gmock from meta-oe is used, then a workaround is needed to avoid
48 # a link error (libgmock.a calls pthread functions without libpthread
49 # being listed in the .pc file).
50 PACKAGECONFIG[tests] = "-DBUILD_TESTS:BOOL=ON,-DBUILD_TESTS:BOOL=OFF,gmock gtest,"
51 SRC_URI_append = "${@bb.utils.contains('PACKAGECONFIG', 'tests', ' file://gmock-pthread-linking.patch file://run-ptest', '', d)}"
53 # Will be empty if no tests were built.
55 FILES_${PN}-ptest += "${bindir}/cynara-tests ${bindir}/cynara-db-migration-tests ${datadir}/cynara/tests"
57 if ${@bb.utils.contains('PACKAGECONFIG', 'tests', 'true', 'false', d)}; then
58 mkdir -p ${D}/${datadir}/cynara/tests
59 cp -r ${S}/test/db/* ${D}/${datadir}/cynara/tests
63 do_compile_prepend () {
64 # en_US.UTF8 is not available, causing cynara-tests parser.getKeyAndValue to fail.
65 # Submitted upstream: https://github.com/Samsung/cynara/issues/10
66 sed -i -e 's/std::locale("en_US.UTF8")/std::locale::classic()/g' ${S}/test/credsCommons/parser/Parser.cpp
70 USERADD_PACKAGES = "${PN}"
71 GROUPADD_PARAM_${PN} = "-r cynara"
72 USERADD_PARAM_${PN} = "\
73 --system --home ${localstatedir}/lib/empty \
74 --no-create-home --shell /bin/false \
78 # Causes deadlock during booting, see workaround in postinst below.
80 #SYSTEMD_SERVICE_${PN} = "cynara.service"
82 do_install_append () {
83 chmod a+rx ${D}/${sbindir}/cynara-db-migration
85 install -d ${D}${sysconfdir}/cynara/
86 install -m 644 ${S}/conf/creds.conf ${D}/${sysconfdir}/cynara/creds.conf
88 # No need to create empty directories except for those which
89 # Cynara expects to find.
90 # install -d ${D}${localstatedir}/cynara/
91 # install -d ${D}${prefix}/share/cynara/tests/empty_db
92 install -d ${D}${libdir}/cynara/plugin/client
93 install -d ${D}${libdir}/cynara/plugin/service
95 # install db* ${D}${prefix}/share/cynara/tests/
97 install -d ${D}${systemd_unitdir}/system/sockets.target.wants
98 ln -s ../cynara.socket ${D}${systemd_unitdir}/system/sockets.target.wants/cynara.socket
99 ln -s ../cynara-admin.socket ${D}${systemd_unitdir}/system/sockets.target.wants/cynara-admin.socket
100 ln -s ../cynara-agent.socket ${D}${systemd_unitdir}/system/sockets.target.wants/cynara-agent.socket
103 FILES_${PN} += "${systemd_unitdir}/system"
105 # Cynara itself has no dependency on Smack. Only its installation
106 # is Smack-aware in the sense that it sets Smack labels. Do not
107 # depend on smack userspace unless we really need Smack labels.
109 # The Tizen .spec file calls cynara-db-migration in a %pre section.
110 # That only works when cynara-db-migration is packaged separately
111 # (overly complex) and does not seem necessary: perhaps there is a
112 # time window where cynara might already get activated before
113 # the postinst completes, but that is a general problem. It gets
114 # avoided entirely when calling this script while building the
116 RDEPENDS_${PN}_append_with-lsm-smack = " smack"
117 DEPENDS_append_with-lsm-smack = " smack-native"
118 CHSMACK_with-lsm-smack = "chsmack"
120 pkg_postinst_${PN} () {
124 # It would be nice to run the code below while building an image,
125 # but currently the calls to cynara-db-chsgen (a binary) in
126 # cynara-db-migration (a script) prevent that. Rely instead
127 # on OE's support for running failed postinst scripts at first boot.
128 if [ x"$D" != "x" ]; then
132 mkdir -p $D${sysconfdir}/cynara
133 ${CHSMACK} -a System $D${sysconfdir}/cynara
135 # Strip git patch level information, the version comparison code
136 # in cynara-db-migration only expect major.minor.patch version numbers.
137 VERSION=${@bb.data.getVar('PV',d,1).split('+git')[0]}
138 if [ -d $D${localstatedir}/cynara ] ; then
140 echo "NOTE: updating cynara DB to version $VERSION"
141 $D${sbindir}/cynara-db-migration upgrade -f 0.0.0 -t $VERSION
144 echo "NOTE: creating cynara DB for version $VERSION"
145 mkdir -p $D${localstatedir}/cynara
146 ${CHSMACK} -a System $D${localstatedir}/cynara
147 $D${sbindir}/cynara-db-migration install -t $VERSION
150 # Workaround for systemd.bbclass issue: it would call
151 # "systemctl start" without "--no-block", but because
152 # the service is not ready to run at the time when
153 # this scripts gets executed by run-postinsts.service,
155 echo "NOTE: enabling and starting cynara service"
156 systemctl enable cynara
157 systemctl start --no-block cynara